Ticket #3209: t3209_keep_victory_condition.patch
File t3209_keep_victory_condition.patch, 3.8 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/gui/gamesetup/gamesetup.js
387 387 Engine.GetGUIObjectByName("mapSelection").focus(); 388 388 } 389 389 390 390 if (g_IsController) 391 391 { 392 load GameAttributes();392 loadPersistMatchSettings(); 393 393 // Sync g_GameAttributes to everyone. 394 394 if (g_IsInGuiUpdate) 395 395 warn("initMain() called while in GUI update"); 396 396 397 397 updateGameAttributes(); … … 674 674 return g_MapData[name]; 675 675 } 676 676 677 677 const FILEPATH_MATCHSETTINGS_SP = "config/matchsettings.json"; 678 678 const FILEPATH_MATCHSETTINGS_MP = "config/matchsettings.mp.json"; 679 function load GameAttributes()679 function loadPersistMatchSettings() 680 680 { 681 681 if (Engine.ConfigDB_GetValue("user", "persistmatchsettings") != "true") 682 682 return; 683 683 684 684 var settingsFile = g_IsNetworked ? FILEPATH_MATCHSETTINGS_MP : FILEPATH_MATCHSETTINGS_SP; … … 718 718 { 719 719 if (civListCodes.indexOf(playerData[i].Civ) < 0) 720 720 playerData[i].Civ = "random"; 721 721 } 722 722 } 723 724 723 // Refresh probably obsoleted/incomplete map data. 725 724 var newMapData = loadMapData(mapName); 726 725 if (newMapData && newMapData.settings) 727 726 { 728 727 for (var prop in newMapData.settings) … … 742 741 initMapNameList(); 743 742 744 743 var mapSelectionBox = Engine.GetGUIObjectByName("mapSelection"); 745 744 mapSelectionBox.selected = mapSelectionBox.list_data.indexOf(mapName); 746 745 746 if (attrs.gameSpeed) 747 { 748 var gameSpeedBox = Engine.GetGUIObjectByName("gameSpeed"); 749 gameSpeedBox.selected = g_GameSpeeds.speeds.indexOf(attrs.gameSpeed); 750 } 751 if (mapSettings.GameType) 752 { 753 var victoryConditions = Engine.GetGUIObjectByName("victoryCondition"); 754 var victories = getVictoryConditions(); 755 victoryConditions.selected = victories.data.indexOf(mapSettings.GameType); 756 } 747 757 if (mapSettings.PopulationCap) 748 758 { 749 759 var populationCapBox = Engine.GetGUIObjectByName("populationCap"); 750 760 populationCapBox.selected = populationCapBox.list_data.indexOf(mapSettings.PopulationCap); 751 761 } 752 762 if (mapSettings.StartingResources) 753 763 { 754 764 var startingResourcesBox = Engine.GetGUIObjectByName("startingResources"); 755 765 startingResourcesBox.selected = startingResourcesBox.list_data.indexOf(mapSettings.StartingResources); 756 766 } 757 758 767 if (mapSettings.Ceasefire) 759 768 { 760 769 var ceasefireBox = Engine.GetGUIObjectByName("ceasefire"); 761 770 ceasefireBox.selected = ceasefireBox.list_data.indexOf(mapSettings.Ceasefire); 762 771 } 763 764 if (attrs.gameSpeed)765 {766 var gameSpeedBox = Engine.GetGUIObjectByName("gameSpeed");767 gameSpeedBox.selected = g_GameSpeeds.speeds.indexOf(attrs.gameSpeed);768 }769 770 772 if (!Engine.HasXmppClient()) 771 773 { 772 774 g_GameAttributes.settings.RatingEnabled = false; 773 775 Engine.SetRankedGame(false); 774 776 Engine.GetGUIObjectByName("enableRating").checked = false; 775 777 Engine.GetGUIObjectByName("enableCheats").enabled = true; 776 778 Engine.GetGUIObjectByName("lockTeams").enabled = true; 777 779 } 778 779 780 g_IsInGuiUpdate = false; 780 781 781 782 onGameAttributesChange(); 782 783 } 783 784 … … 975 976 g_GameAttributes.settings[prop] = undefined; 976 977 977 978 var mapData = loadMapData(name); 978 979 var mapSettings = (mapData && mapData.settings ? deepcopy(mapData.settings) : {}); 979 980 980 // Reset victory conditions981 var victories = getVictoryConditions();982 var victoryIdx = (mapSettings.GameType !== undefined && victories.data.indexOf(mapSettings.GameType) != -1 ? victories.data.indexOf(mapSettings.GameType) : VICTORY_DEFAULTIDX);983 g_GameAttributes.settings.GameType = victories.data[victoryIdx];984 g_GameAttributes.settings.VictoryScripts = victories.scripts[victoryIdx];985 986 981 // Copy any new settings 987 982 g_GameAttributes.map = name; 988 983 g_GameAttributes.script = mapSettings.Script; 989 984 if (g_GameAttributes.map !== "random") 990 985 for (var prop in mapSettings)