From 7fd5beb172c49205ca2679c6c06118d100bdce0a Mon Sep 17 00:00:00 2001 From: dingo Date: Thu, 26 Mar 2026 09:22:14 -0400 Subject: [PATCH] Fix 2-player placement zone and game.over null crash BoardShapeGenerator: 2-player rectangle now assigns one row per seat (row 0 for seat 0, top row for seat 1), restoring the original 1v1 behaviour. 3-4 player lobbies keep the two-row zones for extra placement room. Game.gd game.over: server sends playerOutcomes:null for 2-player games. d.get(key, default) returns null when the key exists with value null, so 'null as Array' crashed. Use 'is Array' guard to safely fall back to an empty array when the field is absent or null. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- Client/origin-client/autoloads/Game.gd | 3 ++- .../src/SOR.Game/Grid/BoardShapeGenerator.cs | 26 +++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Client/origin-client/autoloads/Game.gd b/Client/origin-client/autoloads/Game.gd index 65157c7..4bd5967 100644 --- a/Client/origin-client/autoloads/Game.gd +++ b/Client/origin-client/autoloads/Game.gd @@ -584,7 +584,8 @@ func _on_server_push(type: String, payload: Variant) -> void: var wc : String = str(d.get("winCondition", "")) var wd : int = int(d.get("winnerRankDelta", 0)) var ld : int = int(d.get("loserRankDelta", 0)) - var outcomes : Array = d.get("playerOutcomes", []) as Array + var _raw_outcomes = d.get("playerOutcomes") + var outcomes : Array = _raw_outcomes as Array if _raw_outcomes is Array else [] session_id = "" # Clear so _on_auth_reconnect doesn't resend game.ready for an ended game state = {} # Clear stale state so a new GameScreen calls send_ready() on the next match game_over.emit(winner, wc, wd, ld, outcomes) diff --git a/Server/src/SOR.Game/Grid/BoardShapeGenerator.cs b/Server/src/SOR.Game/Grid/BoardShapeGenerator.cs index bf44ed5..9cd0103 100644 --- a/Server/src/SOR.Game/Grid/BoardShapeGenerator.cs +++ b/Server/src/SOR.Game/Grid/BoardShapeGenerator.cs @@ -43,14 +43,24 @@ public static class BoardShapeGenerator var zones = new Dictionary>(); - // Seat 0 = bottom 2 rows - zones[0] = CoordsInRows(0, 1, w); - if (playerCount >= 2) - zones[1] = CoordsInRows(h - 2, h - 1, w); - if (playerCount >= 3) - zones[2] = CoordsInCols(0, 1, h); - if (playerCount >= 4) - zones[3] = CoordsInCols(w - 2, w - 1, h); + // 2-player: one placement row each (preserves original 1v1 behavior). + // 3-4 player: two rows/cols per seat to give more placement room. + if (playerCount <= 2) + { + zones[0] = CoordsInRows(0, 0, w); + if (playerCount >= 2) + zones[1] = CoordsInRows(h - 1, h - 1, w); + } + else + { + zones[0] = CoordsInRows(0, 1, w); + if (playerCount >= 2) + zones[1] = CoordsInRows(h - 2, h - 1, w); + if (playerCount >= 3) + zones[2] = CoordsInCols(0, 1, h); + if (playerCount >= 4) + zones[3] = CoordsInCols(w - 2, w - 1, h); + } // Return a new Board with the zones attached (Board is a reference type with mutable Tiles // so we create a wrapper that shares the same Tiles dictionary).