Ticket #3551: t3551_prohibit_all_cheats_for_rated_games_v2.patch
File t3551_prohibit_all_cheats_for_rated_games_v2.patch, 3.9 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/simulation/components/GuiInterface.js
GuiInterface.prototype.Init = function() 25 25 { 26 26 this.placementEntity = undefined; // = undefined or [templateName, entityID] 27 27 this.placementWallEntities = undefined; 28 28 this.placementWallLastAngle = 0; 29 29 this.notifications = []; 30 this.ratingEnabled = false; 30 31 this.renamedEntities = []; 31 32 this.miragedEntities = []; 32 33 this.timeNotificationID = 1; 33 34 this.timeNotifications = []; 34 35 this.entsRallyPointsDisplayed = []; … … GuiInterface.prototype.GetSimulationStat 157 158 } 158 159 159 160 return ret; 160 161 }; 161 162 163 GuiInterface.prototype.IsRatedGame = function() 164 { 165 return this.ratingEnabled; 166 } 167 168 GuiInterface.prototype.SetRatedGame = function(enabled) 169 { 170 this.ratingEnabled = enabled; 171 } 172 162 173 /** 163 174 * Returns global information about the current game state, plus statistics. 164 175 * This is used by the GUI at the end of a game, in the summary screen. 165 176 * Note: Amongst statistics, the team exploration map percentage is computed from 166 177 * scratch, so the extended simulation state should not be requested too often. -
binaries/data/mods/public/simulation/helpers/Commands.js
var commands = { 98 98 data.cmpPlayer.TributeResource(cmd.player, cmd.amounts); 99 99 }, 100 100 101 101 "control-all": function(player, cmd, data) 102 102 { 103 var cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); 104 if (cmpGuiInterface.IsRatedGame()) 105 return; 106 103 107 data.cmpPlayer.SetControlAllUnits(cmd.flag); 104 108 }, 105 109 106 110 "reveal-map": function(player, cmd, data) 107 111 { 112 var cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); 113 if (cmpGuiInterface.IsRatedGame()) 114 return; 115 108 116 // Reveal the map for all players, not just the current player, 109 117 // primarily to make it obvious to everyone that the player is cheating 110 118 var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 111 119 cmpRangeManager.SetLosRevealAll(-1, cmd.enable); 112 120 }, … … var commands = { 552 560 }); 553 561 }, 554 562 555 563 "promote": function(player, cmd, data) 556 564 { 557 // No need to do checks here since this is a cheat anyway558 565 var cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); 566 if (cmpGuiInterface.IsRatedGame()) 567 return; 568 559 569 cmpGuiInterface.PushNotification({"type": "chat", "players": [player], "message": "(Cheat - promoted units)"}); 560 570 561 571 for each (var ent in cmd.entities) 562 572 { 563 573 var cmpPromotion = Engine.QueryInterface(ent, IID_Promotion); -
binaries/data/mods/public/simulation/helpers/InitGame.js
function InitGame(settings) 39 39 let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 40 40 for (let i = 1; i < settings.PlayerData.length; ++i) 41 41 cmpRangeManager.ExploreAllTiles(i); 42 42 } 43 43 44 // TODO: cheats should also be saved in the GuiInterface instead of the Player component 45 let cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); 46 cmpGuiInterface.SetRatedGame(settings.RatingEnabled); 47 44 48 let cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 45 49 let cmpAIManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AIManager); 46 50 for (let i = 1; i < settings.PlayerData.length; ++i) 47 51 { 48 52 let cmpPlayer = Engine.QueryInterface(cmpPlayerManager.GetPlayerByID(i), IID_Player);