From 224a96373b8e1e33a34f3ef67e31ca178d20730e Mon Sep 17 00:00:00 2001 From: wraitii Date: Mon, 7 Jun 2021 19:55:05 +0000 Subject: [PATCH] Revert parts of 09a33b6626 There is an issue when no matchsettings.json is present. This keeps the network synchronisation fix, that worked. This was SVN commit r25739. --- .../Controllers/GameSettingsController.js | 18 +++++++----------- .../Single/Dropdowns/MapSelection.js | 16 ++++++++-------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/binaries/data/mods/public/gui/gamesetup/Controllers/GameSettingsController.js b/binaries/data/mods/public/gui/gamesetup/Controllers/GameSettingsController.js index e05d8d66d3..7dd798ce84 100644 --- a/binaries/data/mods/public/gui/gamesetup/Controllers/GameSettingsController.js +++ b/binaries/data/mods/public/gui/gamesetup/Controllers/GameSettingsController.js @@ -94,16 +94,15 @@ class GameSettingsController g_GameSettings.playerAI.get(g_PlayerAssignments[guid].player - 1)) g_GameSettings.playerAI.set(g_PlayerAssignments[guid].player - 1, undefined); + for (const handler of this.settingsLoadedHandlers) + handler(); + this.updateLayout(); this.setNetworkInitAttributes(); // If we are the controller, we are done loading. if (hotloadData || !g_IsNetworked || g_IsController) - { - for (const handler of this.settingsLoadedHandlers) - handler(); this.setLoading(false); - } } onClientJoin() @@ -160,18 +159,15 @@ class GameSettingsController // Ignore initial updates if we've already received settings. if (!this.loading) return; - this.parseSettings(message.data.initAttribs); - for (const handler of this.settingsLoadedHandlers) - handler(); this.setLoading(false); } - else - this.parseSettings(message.data.initAttribs); + + this.parseSettings(message.data.initAttribs); // This assumes that messages aren't sent spuriously without changes // (which is generally fair), but technically it would be good // to check if the new data is different from the previous data. - for (const handler of this.settingsChangeHandlers) + for (let handler of this.settingsChangeHandlers) handler(); } @@ -190,9 +186,9 @@ class GameSettingsController */ parseSettings(settings) { - g_GameSettings.fromInitAttributes(settings); if (settings.guiData) this.guiData.Deserialize(settings.guiData); + g_GameSettings.fromInitAttributes(settings); } setLoading(loading) diff --git a/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/MapSelection.js b/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/MapSelection.js index a943128146..e4f9ac8672 100644 --- a/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/MapSelection.js +++ b/binaries/data/mods/public/gui/gamesetup/Pages/GameSetupPage/GameSettings/Single/Dropdowns/MapSelection.js @@ -37,13 +37,6 @@ GameSettingControls.MapSelection = class MapSelection extends GameSettingControl this.gameSettingsController.guiData.mapFilter.watch(() => this.updateMapList(), ["filter"]); this.updateMapList(); - - // We can end up with incorrect settings in various situations. - if (this.values.file.indexOf(g_GameSettings.map.map) === -1) - { - g_GameSettings.map.selectMap(this.values.file[this.values.Default]); - return; - } } this.render(); @@ -66,6 +59,13 @@ GameSettingControls.MapSelection = class MapSelection extends GameSettingControl if (!this.values) return; + // We can end up with incorrect map selection when dependent settings change. + if (this.values.file.indexOf(g_GameSettings.map.map) === -1) + { + g_GameSettings.map.selectMap(this.values.file[this.values.Default]); + return; + } + this.setSelectedValue(g_GameSettings.map.map); } @@ -77,7 +77,7 @@ GameSettingControls.MapSelection = class MapSelection extends GameSettingControl return; { - const values = + let values = this.mapFilters.getFilteredMaps( g_GameSettings.map.type, this.gameSettingsController.guiData.mapFilter.filter,