Ticket #3551: t3551_prohibit_all_cheats_for_rated_games_v1.patch
File t3551_prohibit_all_cheats_for_rated_games_v1.patch, 3.4 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/simulation/components/Player.js
Player.prototype.Init = function() 35 35 this.startCam = undefined; 36 36 this.controlAllUnits = false; 37 37 this.isAI = false; 38 38 this.gatherRateMultiplier = 1; 39 39 this.cheatsEnabled = false; 40 this.ratingEnabled = false; 40 41 this.cheatTimeMultiplier = 1; 41 42 this.heroes = []; 42 43 this.resourceNames = { 43 44 "food": markForTranslation("Food"), 44 45 "wood": markForTranslation("Wood"), … … Player.prototype.SetCheatsEnabled = func 684 685 Player.prototype.GetCheatsEnabled = function() 685 686 { 686 687 return this.cheatsEnabled; 687 688 }; 688 689 690 Player.prototype.SetRatingEnabled = function(flag) 691 { 692 this.ratingEnabled = flag; 693 }; 694 695 Player.prototype.GetRatingEnabled = function() 696 { 697 return this.ratingEnabled; 698 }; 699 689 700 Player.prototype.SetCheatTimeMultiplier = function(time) 690 701 { 691 702 this.cheatTimeMultiplier = time; 692 703 }; 693 704 -
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 if (data.cmpPlayer.GetRatingEnabled()) 104 return; 105 103 106 data.cmpPlayer.SetControlAllUnits(cmd.flag); 104 107 }, 105 108 106 109 "reveal-map": function(player, cmd, data) 107 110 { 111 if (data.cmpPlayer.GetRatingEnabled()) 112 return; 113 108 114 // Reveal the map for all players, not just the current player, 109 115 // primarily to make it obvious to everyone that the player is cheating 110 116 var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 111 117 cmpRangeManager.SetLosRevealAll(-1, cmd.enable); 112 118 }, … … var commands = { 552 558 }); 553 559 }, 554 560 555 561 "promote": function(player, cmd, data) 556 562 { 557 // No need to do checks here since this is a cheat anyway 563 if (data.cmpPlayer.GetRatingEnabled()) 564 return; 565 558 566 var cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); 559 567 cmpGuiInterface.PushNotification({"type": "chat", "players": [player], "message": "(Cheat - promoted units)"}); 560 568 561 569 for each (var ent in cmd.entities) 562 570 { -
binaries/data/mods/public/simulation/helpers/InitGame.js
function InitGame(settings) 45 45 let cmpAIManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AIManager); 46 46 for (let i = 1; i < settings.PlayerData.length; ++i) 47 47 { 48 48 let cmpPlayer = Engine.QueryInterface(cmpPlayerManager.GetPlayerByID(i), IID_Player); 49 49 cmpPlayer.SetCheatsEnabled(!!settings.CheatsEnabled); 50 cmpPlayer.SetRatingEnabled(!!settings.RatingEnabled); 50 51 if (settings.PlayerData[i] && settings.PlayerData[i].AI && settings.PlayerData[i].AI != "") 51 52 { 52 53 cmpAIManager.AddPlayer(settings.PlayerData[i].AI, i, +settings.PlayerData[i].AIDiff); 53 54 cmpPlayer.SetAI(true); 54 55 // Sandbox: 50%, very easy: 50%, easy: 66%, Medium: 100%, hard: 133%, very hard: 166%