Files
tidewall/tools/client_check.sh
T
claudeandClaude Opus 5.5 9a36ae8615 N10: Playable network client
The client program now turns a connection into a match someone can play.

- ClientSession: a ClientGame, the keyboard and mouse as commands
  (ClientInput), and a MatchView of the client's own copy of the world.
- ClientMirror writes what the client is showing into that world every
  frame: other players from the recent past, its own player where it was
  predicted, items, the barge, the clock and the sea. The existing views
  draw it unchanged.
- LocalServer: offline play is the same ServerLoop and NetGame in the same
  process, with packets handed across in memory, so there is one path.
- main.gd: --connect=HOST[:PORT] joins a server, otherwise an offline
  match; --autoplay and --client-seconds=N for scripts and checks.
- The camera aboard the barge follows the player's own place on the deck.

Tests drive a scripted client through a whole match on a real server over
loopback UDP, lobby to results, and through an offline match. `make
client-check` does it with two real processes, and `make client-captures`
renders what the client sees.

Closes #77

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 14:50:52 -05:00

47 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Starts a real dedicated server and a real client as two processes, joins the client
# to the server over loopback UDP with its autoplay script at the controls, and checks
# it got from the lobby into the match and played. Both run headless and in real time,
# so this takes about a minute: the lobby waits 20 s and counts down 10 s.
#
# tools/client_check.sh CLIENT_CHECK_PORT=N picks the UDP port (default 24677)
set -euo pipefail
repo="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
port="${CLIENT_CHECK_PORT:-24677}"
out="$repo/build/client-check"
mkdir -p "$out"
nice -n 15 "$repo/tools/godot.sh" -- --server --listen --port="$port" --seed=41 --bots=3 --ticks=2100 >"$out/server.log" 2>&1 &
server=$!
trap 'kill "$server" 2>/dev/null || true' EXIT
sleep 3
set +e
nice -n 15 "$repo/tools/godot.sh" -- --connect="127.0.0.1:$port" --name=Mara --autoplay --client-seconds=55 >"$out/client.log" 2>&1
client_code=$?
wait "$server"
server_code=$?
set -e
trap - EXIT
report="$(grep -m1 '"event":"client"' "$out/client.log" || true)"
fail() {
echo "client-check: $1" >&2
echo " client: ${report:-no report}" >&2
tail -n 5 "$out/server.log" >&2
exit 1
}
[[ "$client_code" -eq 0 ]] || fail "the client exited with $client_code"
[[ "$server_code" -eq 0 ]] || fail "the server exited with $server_code"
[[ -n "$report" ]] || fail "the client said nothing"
grep -q '"joined":true' <<<"$report" || fail "the client never joined"
grep -q '"phases":\["lobby","countdown","drop"' <<<"$report" || fail "the client didn't follow the match from the lobby into the drop"
grep -q '"bad_packets":0' <<<"$report" || fail "the client was sent packets it couldn't read"
playing="$(sed -n 's/.*"frames_playing":\([0-9]*\).*/\1/p' <<<"$report")"
[[ "${playing:-0}" -ge 300 ]] || fail "the client's player was in the match for only ${playing:-0} frames"
grep -q '"event":"player_joined".*"name":"Mara"' "$out/server.log" || fail "the server never saw the client join"
grep -q '"errors":0,"event":"stop"' "$out/server.log" || fail "the server logged errors"
if grep -q 'SCRIPT ERROR' "$out/client.log"; then fail "the client logged script errors"; fi
echo "client-check: ok (joined over UDP, lobby to drop, played $playing frames, no bad packets)"
echo " $report"