mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-15 05:52:13 +00:00
fix(multiplayer): lock signed team assignments
This commit is contained in:
@@ -70,6 +70,23 @@ func test_draining_disconnect_still_releases_roster_and_join_token() -> void:
|
||||
assert_true(float(match_net._join_history[token].get("lost_at", 0.0)) > 0.0, "disconnect records the reclaim boundary during drain")
|
||||
|
||||
|
||||
func test_signed_assignment_locks_team_and_spawn_slot_together() -> void:
|
||||
var match_net := MatchNet.new()
|
||||
var info := MatchNet.PlayerInfo.new(42, "Alice", 0, true, "player-1")
|
||||
info.spawn_index = 2
|
||||
match_net.roster[42] = info
|
||||
match_net.require_join_authorisation = true
|
||||
assert_true(not match_net._apply_team_change(42, 1), "allocated clients cannot override their signed team")
|
||||
assert_eq(info.team, 0, "signed team is unchanged")
|
||||
assert_eq(info.spawn_index, 2, "signed spawn index remains paired with its team")
|
||||
assert_true(info.ready, "rejected mutation does not alter readiness")
|
||||
|
||||
match_net.require_join_authorisation = false
|
||||
assert_true(match_net._apply_team_change(42, 1), "direct lobbies retain team switching")
|
||||
assert_eq(info.team, 1, "direct team switch applies")
|
||||
assert_true(not info.ready, "direct team switch still clears readiness")
|
||||
|
||||
|
||||
func test_reservation_reclaim_requires_stable_identity() -> void:
|
||||
assert_true(MatchNet.reservation_identity_matches("player-a", "player-a", "Alice", "Impostor"), "the verified identity can reclaim despite a changed display name")
|
||||
assert_true(not MatchNet.reservation_identity_matches("player-a", "player-b", "Alice", "Alice"), "a same-name peer cannot reclaim another identity's slot")
|
||||
|
||||
Reference in New Issue
Block a user