diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..d3c2da5 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @/Re-HLDS/developers \ No newline at end of file diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml new file mode 100644 index 0000000..1432d56 --- /dev/null +++ b/.github/workflows/Build.yml @@ -0,0 +1,62 @@ +name: Docker Image CI + +on: + push: + branches: [ master ] + paths-ignore: + - '**.md' + - '.vscode/**' + pull_request: + workflow_dispatch: + +jobs: + + build: + runs-on: ubuntu-latest + strategy: + matrix: + branch: + - steam_legacy + - public + mod: + # - valve + - cstrike + # - czero + # - dod + # - gearbox + # - tfc + # - ricochet + # - dmc + + env: + needToPush: ${{ github.ref == 'refs/heads/master' }} + + steps: + - uses: actions/checkout@v4.1.1 + - uses: docker/setup-buildx-action@v3.2.0 + + - name: Log in to Docker Hub + if: ${{ env.needToPush }} + uses: docker/login-action@v3.1.0 + with: + username: ${{ vars.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5.3.0 + env: + OWNER: ${{ vars.DOCKER_USERNAME }} + REPO: ${{ vars.DOCKER_REPOSITORY }} + TAG: ${{ matrix.branch }} + with: + context: . + file: ./Dockerfile + push: ${{ env.needToPush }} + tags: | + ${{ env.OWNER }}/${{ env.REPO }}:${{ env.TAG }} + ${{ env.TAG == 'steam_legacy' && format('{0}/{1}:latest', env.OWNER, env.REPO) || null}} + build-args: | + APPBRANCH=${{ matrix.branch }} + MOD=${{ matrix.mod }} + cache-from: type=gha,scope=build-${{ matrix.mod }}-${{ matrix.branch }} + cache-to: type=gha,mode=max,scope=build-${{ matrix.mod }}-${{ matrix.branch }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..775804d --- /dev/null +++ b/.gitignore @@ -0,0 +1,96 @@ +# Created by https://www.toptal.com/developers/gitignore/api/linux,macos,windows,visualstudiocode +# Edit at https://www.toptal.com/developers/gitignore?templates=linux,macos,windows,visualstudiocode + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/linux,macos,windows,visualstudiocode \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..e4022c7 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,37 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Build image", + "type": "docker-build", + "dockerBuild": { + "context": "${workspaceFolder}", + "tag": "testdemos:latest" + }, + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "type": "shell", + "label": "Run container", + "command": "docker run --rm -ti testdemos:latest", + "dependsOn": [ + "Build image" + ] + } + ], + "inputs": [ + { + "type": "pickString", + "id": "betaBranch", + "default": "public", + "description": "Select DepotsDownloader branch.", + "options": [ + "public", + "steam_legacy" + ] + } + ] +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1f28c87 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,76 @@ +FROM debian:stable-slim AS download_hlds_windows + +LABEL creator="Sergey Shorokhov " + +# Install required packages +RUN set -x \ + && apt-get update \ + && apt-get install -y --install-recommends \ + curl \ + libarchive-tools \ + && rm -rf /var/lib/apt/lists/* + +# Download and install DepotDownloader +ARG DepotDownloader_URL="https://github.com/SteamRE/DepotDownloader/releases/download/DepotDownloader_2.7.1/DepotDownloader-linux-x64.zip" +RUN curl -sSL ${DepotDownloader_URL} | bsdtar -xvf - -C /usr/local/bin/ \ + && chmod +x /usr/local/bin/DepotDownloader + +ENV APPDIR=/opt/hlds +WORKDIR ${APPDIR} + +ARG APPID=90 +ARG APPBRANCH=steam_legacy +ARG OS=windows +ARG MOD=cstrike + +RUN DepotDownloader -os ${OS} -dir ${APPDIR} -app ${APPID} -beta ${APPBRANCH} -depot 1 +RUN DepotDownloader -os ${OS} -dir ${APPDIR} -app ${APPID} -beta ${APPBRANCH} -depot 5 +RUN DepotDownloader -os ${OS} -dir ${APPDIR} -app ${APPID} -beta ${APPBRANCH} -depot 11 +RUN DepotDownloader -os ${OS} -dir ${APPDIR} -app ${APPID} -beta ${APPBRANCH} -depot 1004 + +SHELL ["/bin/bash", "-c"] + +# Fix first run crash and STEAM Validation rejected issue +RUN cp ${APPDIR}/${MOD}/steam_appid.txt ${APPDIR} \ + && touch ${APPDIR}/${MOD}/{banned,listip}.cfg + +# Remove unnecessary files +RUN rm -rf linux64 .DepotDownloader utils/ \ + && find . \ + \( \ + -name '*.so' -o \ + -name '*64.dll' -o \ + -name '*.dylib' \ + \) -exec rm -rf {} \; + +# Remove *.bsp +# RUN find . -name '*.bsp' \ +# \( \ +# -not -name 'rehlds_*' \ +# -not -name 'regamedll_*' \ +# -not -name 'de_dust2*' \ +# -not -name 'crossfire*' \ +# \) \ +# -delete + + +FROM debian:stable-slim AS test_runner + +RUN dpkg --add-architecture i386 \ + && apt-get update \ + && apt-get install -y \ + wine32 \ + rsync \ + && rm -rf /var/lib/apt/lists/* + +ENV WINEDEBUG=-all +ENV WINEDLLOVERRIDES=mshtml= + +COPY --from=download_hlds_windows /opt/hlds /opt/HLDS + +WORKDIR /opt/HLDS +# Add test depend files +COPY testdemos_files . + +# CMD [ "./test.sh" ] +# CMD wine hlds.exe --rehlds-enable-all-hooks --rehlds-test-play "testdemos/cstrike-basic-1.bin" -game cstrike -console -port 27039 +map regamedll_test_map_v5 \ No newline at end of file diff --git a/testdemos_files/cstrike/maps/regamedll_test_map_v5.bsp b/testdemos_files/cstrike/maps/regamedll_test_map_v5.bsp new file mode 100755 index 0000000..74f0587 Binary files /dev/null and b/testdemos_files/cstrike/maps/regamedll_test_map_v5.bsp differ diff --git a/testdemos_files/deps/regamedll/cstrike/server.cfg b/testdemos_files/deps/regamedll/cstrike/server.cfg new file mode 100755 index 0000000..b8f2f7f --- /dev/null +++ b/testdemos_files/deps/regamedll/cstrike/server.cfg @@ -0,0 +1,40 @@ +// Use this file to configure your DEDICATED server. +// This config file is executed on server start. + +// disable autoaim +sv_aim 0 + +// disable clients' ability to pause the server +pausable 0 + +// default server name. Change to "Bob's Server", etc. +hostname "Counter-Strike 1.6 Server" + +sv_minupdaterate 30 +sv_maxupdaterate 101 + +sv_minrate 10000 +sv_maxupdaterate 50000 + +// maximum client movement speed +sv_maxspeed 320 + +// 20 minute timelimit +mp_timelimit 20 +mp_startmoney 16000 +mp_flashlight 1 + +mp_autoteambalance 1 +mp_limitteams 3 +mp_roundtime 1.5 +mp_c4timer 25 +mp_friendlyfire 1 + +sv_cheats 0 +sv_allowupload 0 +sv_send_logos 0 + +// load ban files +exec listip.cfg +exec banned.cfg + diff --git a/testdemos_files/deps/regamedll/swds.dll b/testdemos_files/deps/regamedll/swds.dll new file mode 100755 index 0000000..fac8868 Binary files /dev/null and b/testdemos_files/deps/regamedll/swds.dll differ diff --git a/testdemos_files/deps/rehlds/cstrike/dlls/mp.dll b/testdemos_files/deps/rehlds/cstrike/dlls/mp.dll new file mode 100755 index 0000000..e5be674 Binary files /dev/null and b/testdemos_files/deps/rehlds/cstrike/dlls/mp.dll differ diff --git a/testdemos_files/deps/rehlds/cstrike/server.cfg b/testdemos_files/deps/rehlds/cstrike/server.cfg new file mode 100755 index 0000000..b462c3a --- /dev/null +++ b/testdemos_files/deps/rehlds/cstrike/server.cfg @@ -0,0 +1,31 @@ +// Use this file to configure your DEDICATED server. +// This config file is executed on server start. + +// disable autoaim +sv_aim 0 + +// disable clients' ability to pause the server +pausable 0 + +// default server name. Change to "Bob's Server", etc. +hostname "CS Test Server [Steam]" + +rcon_password "vH9.ChfusK" +sv_minupdaterate 30 +sv_maxupdaterate 101 + +sv_minrate 10000 +sv_maxupdaterate 50000 + +// maximum client movement speed +sv_maxspeed 320 + +// 20 minute timelimit +mp_timelimit 20 + +sv_cheats 0 + +// load ban files +exec listip.cfg +exec banned.cfg + diff --git a/testdemos_files/hlds.exe b/testdemos_files/hlds.exe new file mode 100755 index 0000000..a254fd9 Binary files /dev/null and b/testdemos_files/hlds.exe differ diff --git a/testdemos_files/swds.dll b/testdemos_files/swds.dll new file mode 100755 index 0000000..fac8868 Binary files /dev/null and b/testdemos_files/swds.dll differ diff --git a/testdemos_files/test.sh b/testdemos_files/test.sh new file mode 100755 index 0000000..b356c6d --- /dev/null +++ b/testdemos_files/test.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +chown root ~ +# rsync -a deps/regamedll/* . +rsync -a deps/rehlds/* . +# mv $GITHUB_WORKSPACE/tests/swds.dll . + +descs=( + # "CS: Testing jumping, scenarios, shooting etc" + "CS: Multiplayer" + # "Half-Life: Physics singleplayer" + # "Half-Life: Multiplayer on crossfire map" + # "Half-Life: Shooting with several weapons" +) +demos=( + # "cstrike-basic-1" + "cstrike-muliplayer-1" + # "rehlds-phys-single1" + # "crossfire-1-multiplayer-1" + # "shooting-hl-1" +) +retVal=0 +for i in "${!demos[@]}"; do + params=$(cat "testdemos/${demos[i]}.params") + echo -e "\e[1m[$((i + 1))/${#demos[@]}] \e[1;36m${descs[i]} testing...\e[0m" + echo -e " - \e[0;33mParameters $params\e[0m" + wine hlds.exe --rehlds-enable-all-hooks --rehlds-test-play "testdemos/${demos[i]}.bin" $params &> result.log || retVal=$? + + if [ $retVal -ne 777 ] && [ $retVal -ne 9 ]; then + # Print with catchy messages + while read line; do + echo -e " \e[0;33m$line" + done <<< $(cat result.log | sed '0,/demo failed/I!d;/wine:/d;/./,$!d') + echo " 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸 🔸" + + while read line; do + echo -e " \e[1;31m$line"; + done < rehlds_demo_error.txt + + echo -e " \e[30;41mExit code: $retVal\e[0m" + echo -e "\e[1m[$((i + 1))/${#demos[@]}] \e[1;36m${descs[i]} testing...\e[1;31m Failed ❌" + exit 6 # Test demo failed + else + # Print result HLDS console + while read line; do + echo -e " \e[0;33m$line" + done <<< $(cat result.log | sed '/wine:/d;/./,$!d') + + echo -e " \e[30;43mExit code: $retVal\e[0m" + echo -e "\e[1m[$((i + 1))/${#demos[@]}] \e[1;36m${descs[i]} testing...\e[1;32m Succeed ✔" + fi +done diff --git a/testdemos_files/testdemos/crossfire-1-multiplayer-1.bin b/testdemos_files/testdemos/crossfire-1-multiplayer-1.bin new file mode 100755 index 0000000..0a6e258 Binary files /dev/null and b/testdemos_files/testdemos/crossfire-1-multiplayer-1.bin differ diff --git a/testdemos_files/testdemos/crossfire-1-multiplayer-1.params b/testdemos_files/testdemos/crossfire-1-multiplayer-1.params new file mode 100755 index 0000000..8a8e0bc --- /dev/null +++ b/testdemos_files/testdemos/crossfire-1-multiplayer-1.params @@ -0,0 +1 @@ +-console -port 27030 -maxplayers 32 +map crossfire \ No newline at end of file diff --git a/testdemos_files/testdemos/cstrike-basic-1.bin b/testdemos_files/testdemos/cstrike-basic-1.bin new file mode 100755 index 0000000..2454863 Binary files /dev/null and b/testdemos_files/testdemos/cstrike-basic-1.bin differ diff --git a/testdemos_files/testdemos/cstrike-basic-1.params b/testdemos_files/testdemos/cstrike-basic-1.params new file mode 100755 index 0000000..c393f8f --- /dev/null +++ b/testdemos_files/testdemos/cstrike-basic-1.params @@ -0,0 +1 @@ +-game cstrike -console -port 27039 +map regamedll_test_map_v5 \ No newline at end of file diff --git a/testdemos_files/testdemos/cstrike-muliplayer-1.bin b/testdemos_files/testdemos/cstrike-muliplayer-1.bin new file mode 100755 index 0000000..4fdb528 Binary files /dev/null and b/testdemos_files/testdemos/cstrike-muliplayer-1.bin differ diff --git a/testdemos_files/testdemos/cstrike-muliplayer-1.params b/testdemos_files/testdemos/cstrike-muliplayer-1.params new file mode 100755 index 0000000..248ca5a --- /dev/null +++ b/testdemos_files/testdemos/cstrike-muliplayer-1.params @@ -0,0 +1 @@ +-game cstrike -console -port 27016 +map de_dust2 \ No newline at end of file diff --git a/testdemos_files/testdemos/rehlds-phys-single1.bin b/testdemos_files/testdemos/rehlds-phys-single1.bin new file mode 100755 index 0000000..d3142da Binary files /dev/null and b/testdemos_files/testdemos/rehlds-phys-single1.bin differ diff --git a/testdemos_files/testdemos/rehlds-phys-single1.params b/testdemos_files/testdemos/rehlds-phys-single1.params new file mode 100755 index 0000000..15c0161 --- /dev/null +++ b/testdemos_files/testdemos/rehlds-phys-single1.params @@ -0,0 +1 @@ +-console -port 27016 +map rehlds_test_map_v2 \ No newline at end of file diff --git a/testdemos_files/testdemos/shooting-hl-1.bin b/testdemos_files/testdemos/shooting-hl-1.bin new file mode 100755 index 0000000..a0de577 Binary files /dev/null and b/testdemos_files/testdemos/shooting-hl-1.bin differ diff --git a/testdemos_files/testdemos/shooting-hl-1.params b/testdemos_files/testdemos/shooting-hl-1.params new file mode 100755 index 0000000..15c0161 --- /dev/null +++ b/testdemos_files/testdemos/shooting-hl-1.params @@ -0,0 +1 @@ +-console -port 27016 +map rehlds_test_map_v2 \ No newline at end of file diff --git a/testdemos_files/valve/maps/rehlds_test_map_v2.bsp b/testdemos_files/valve/maps/rehlds_test_map_v2.bsp new file mode 100755 index 0000000..92e42fb Binary files /dev/null and b/testdemos_files/valve/maps/rehlds_test_map_v2.bsp differ