mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 22:06:33 +00:00
Add AI safety guard. I had a game with an undefined template, but that shouldn't happen at that point.
This was SVN commit r16535.
This commit is contained in:
@@ -124,11 +124,20 @@ m.TrainingPlan.prototype.promotedTypes = function(gameState)
|
||||
var types = [];
|
||||
var promotion = this.template.promotion();
|
||||
var previous;
|
||||
var template;
|
||||
while (promotion)
|
||||
{
|
||||
types.push(promotion);
|
||||
previous = promotion;
|
||||
promotion = gameState.getTemplate(promotion).promotion();
|
||||
template = gameState.getTemplate(promotion);
|
||||
if (!template)
|
||||
{
|
||||
if (gameState.ai.Config.debug > 0)
|
||||
API3.warn(" promotion template " + promotion + " is not found");
|
||||
promotion = undefined;
|
||||
break;
|
||||
}
|
||||
promotion = template.promotion();
|
||||
if (previous === promotion)
|
||||
{
|
||||
if (gameState.ai.Config.debug > 0)
|
||||
|
||||
Reference in New Issue
Block a user