Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3418 closed defect (fixed)

AI Defense Manager - army is undefined

Reported by: silure Owned by: mimo
Priority: Must Have Milestone: Alpha 19
Component: AI Keywords:
Cc: Patch:

Description (last modified by elexis)

Hello,

Getting this error on some maps, this also causes a huge slowdown past some time (r17021).

ERROR: JavaScript error: simulation/ai/petra/defenseManager.js line 401
TypeError: army is undefined
  m.DefenseManager.prototype.checkEvents@simulation/ai/petra/defenseManager.js:401:1
  m.DefenseManager.prototype.update@simulation/ai/petra/defenseManager.js:18:2
  m.HQ.prototype.update@simulation/ai/petra/headquarters.js:2039:2
  m.PetraBot.prototype.OnUpdate@simulation/ai/petra/_petrabot.js:123:3
  m.BaseAI.prototype.HandleMessage@simulation/ai/common-api/baseAI.js:81:2

Change History (3)

comment:1 by elexis, 9 years ago

Description: modified (diff)
Keywords: army undefined removed
Milestone: Alpha 19Backlog
Summary: TypeError: army is undefinedAI Defense Manager - army is undefined

The error occcurs in the second line:

   let army = this.getArmy(target.getMetadata(PlayerID, "PartOfArmy"));
   if (army.isCapturing(gameState))
   ...

m.DefenseManager.prototype.getArmy = function(partOfArmy)
{
	// Find the army corresponding to this ID partOfArmy
	for (let army of this.armies)
		if (army.ID === partOfArmy)
		    return army;

	return undefined;
};

That's probably easy to fix, only a missing check. But if you have a commands.txt file at hand where that error happens, that would help too.

comment:2 by mimo, 9 years ago

Owner: set to mimo
Resolution: fixed
Status: newclosed

In 17023:

petra: improve detection of threatening enemy units, complete and fix r17016, fixes #3418

comment:3 by mimo, 9 years ago

Milestone: BacklogAlpha 19

Thanks for the report. I have been able to reproduce it, but that's not always possible and, as said by elexis, don't forget to provide the commands.txt file when reporting such bugs.

Note: See TracTickets for help on using tickets.