Files
modbison/scripts/run_multiplayer_2p_test.sh
T
daddy 7ccdd3063a
checkpoint / checkpoint (push) Failing after 1m34s
Fix: players fall through the floor in multiplayer
scenes/server_player.tscn was a bare CharacterBody3D with NO CollisionShape3D,
so on the server move_and_slide() never hit the ground and is_on_floor() was
always false -> the server player fell forever, and the client (which snaps to
the server's authoritative position past a drift threshold) fell with it.

Give the server player the same CapsuleShape3D (r=0.35, h=1.6) as the client.
The 2-player test now also asserts the server keeps the player on the ground
(on_floor / min_y), which is how this slipped through -- the tests only
checked "position changes" and "sees the other player".

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015jtxAiu5dAW4WxCNdGkrkJ
2026-09-05 22:58:55 +00:00

48 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Two real client processes against one real dedicated server: client A must
# see client B and its own movement must round-trip through the server.
#
# Usage: scripts/run_multiplayer_2p_test.sh
# Exit 0 iff A reports moved=true and remotes>=1.
set -uo pipefail
cd "$(dirname "$0")/.."
GODOT_BIN="${GODOT_BIN:-godot}"
command -v "$GODOT_BIN" >/dev/null 2>&1 || GODOT_BIN="$HOME/godot/godot"
PORT=7787
cleanup() { kill "${SRV_PID:-}" "${B_PID:-}" 2>/dev/null; wait 2>/dev/null; }
trap cleanup EXIT
echo "=== starting dedicated server on $PORT ==="
"$GODOT_BIN" --headless --path . res://scenes/server.tscn -- --port "$PORT" >/tmp/mp2p_server.log 2>&1 &
SRV_PID=$!
sleep 3
echo "=== starting client B (idle observer) ==="
"$GODOT_BIN" --headless --path . --script res://scripts/mp_test_client.gd -- --role b --port "$PORT" >/tmp/mp2p_b.log 2>&1 &
B_PID=$!
# Wait until B is actually connected before starting A.
for _ in $(seq 1 30); do grep -q 'RESULT b connected' /tmp/mp2p_b.log && break; sleep 1; done
echo "=== running client A (mover) ==="
"$GODOT_BIN" --headless --path . --script res://scripts/mp_test_client.gd -- --role a --port "$PORT" 2>&1 | tee /tmp/mp2p_a.log
A_LINE=$(grep '^RESULT a' /tmp/mp2p_a.log || true)
wait "$B_PID" 2>/dev/null
B_LINE=$(grep '^RESULT b' /tmp/mp2p_b.log || true)
echo
echo "server: $(grep -c 'joined' /tmp/mp2p_server.log) joins seen"
echo "A: ${A_LINE:-<none>}"
echo "B: ${B_LINE:-<none>}"
if echo "$A_LINE" | grep -q 'moved=true' \
&& echo "$A_LINE" | grep -qE 'remotes=[1-9]' \
&& echo "$A_LINE" | grep -q 'on_floor=true'; then
echo "=== SMOKE RESULT: PASS ==="
exit 0
fi
echo "=== SMOKE RESULT: FAIL ==="
exit 1