Prevent players from gaining unlimited resources by setting the batch-train-modifier to a non numeric value.
Differential Revision: https://code.wildfiregames.com/D66 Refs #4459 Reviewed By: fatherbushido (wraitii, leper) This was SVN commit r19826.
This commit is contained in:
parent
d7c4c20aa8
commit
2e3ac4cf20
@ -1332,6 +1332,12 @@ function addTrainingByPosition(position)
|
||||
return;
|
||||
}
|
||||
|
||||
function getBatchTrainingSize()
|
||||
{
|
||||
let num = +Engine.ConfigDB_GetValue("user", "gui.session.batchtrainingsize");
|
||||
return Number.isInteger(num) && num > 0 ? num : 5;
|
||||
}
|
||||
|
||||
// Called by GUI when user clicks training button
|
||||
function addTrainingToQueue(selection, trainEntType, playerState)
|
||||
{
|
||||
@ -1348,7 +1354,7 @@ function addTrainingToQueue(selection, trainEntType, playerState)
|
||||
if (!decrement)
|
||||
var template = GetTemplateData(trainEntType);
|
||||
|
||||
let batchIncrementSize = +Engine.ConfigDB_GetValue("user", "gui.session.batchtrainingsize");
|
||||
let batchIncrementSize = getBatchTrainingSize();
|
||||
|
||||
if (Engine.HotkeyIsPressed("session.batchtrain") && batchTrainingPossible)
|
||||
{
|
||||
@ -1431,7 +1437,7 @@ function addResearchToQueue(entity, researchType)
|
||||
*/
|
||||
function getTrainingStatus(playerState, trainEntType, selection)
|
||||
{
|
||||
let batchIncrementSize = +Engine.ConfigDB_GetValue("user", "gui.session.batchtrainingsize");
|
||||
let batchIncrementSize = getBatchTrainingSize();
|
||||
var appropriateBuildings = [];
|
||||
if (selection)
|
||||
appropriateBuildings = getBuildingsWhichCanTrainEntity(selection, trainEntType);
|
||||
|
@ -261,6 +261,12 @@ ProductionQueue.prototype.AddBatch = function(templateName, type, count, metadat
|
||||
|
||||
if (type == "unit")
|
||||
{
|
||||
if (!Number.isInteger(count) || count <= 0)
|
||||
{
|
||||
error("Invalid batch count " + count);
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the template data so we can determine the build costs
|
||||
var cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager);
|
||||
var template = cmpTemplateManager.GetTemplate(templateName);
|
||||
|
@ -260,6 +260,12 @@ var g_Commands = {
|
||||
|
||||
"train": function(player, cmd, data)
|
||||
{
|
||||
if (!Number.isInteger(cmd.count) || cmd.count <= 0)
|
||||
{
|
||||
warn("Invalid command: can't train " + uneval(cmd.count) + " units");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check entity limits
|
||||
var template = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager).GetTemplate(cmd.template);
|
||||
var unitCategory = null;
|
||||
|
Loading…
Reference in New Issue
Block a user