#!/usr/bin/env bash # Two real client processes with different avatar customizations against # one real dedicated server: # Machine A (customized character) and Machine B (uncustomized character). # Client A must render Client B with NO customizations and NO pink/purple tint. # Client B must render Client A WITH customizations and NO pink/purple tint. 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=7789 cleanup() { kill "${SRV_PID:-}" "${B_PID:-}" "${A_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/mp_avatar_server.log 2>&1 & SRV_PID=$! sleep 3 echo "=== starting client B (uncustomized character) ===" "$GODOT_BIN" --headless --path . --script res://scripts/mp_avatar_test_client.gd -- --role b --port "$PORT" >/tmp/mp_avatar_b.log 2>&1 & B_PID=$! for _ in $(seq 1 30); do grep -q 'RESULT b in_world' /tmp/mp_avatar_b.log && break; sleep 1; done grep -q 'RESULT b in_world' /tmp/mp_avatar_b.log || { echo "B failed to enter world:"; cat /tmp/mp_avatar_b.log; exit 1; } echo "=== running client A (customized character) ===" "$GODOT_BIN" --headless --path . --script res://scripts/mp_avatar_test_client.gd -- --role a --port "$PORT" >/tmp/mp_avatar_a.log 2>&1 & A_PID=$! wait "$A_PID" 2>/dev/null A_STATUS=$? wait "$B_PID" 2>/dev/null B_STATUS=$? A_LINE=$(grep '^RESULT a' /tmp/mp_avatar_a.log || true) B_LINE=$(grep '^RESULT b' /tmp/mp_avatar_b.log || true) echo echo "server: $(grep -c 'joined' /tmp/mp_avatar_server.log) joins seen" echo "A (Machine A observing Machine B): ${A_LINE:-}" echo "B (Machine B observing Machine A): ${B_LINE:-}" if [ $A_STATUS -eq 0 ] && [ $B_STATUS -eq 0 ] \ && echo "$A_LINE" | grep -q 'ok=true' \ && echo "$B_LINE" | grep -q 'ok=true'; then echo "=== MULTIPLAYER AVATAR REPLICATION RESULT: PASS ===" exit 0 fi echo "=== MULTIPLAYER AVATAR REPLICATION RESULT: FAIL ===" exit 1