Ticket #3883: persist_match_settings_v9.patch
File persist_match_settings_v9.patch, 2.6 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/gamesetup/gamesetup.js
846 846 mapSelectionBox.selected = Math.max(0, mapListFiles.indexOf(g_GameAttributes.map || "")); 847 847 } 848 848 849 /** 850 * Removes every setting the user cannot change 851 */ 852 function cleanUpSettings(attrs) 853 { 854 // Find which settings can be changed by the user 855 let allowedSettings = ["PlayerData"]; 856 857 if (attrs.mapType == "skirmish" || attrs.mapType == "random") 858 allowedSettings = allowedSettings.concat( 859 [ 860 "GameType", 861 "WonderDuration", 862 "PopulationCap", 863 "Ceasefire", 864 "StartingResources", 865 "RevealMap", 866 "LockTeams", 867 "ExploreMap", 868 "DisableTreasures" 869 ]); 870 871 if (attrs.mapType == "random") 872 allowedSettings.push("Size"); 873 874 if (g_IsNetworked) 875 allowedSettings.push("CheatsEnabled"); 876 877 if (Engine.HasXmppClient()) 878 allowedSettings.push("RatingEnabled"); 879 880 // Only load settings which can be changed by the user 881 for (let prop in attrs.settings) 882 if (allowedSettings.indexOf(prop) == -1) 883 delete attrs.settings[prop]; 884 885 if (attrs.settings.RatingEnabled) 886 attrs.settings.CheatsEnabled = false; 887 } 888 849 889 function loadMapData(name) 850 890 { 851 891 if (!name || !g_MapPath[g_GameAttributes.mapType]) … … 868 908 if (Engine.ConfigDB_GetValue("user", "persistmatchsettings") != "true") 869 909 return; 870 910 911 // Load file 871 912 let settingsFile = g_IsNetworked ? g_MatchSettings_MP : g_MatchSettings_SP; 872 913 if (!Engine.FileExists(settingsFile)) 873 914 return; … … 878 919 879 920 g_IsInGuiUpdate = true; 880 921 922 cleanUpSettings(attrs); 923 924 // Restore valid matchsettings 881 925 let mapName = attrs.map || ""; 882 926 let mapSettings = attrs.settings; 883 927 … … 913 957 // Reload, as the maptype or mapfilter might have changed 914 958 initMapNameList(); 915 959 916 g_GameAttributes.settings.RatingEnabled = Engine.HasXmppClient(); 917 Engine.SetRankedGame(g_GameAttributes.settings.RatingEnabled); 960 Engine.SetRankedGame(!!g_GameAttributes.settings.RatingEnabled); 918 961 919 962 updateGUIObjects(); 920 963 } … … 1125 1168 if (g_IsInGuiUpdate || !g_IsController || !name) 1126 1169 return; 1127 1170 1128 // Reset some map specific properties which are not necessarily redefined on each map 1129 for (let prop of ["TriggerScripts", "CircularMap", "Garrison"]) 1130 g_GameAttributes.settings[prop] = undefined; 1171 cleanUpSettings(g_GameAttributes); 1131 1172 1132 1173 let mapData = loadMapData(name); 1133 1174 let mapSettings = mapData && mapData.settings ? deepcopy(mapData.settings) : {};