Ticket #3883: persist_match_settings_v7.patch

File persist_match_settings_v7.patch, 1.8 KB (added by Imarok, 8 years ago)
  • binaries/data/mods/public/gui/gamesetup/gamesetup.js

     
    868868    if (Engine.ConfigDB_GetValue("user", "persistmatchsettings") != "true")
    869869        return;
    870870
     871    // Load file
    871872    let settingsFile = g_IsNetworked ? g_MatchSettings_MP : g_MatchSettings_SP;
    872873    if (!Engine.FileExists(settingsFile))
    873874        return;
     
    878879
    879880    g_IsInGuiUpdate = true;
    880881
     882    // Find which settings can be changed by the user
     883    let allowedSettings = ["PlayerData"];
     884
     885    if (attrs.mapType == "skirmish" || attrs.mapType == "random")
     886        allowedSettings = allowedSettings.concat(
     887        [
     888            "GameType",
     889            "WonderDuration",
     890            "PopulationCap",
     891            "Ceasefire",
     892            "StartingResources",
     893            "RevealMap",
     894            "LockTeams",
     895            "ExploreMap",
     896            "DisableTreasures"
     897        ]);
     898
     899    if (attrs.mapType == "random")
     900        allowedSettings.push("Size");
     901
     902    if (g_IsNetworked)
     903        allowedSettings.push("CheatsEnabled");
     904
     905    if (Engine.HasXmppClient())
     906        allowedSettings.push("RatingEnabled");
     907
     908    // Only load settings which can be changed by the user
     909    for (let prop in attrs.settings)
     910        if (!(prop in allowedSettings))
     911            delete attrs.settings[prop];
     912
     913        if (attrs.settings.RatingEnabled)
     914            attrs.settings.CheatsEnabled = false;
     915        else
     916            attrs.settings.RatingEnabled = false;
     917
     918    // Restore valid matchsettings
    881919    let mapName = attrs.map || "";
    882920    let mapSettings = attrs.settings;
    883921
     
    913951    // Reload, as the maptype or mapfilter might have changed
    914952    initMapNameList();
    915953
    916     g_GameAttributes.settings.RatingEnabled = Engine.HasXmppClient();
    917954    Engine.SetRankedGame(g_GameAttributes.settings.RatingEnabled);
    918955
    919956    updateGUIObjects();