Ticket #3883: persist_match_settings_v5.patch

File persist_match_settings_v5.patch, 1.4 KB (added by Imarok, 8 years ago)
  • 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" || attrs.mapType == "random")
     879        allowedSettings = allowedSettings.concat(
     880        [
     881            "GameType",
     882            "VictoryScripts",
     883            "WonderDuration",
     884            "PopulationCap",
     885            "Ceasefire",
     886            "StartingResources",
     887            "RevealMap",
     888            "LockTeams",
     889            "ExploreMap",
     890            "DisableTreasures"
     891        ]);
     892
     893    if (attrs.mapType == "random")
     894        allowedSettings.push("Size");
     895
     896    if (g_IsNetworked)
     897        allowedSettings.push("CheatsEnabled");
     898
     899    if (Engine.HasXmppClient())
     900        allowedSettings.push("RatingEnabled");
     901
     902    // Only load settings which can be changed by the user
     903    for (let prop in attrs.settings)
     904        if (!(prop in allowedSettings))
     905            delete attrs.settings[prop];
     906
     907    // Restore valid matchsettings
    874908    g_IsInGuiUpdate = true;
    875909