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.
This commit is contained in:
Dunedan 2024-07-10 06:20:51 +00:00
parent 62692ca270
commit b68a22ecdb
2 changed files with 2 additions and 9 deletions

View File

@ -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;

View File

@ -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.