diff --git a/.github/workflows/map-tests.yml b/.github/workflows/map-tests.yml new file mode 100644 index 0000000..1ec39d0 --- /dev/null +++ b/.github/workflows/map-tests.yml @@ -0,0 +1,18 @@ +name: QuakeC Round 100 Tests +on: [pull_request] +jobs: + Round-100-Tests: + name: Run Round 100 Tests + runs-on: ubuntu-latest + container: + image: ubuntu:24.10 + options: --shm-size=8192m + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Wait for GitHub to keep up.. + run: sleep 2s + shell: bash + - name: Run Round 100 Script + run: | + bash testing/run_map_tests.sh diff --git a/source/server/ai/zombie_core.qc b/source/server/ai/zombie_core.qc index c04a29f..9e04b36 100644 --- a/source/server/ai/zombie_core.qc +++ b/source/server/ai/zombie_core.qc @@ -740,6 +740,11 @@ void() zombie_attack2 = { if(vlen(self.enemy.origin - self.origin) < 64) { + if (cvar("sys_testmode") == 2) { + self.th_die(); + return; + } + if (self.classname == "ai_dog") DamageHandler (self.enemy, self, 40, DMG_TYPE_ZOMBIESWIPE); else diff --git a/source/server/rounds.qc b/source/server/rounds.qc index c307db1..9f067cf 100644 --- a/source/server/rounds.qc +++ b/source/server/rounds.qc @@ -209,6 +209,20 @@ void() NewRound = rounds = rounds + 1; + if (cvar("sys_testmode") == 2) { + if (rounds >= 100) { + localcmd("quit\n"); + } else if (rounds % 5 == 0) { +#ifdef FTE + print(sprintf(" + Reached round [%d]\n", rounds)); +#endif + } + } + + if (rounds >= 100 && cvar("sys_testmode") == 2) { + localcmd("quit\n"); + } + #ifdef FTE // FTE-Specific - alert CSQC of the round increment for HUD display diff --git a/testing/run_map_tests.sh b/testing/run_map_tests.sh new file mode 100644 index 0000000..6b9b81b --- /dev/null +++ b/testing/run_map_tests.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# +# Nazi Zombies: Portable +# QuakeC Round 100 test runs on every bundled map. +# ---- +# This is intended to be used via a Docker +# container running ubuntu:24.10. +# +set -o errexit + +# tzdata will try to display an interactive install prompt by +# default, so make sure we define our system as non-interactive. +export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true + +WORKING_DIRECTORY="/working" +OUTPUT_LOG="${WORKING_DIRECTORY}/run.log" +REPO_PWD=$(pwd) + +function setup_container() +{ + echo "[INFO]: Installing dependancies.." + apt update -y + apt install libsdl2-dev wget zip python3 python3-pip -y + wget https://raw.githubusercontent.com/nzp-team/QCHashTableGenerator/main/requirements.txt + pip install -r requirements.txt --break-system-packages + rm requirements.txt + mkdir -p "${WORKING_DIRECTORY}" +} + +function download_nzp() +{ + echo "[INFO]: Obtaining latest Nazi Zombies: Portable Linux x86_64 release.." + cd "${WORKING_DIRECTORY}" + wget https://github.com/nzp-team/nzportable/releases/download/nightly/nzportable-linux64.zip + mkdir nzportable-linux64 + unzip nzportable-linux64.zip -d nzportable-linux64/ + chmod +x nzportable-linux64/nzportable64-sdl +} + +function build_quakec() +{ + echo "[INFO]: Building QuakeC.." + cd "${REPO_PWD}/tools" + local cmd="./qc-compiler-gnu.sh" + ${cmd} + + echo "[INFO]: Moving QuakeC to game download.." + cp "${REPO_PWD}/build/fte/qwprogs.dat" "${WORKING_DIRECTORY}/nzportable-linux64/nzp/" +} + +function run_test() +{ + echo "[INFO]: Running tests.." + cd "${WORKING_DIRECTORY}/nzportable-linux64/" + + # Iterate through every map.. + while read -r map; do + local pretty_name=$(basename ${map} .bsp) + echo "[INFO]: Running [${pretty_name}].." + + local cmd="./nzportable64-sdl +map ${pretty_name} +vid_renderer headless +sys_testmode 2 +slowmo 100" + ${cmd} + done < <(find nzp/maps/ -type f -name "*.bsp") + + echo "[INFO]: TEST PASSED." +} + +function main() +{ + setup_container; + download_nzp; + build_quakec; + run_test; +} + +main; \ No newline at end of file