Ticket #3883: persist_match_settings.patch

File persist_match_settings.patch, 1.9 KB (added by Imarok, 8 years ago)

Only restore the settings the user can change (Based on elexis' roughsketch.patch)

  • binaries/data/mods/public/gui/gamesetup/gamesetup.js

     
    863863    if (Engine.ConfigDB_GetValue("user", "persistmatchsettings") != "true")
    864864        return;
    865865
     866    // Load file
    866867    let settingsFile = g_IsNetworked ? g_MatchSettings_MP : g_MatchSettings_SP;
    867868    if (!Engine.FileExists(settingsFile))
    868869        return;
     
    871872    if (!attrs || !attrs.settings)
    872873        return;
    873874
     875    // Find which settings can be changed by the user
     876    let allowedSettings = ["PlayerData"];
     877
     878    if (attrs.mapType == "skirmish")
     879        allowedSettings = allowedSettings.concat(["GameType", "VictoryScripts", "WonderDuration", "PopulationCap", "Ceasefire", "StartingResources", "RevealMap", "LockTeams", "ExploreMap", "DisableTreasures"]);
     880
     881    if (attrs.mapType == "random")
     882        allowedSettings = allowedSettings.concat(["Size", "GameType", "VictoryScripts", "WonderDuration", "PopulationCap", "Ceasefire", "StartingResources", "RevealMap", "LockTeams", "ExploreMap", "DisableTreasures"]);
     883
     884    attrs.settings.RatingEnabled = Engine.HasXmppClient();
     885    Engine.SetRankedGame(attrs.settings.RatingEnabled);
     886
     887    if (g_IsNetworked && !attrs.settings.RatingEnabled)
     888        allowedSettings.push("CheatsEnabled");
     889
     890    // Only load settings which can be changed by the user
     891    for (let prop in attrs.settings)
     892        if (!prop in allowedSettings)
     893            delete attrs.settings[prop];
     894
     895    // Restore valid matchsettings
    874896    g_IsInGuiUpdate = true;
    875897
    876898    let mapName = attrs.map || "";
     
    908930    // Reload, as the maptype or mapfilter might have changed
    909931    initMapNameList();
    910932
    911     g_GameAttributes.settings.RatingEnabled = Engine.HasXmppClient();
    912     Engine.SetRankedGame(g_GameAttributes.settings.RatingEnabled);
    913 
    914933    updateGUIObjects();
    915934}
    916935