Fix MP gamesetup issues with mapfilter

- Settings weren't sent to the server when mapfilters change.
- Because of ordering issues, the 'multiplayer' mapfilter would be
activated at the wrong time and things would go haywire.
- Likewise, selecting a non-default map with a non-default filter
wouldn't work well.

Fixes #6208

Differential Revision: https://code.wildfiregames.com/D4111
This was SVN commit r25731.
This commit is contained in:
wraitii 2021-06-07 11:40:43 +00:00
parent 70f2ac6788
commit 09a33b6626
3 changed files with 20 additions and 15 deletions

View File

@ -94,15 +94,16 @@ class GameSettingsController
g_GameSettings.playerAI.get(g_PlayerAssignments[guid].player - 1)) g_GameSettings.playerAI.get(g_PlayerAssignments[guid].player - 1))
g_GameSettings.playerAI.set(g_PlayerAssignments[guid].player - 1, undefined); g_GameSettings.playerAI.set(g_PlayerAssignments[guid].player - 1, undefined);
for (const handler of this.settingsLoadedHandlers)
handler();
this.updateLayout(); this.updateLayout();
this.setNetworkInitAttributes(); this.setNetworkInitAttributes();
// If we are the controller, we are done loading. // If we are the controller, we are done loading.
if (hotloadData || !g_IsNetworked || g_IsController) if (hotloadData || !g_IsNetworked || g_IsController)
{
for (const handler of this.settingsLoadedHandlers)
handler();
this.setLoading(false); this.setLoading(false);
}
} }
onClientJoin() onClientJoin()
@ -159,15 +160,18 @@ class GameSettingsController
// Ignore initial updates if we've already received settings. // Ignore initial updates if we've already received settings.
if (!this.loading) if (!this.loading)
return; return;
this.parseSettings(message.data.initAttribs);
for (const handler of this.settingsLoadedHandlers)
handler();
this.setLoading(false); this.setLoading(false);
} }
else
this.parseSettings(message.data.initAttribs); this.parseSettings(message.data.initAttribs);
// This assumes that messages aren't sent spuriously without changes // This assumes that messages aren't sent spuriously without changes
// (which is generally fair), but technically it would be good // (which is generally fair), but technically it would be good
// to check if the new data is different from the previous data. // to check if the new data is different from the previous data.
for (let handler of this.settingsChangeHandlers) for (const handler of this.settingsChangeHandlers)
handler(); handler();
} }
@ -186,9 +190,9 @@ class GameSettingsController
*/ */
parseSettings(settings) parseSettings(settings)
{ {
g_GameSettings.fromInitAttributes(settings);
if (settings.guiData) if (settings.guiData)
this.guiData.Deserialize(settings.guiData); this.guiData.Deserialize(settings.guiData);
g_GameSettings.fromInitAttributes(settings);
} }
setLoading(loading) setLoading(loading)

View File

@ -74,6 +74,7 @@ GameSettingControls.MapFilter = class MapFilter extends GameSettingControlDropdo
onSelectionChange(itemIdx) onSelectionChange(itemIdx)
{ {
this.gameSettingsController.guiData.mapFilter.filter = this.values.Name[itemIdx]; this.gameSettingsController.guiData.mapFilter.filter = this.values.Name[itemIdx];
this.gameSettingsController.setNetworkInitAttributes();
} }
}; };

View File

@ -37,6 +37,13 @@ GameSettingControls.MapSelection = class MapSelection extends GameSettingControl
this.gameSettingsController.guiData.mapFilter.watch(() => this.updateMapList(), ["filter"]); this.gameSettingsController.guiData.mapFilter.watch(() => this.updateMapList(), ["filter"]);
this.updateMapList(); 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(); this.render();
@ -59,13 +66,6 @@ GameSettingControls.MapSelection = class MapSelection extends GameSettingControl
if (!this.values) if (!this.values)
return; 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); this.setSelectedValue(g_GameSettings.map.map);
} }
@ -77,7 +77,7 @@ GameSettingControls.MapSelection = class MapSelection extends GameSettingControl
return; return;
{ {
let values = const values =
this.mapFilters.getFilteredMaps( this.mapFilters.getFilteredMaps(
g_GameSettings.map.type, g_GameSettings.map.type,
this.gameSettingsController.guiData.mapFilter.filter, this.gameSettingsController.guiData.mapFilter.filter,