Ticket #3883: persist_match_settings_v8.patch

File persist_match_settings_v8.patch, 1.8 KB (added by Imarok, 8 years ago)

Removed an else and added the ugly !! ;)

  • 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
     916    // Restore valid matchsettings
    881917    let mapName = attrs.map || "";
    882918    let mapSettings = attrs.settings;
    883919
     
    913949    // Reload, as the maptype or mapfilter might have changed
    914950    initMapNameList();
    915951
    916     g_GameAttributes.settings.RatingEnabled = Engine.HasXmppClient();
    917     Engine.SetRankedGame(g_GameAttributes.settings.RatingEnabled);
     952    Engine.SetRankedGame(!!g_GameAttributes.settings.RatingEnabled);
    918953
    919954    updateGUIObjects();
    920955}