1
0
forked from 0ad/0ad

Fix batch not stopped when using the spawn cheat.

Reported and tested by @Langbart.
Differential revision: https://code.wildfiregames.com/D4939
Fixes #6739

This was SVN commit r27549.
This commit is contained in:
Freagarach 2023-02-17 13:31:51 +00:00
parent f7193ed595
commit 189fc18251
2 changed files with 11 additions and 2 deletions

View File

@ -199,6 +199,14 @@ Trainer.prototype.Item.prototype.Finish = function()
this.finished = true;
};
/**
* @return {boolean} -
*/
Trainer.prototype.Item.prototype.IsFinished = function()
{
return !!this.finished;
};
/*
* This function creates the entities and places them in world if possible
* (some of these entities may be garrisoned directly if autogarrison, the others are spawned).
@ -682,7 +690,7 @@ Trainer.prototype.Progress = function(id, allocatedTime)
{
const item = this.queue.get(id);
const usedTime = item.Progress(allocatedTime);
if (item.finished)
if (item.IsFinished())
this.queue.delete(id);
return usedTime;
};

View File

@ -83,7 +83,8 @@ function Cheat(input)
const batch = new cmpTrainer.Item(input.templates[i % input.templates.length], 1, input.selected[0], null);
batch.player = owner;
batch.Finish();
// ToDo: If not able to spawn, cancel the batch.
if (!batch.IsFinished())
batch.Stop();
}
return;
}