Ticket #3551: t3551_prohibit_all_cheats_when_cheats_are_disabled_v3.patch

File t3551_prohibit_all_cheats_when_cheats_are_disabled_v3.patch, 2.3 KB (added by elexis, 4 years ago)

No more pointless calls and also updates the GUI in case we go with this of the two variants (disable only for rated games vs. disable in all non-cheated games).

  • binaries/data/mods/public/gui/session/menu.js

    function openManual() 
    681681    Engine.PushGuiPage("page_manual.xml", {"page": "manual/intro", "title":translate("Manual"), "url":"http://trac.wildfiregames.com/wiki/0adManual", "callback": "resumeGame"});
    682682}
    683683
    684684function toggleDeveloperOverlay()
    685685{
    686     // The developer overlay is disabled in ranked games
    687     if (Engine.HasXmppClient() && Engine.IsRankedGame())
     686    // The developer overlay is disabled when cheats are disabled
     687    if (g_IsObserver || !g_SimState.players[Engine.GetPlayerID()].cheatsEnabled)
    688688        return;
    689689
    690690    var devCommands = Engine.GetGUIObjectByName("devCommands");
    691691    if (devCommands.hidden)
    692692        submitChatDirectly(translate("The Developer Overlay was opened."));
  • binaries/data/mods/public/simulation/helpers/Commands.js

    var g_Commands = { 
    9898        data.cmpPlayer.TributeResource(cmd.player, cmd.amounts);
    9999    },
    100100
    101101    "control-all": function(player, cmd, data)
    102102    {
     103        if (!data.cmpPlayer.GetCheatsEnabled())
     104            return;
     105
    103106        data.cmpPlayer.SetControlAllUnits(cmd.flag);
    104107    },
    105108
    106109    "reveal-map": function(player, cmd, data)
    107110    {
     111        if (!data.cmpPlayer.GetCheatsEnabled())
     112            return;
     113
    108114        // Reveal the map for all players, not just the current player,
    109115        // primarily to make it obvious to everyone that the player is cheating
    110116        var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
    111117        cmpRangeManager.SetLosRevealAll(-1, cmd.enable);
    112118    },
    var g_Commands = { 
    552558        });
    553559    },
    554560
    555561    "promote": function(player, cmd, data)
    556562    {
    557         // No need to do checks here since this is a cheat anyway
     563        if (!data.cmpPlayer.GetCheatsEnabled())
     564            return;
     565
    558566        var cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
    559567        cmpGuiInterface.PushNotification({"type": "chat", "players": [player], "message": "(Cheat - promoted units)"});
    560568
    561569        for each (var ent in cmd.entities)
    562570        {