Ticket #3545: 3545.2.diff

File 3545.2.diff, 1.0 KB (added by Stan, 9 years ago)

Updated.

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

     
     1/**
     2 * This function performs different simulation commands such as adding resources, spawning units
     3 * modifying max population etc.
     4 */
    15function Cheat(input)
    26{
    37    var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
     
    7276            cmpGuiInterface.PushNotification({"type": "notification", "players": [input.player], "message": "You need to select a building that trains units."});
    7377            return;
    7478        }
    75         for (let i = 0; i < input.parameter; ++i)
     79   
     80        for (let i = 0; i < Math.Min(input.parameter, cmpPlayer.GetMaxPopulation() - cmpPlayer.GetPopulationCount()); ++i)
    7681            cmpProductionQueue.SpawnUnits(input.templates[i % input.templates.length], 1, null);
    7782        break;
    7883    case "fastactions":