Skip to content

Commit

Permalink
Add engine and mod version test before loading the persist-matchsetti…
Browse files Browse the repository at this point in the history
…ngs file.

This should be unneeded if the settings were parsed rather than copied directly.

Differential Revision: https://code.wildfiregames.com/D1475
Reviewed By: Itms



git-svn-id: https://svn.wildfiregames.com/public/ps/trunk@21802 3db68df2-c116-0410-a063-a993310a9797
  • Loading branch information
elexis committed Apr 29, 2018
1 parent a87423c commit e14a64c
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions binaries/data/mods/public/gui/gamesetup/gamesetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -1847,16 +1847,20 @@ function loadPersistMatchSettings()
if (!Engine.FileExists(settingsFile))
return;

let attrs = Engine.ReadJSONFile(settingsFile);
if (!attrs || !attrs.settings)
let data = Engine.ReadJSONFile(settingsFile);
if (!data || !data.attributes || !data.attributes.settings)
return;

if (data.engine_info.engine_version != Engine.GetEngineInfo().engine_version ||
!hasSameMods(data.engine_info.mods, Engine.GetEngineInfo().mods))
return;

g_IsInGuiUpdate = true;

let mapName = attrs.map || "";
let mapSettings = attrs.settings;
let mapName = data.attributes.map || "";
let mapSettings = data.attributes.settings;

g_GameAttributes = attrs;
g_GameAttributes = data.attributes;

if (!g_IsNetworked)
mapSettings.CheatsEnabled = true;
Expand Down Expand Up @@ -1898,8 +1902,17 @@ function savePersistMatchSettings()
{
if (g_IsTutorial)
return;
let attributes = Engine.ConfigDB_GetValue("user", "persistmatchsettings") == "true" ? g_GameAttributes : {};
Engine.WriteJSONFile(g_IsNetworked ? g_MatchSettings_MP : g_MatchSettings_SP, attributes);

Engine.WriteJSONFile(
g_IsNetworked ? g_MatchSettings_MP : g_MatchSettings_SP,
{
"attributes":
// Delete settings if disabled, so that players are not confronted with old settings after enabling the setting again
Engine.ConfigDB_GetValue("user", "persistmatchsettings") == "true" ?
g_GameAttributes :
{},
"engine_info": Engine.GetEngineInfo()
});
}

function sanitizePlayerData(playerData)
Expand Down

0 comments on commit e14a64c

Please sign in to comment.