From b68a22ecdbdeeacec0086446f8038c0dc7f98736 Mon Sep 17 00:00:00 2001 From: Dunedan Date: Wed, 10 Jul 2024 06:20:51 +0000 Subject: [PATCH] Instantiate controller only for the host This moves the check whether a player is the host out of `LobbyGameRegistrationController` and only creates an instance of it in `SetupWindow` if the player is the host. This solves a problem with `LobbyGameRegistrationController.onGameStart()` getting triggered by players not being the host and sending unnecessary and invalid changestate stanzas to XpartaMuPP. Patch by: @Dunedan Accepted by: @Stan Differential Revision: https://code.wildfiregames.com/D5270 This was SVN commit r28148. --- .../gui/gamesetup/Controllers/LobbyGameRegistration.js | 9 +-------- binaries/data/mods/public/gui/gamesetup/SetupWindow.js | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/binaries/data/mods/public/gui/gamesetup/Controllers/LobbyGameRegistration.js b/binaries/data/mods/public/gui/gamesetup/Controllers/LobbyGameRegistration.js index d498b6755e..3757995ca6 100644 --- a/binaries/data/mods/public/gui/gamesetup/Controllers/LobbyGameRegistration.js +++ b/binaries/data/mods/public/gui/gamesetup/Controllers/LobbyGameRegistration.js @@ -46,8 +46,7 @@ class LobbyGameRegistrationController onClosePage() { - if (g_IsController && Engine.HasXmppClient()) - Engine.SendUnregisterGame(); + Engine.SendUnregisterGame(); } /** @@ -55,9 +54,6 @@ class LobbyGameRegistrationController */ sendDelayed() { - if (!g_IsController || !Engine.HasXmppClient()) - return; - // Already sending an update - do nothing. if (this.timer !== undefined) return; @@ -70,9 +66,6 @@ class LobbyGameRegistrationController */ sendImmediately() { - if (!g_IsController || !Engine.HasXmppClient()) - return; - // Wait until a map has been selected. if (!g_GameSettings.map.map) return; diff --git a/binaries/data/mods/public/gui/gamesetup/SetupWindow.js b/binaries/data/mods/public/gui/gamesetup/SetupWindow.js index 98a1545b93..8a9caed17a 100644 --- a/binaries/data/mods/public/gui/gamesetup/SetupWindow.js +++ b/binaries/data/mods/public/gui/gamesetup/SetupWindow.js @@ -33,7 +33,7 @@ class SetupWindow let playerAssignmentsController = new PlayerAssignmentsController(this, netMessages); let gameSettingsController = new GameSettingsController(this, netMessages, playerAssignmentsController, mapCache); let readyController = new ReadyController(netMessages, gameSettingsController, playerAssignmentsController); - let lobbyGameRegistrationController = Engine.HasXmppClient() && + const lobbyGameRegistrationController = g_IsController && Engine.HasXmppClient() && new LobbyGameRegistrationController(initData, this, netMessages, mapCache, playerAssignmentsController); // These class instances control central data and do not manage any GUI Object.