Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Requirements:
- Desktop development with C++:
- MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)
- Windows 11 SDK (10.0.22621.0) or Windows 10 SDK (10.0.19041.1)
- Python 3.13 or later

Inside the cloned directory, navigate to `src`, run:
```bat
Expand Down
31 changes: 31 additions & 0 deletions src/devtools/bin/texttoarray.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
param
(
[ Parameter( Mandatory = $true ) ][ string ]$sFileName,
[ Parameter( Mandatory = $true ) ][ string ]$sObjName
)

$Bytes = [ System.IO.File ]::ReadAllBytes( $sFileName )

Write-Output "static unsigned char $sObjName[] = {"

$sLine = " "
for ( $i = 0; $i -lt $Bytes.Length; $i++ )
{
$Byte = $Bytes[ $i ]

if ( ( $i % 20 ) -ne 0 )
{
$sLine += " "
}
$sLine += ( "0x{0:x2}," -f $Byte )

if ( ( $i % 20 ) -eq 19 )
{
Write-Output $sLine
$sLine = " "
}
}

$sLine += " 0x00"
Write-Output $sLine
Write-Output "};"
22 changes: 0 additions & 22 deletions src/devtools/bin/texttoarray.py

This file was deleted.

29 changes: 29 additions & 0 deletions src/devtools/bin/texttoarray.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

if [ $# -lt 2 ]; then
echo "Usage: $0 <filename> <name>"
exit 1
fi

sFileName="$1"
sObjName="$2"

exec 3< "$sFileName"

printf "static unsigned char %s[] = {\n " "$sObjName"

i=0
while :; do
Byte=$(dd bs=1 count=1 <&3 2>/dev/null | od -An -t u1)
[ -z "$Byte" ] && break

Byte=$(printf "%s" "$Byte" | tr -d '[:space:]')
printf "0x%02x," "$Byte"

i=$(( i + 1 ))
if [ $(( i % 20 )) -eq 0 ]; then
printf "\n "
fi
done

printf "0x00\n};\n"
4 changes: 2 additions & 2 deletions src/game/server/server_base.vpc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ $Configuration "Release"

$CustomBuildStep "nut"
{
$CommandLine "python $SRCDIR\devtools\bin\texttoarray.py $(InputPath) g_Script_$(InputName)> $(InputName)_nut.h" [$WINDOWS]
$CommandLine "python $SRCDIR\devtools\bin\texttoarray.py $(InputPath) g_Script_$(InputName)> $(InputName)_nut.h" [$POSIX]
$CommandLine "powershell -NoProfile -ExecutionPolicy Bypass -File $SRCDIR\devtools\bin\texttoarray.ps1 $(InputPath) g_Script_$(InputName)> $(InputName)_nut.h" [$WINDOWS]
$CommandLine "sh $SRCDIR\devtools\bin\texttoarray.sh $(InputPath) g_Script_$(InputName)> $(InputName)_nut.h" [$POSIX]
$Description "$(InputFileName) produces $(InputName)_nut.h"
$Outputs "$(InputName)_nut.h"
}
Expand Down