From 4f33fc01f1cddbebe86bec0cf7b285a372c77df9 Mon Sep 17 00:00:00 2001 From: xerus2000 <27jf@pm.me> Date: Fri, 12 Feb 2021 18:55:52 +0100 Subject: [PATCH] fix: save test mode scores before broadcasting GameResult Prevents race conditions creating errors in the TestClient and failing our CI. --- server/src/sc/server/gaming/GameRoom.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/server/src/sc/server/gaming/GameRoom.java b/server/src/sc/server/gaming/GameRoom.java index 9ddd56c83..21d3405e9 100644 --- a/server/src/sc/server/gaming/GameRoom.java +++ b/server/src/sc/server/gaming/GameRoom.java @@ -89,6 +89,11 @@ public synchronized void onGameOver(Map results) throws Inv try { result = generateGameResult(results); logger.info("{} is over (regular={})", game, result.isRegular()); + // save playerScore if test mode enabled + if (Boolean.parseBoolean(Configuration.get(Configuration.TEST_MODE))) { + List players = game.getPlayers(); + gameRoomManager.addResultToScore(this.getResult(), players.get(0).getDisplayName(), players.get(1).getDisplayName()); + } broadcast(result); } catch(Throwable t) { logger.error("Failed to generate GameResult from " + results, t); @@ -98,12 +103,6 @@ public synchronized void onGameOver(Map results) throws Inv saveReplay(); } - // save playerScore if test mode enabled - if (Boolean.parseBoolean(Configuration.get(Configuration.TEST_MODE))) { - List players = game.getPlayers(); - gameRoomManager.addResultToScore(this.getResult(), players.get(0).getDisplayName(), players.get(1).getDisplayName()); - } - kickAllClients(); cancel(); }