Ticket #3551: t3551_prohibit_all_cheats_when_cheats_are_disabled_v2.patch

File t3551_prohibit_all_cheats_when_cheats_are_disabled_v2.patch, 1.6 KB (added by elexis, 9 years ago)

Alternative. Only allows developer-overlay cheats when the cheats-setting is enabled. Would be coherent with the current state of #2676 (r17170).

  • binaries/data/mods/public/simulation/helpers/Commands.js

    var commands = {  
    9898        data.cmpPlayer.TributeResource(cmd.player, cmd.amounts);
    9999    },
    100100
    101101    "control-all": function(player, cmd, data)
    102102    {
     103        var cmpPlayer = Engine.QueryInterface(data.playerEnt, IID_Player);
     104        if (!cmpPlayer.GetCheatsEnabled())
     105            return;
     106
    103107        data.cmpPlayer.SetControlAllUnits(cmd.flag);
    104108    },
    105109
    106110    "reveal-map": function(player, cmd, data)
    107111    {
     112        var cmpPlayer = Engine.QueryInterface(data.playerEnt, IID_Player);
     113        if (!cmpPlayer.GetCheatsEnabled())
     114            return;
     115
    108116        // Reveal the map for all players, not just the current player,
    109117        // primarily to make it obvious to everyone that the player is cheating
    110118        var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
    111119        cmpRangeManager.SetLosRevealAll(-1, cmd.enable);
    112120    },
    var commands = {  
    552560        });
    553561    },
    554562
    555563    "promote": function(player, cmd, data)
    556564    {
    557         // No need to do checks here since this is a cheat anyway
     565        var cmpPlayer = Engine.QueryInterface(data.playerEnt, IID_Player);
     566        if (!cmpPlayer.GetCheatsEnabled())
     567            return;
     568
    558569        var cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
    559570        cmpGuiInterface.PushNotification({"type": "chat", "players": [player], "message": "(Cheat - promoted units)"});
    560571
    561572        for each (var ent in cmd.entities)
    562573        {