Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3430 closed defect (fixed)

[PATCH] UnitAI - undefined property this.order.data.type while gathering

Reported by: Kieran P Owned by: Itms
Priority: Must Have Milestone: Alpha 19
Component: UI & Simulation Keywords:
Cc: Patch:

Description

These errors got repeated hundreds of times.

WARNING: JavaScript warning: simulation/components/UnitAI.js line 2218
reference to undefined property this.order.data.type
ERROR: JavaScript error: simulation/components/UnitAI.js line 2218
TypeError: this.order.data.type is undefined
  UnitAI.prototype.UnitFsmSpec.INDIVIDUAL.GATHER.GATHERING.enter@simulation/components/UnitAI.js:2218:11
  FSM.prototype.SwitchToNextState@simulation/helpers/FSM.js:376:1
  FSM.prototype.ProcessMessage@simulation/helpers/FSM.js:284:4
  UnitAI.prototype.OnMotionChanged@simulation/components/UnitAI.js:3840:63
ERROR: Script message handler OnMotionChanged failed
ERROR: Error in timer on entity 7325, IID 89, function TimerHandler: TypeError: resourceType is undefined
  UnitAI.prototype.UnitFsmSpec.INDIVIDUAL.GATHER.GATHERING.Timer@simulation/components/UnitAI.js:2262:1
  FSM.prototype.ProcessMessage@simulation/helpers/FSM.js:274:29
  UnitAI.prototype.TimerHandler@simulation/components/UnitAI.js:3798:68
  Timer.prototype.OnUpdate@simulation/components/Timer.js:100:4

Attachments (3)

commands.txt (6.6 KB ) - added by mimo 9 years ago.
I reproduced the error with this commands.txt. Notice that about 30 turns before the error, there is a warning issued "WARNING: unexpected PathResult (5439 3 3)"
ticket3430.patch (1.3 KB ) - added by mimo 9 years ago.
ticket3430-v2.patch (2.9 KB ) - added by mimo 9 years ago.
yes, i forgot to upload my current more complete patch, fixing that warning and another undef which may arise in the AI.

Download all attachments as: .zip

Change History (17)

comment:1 by elexis, 9 years ago

Summary: JS Errors during AI autoplayUniAI - undefined property this.order.data.type while gathering

Can you provide the commands.txt file where that error occured? Which version did you use?

comment:2 by Itms, 9 years ago

Owner: changed from ltms to Itms

Almost missed this one!

comment:3 by Stan, 9 years ago

Summary: UniAI - undefined property this.order.data.type while gatheringUnitAI - undefined property this.order.data.type while gathering

by mimo, 9 years ago

Attachment: commands.txt added

I reproduced the error with this commands.txt. Notice that about 30 turns before the error, there is a warning issued "WARNING: unexpected PathResult (5439 3 3)"

comment:4 by bb, 9 years ago

@ mimo: you sure that is the correct commands.txt? It seems "empty" to me.

By looking at the code it seems logical this crash occurs, because this.order.data.type.specific is never allocated. This crash should occur when the check above is true, could not reproduce that.

Last edited 9 years ago by bb (previous) (diff)

comment:5 by mimo, 9 years ago

Yes sure. It is an autostart with 4 AI, so all commands are generated by the AI.

this.order.data.type should be allocated in PerformGather for a true Gather order. But here, we enter in the gathering state with an Attack order !!! which should never happen.

in reply to:  5 comment:6 by bb, 9 years ago

Replying to mimo:

this.order.data.type should be allocated in PerformGather for a true Gather order. But here, we enter in the gathering state with an Attack order !!! which should never happen.

Found what is going wrong in the game: on this map player 3 (green normaly) starts of with a boar (animal with attack, not domestic) near it's cc. When he has a cav skirm he tries to attack that animal. So far no problems. But what happens then is that the cav walks all the way to the boar (like is normal for domestic animals) and then attacks, not like trowing spears from a distance (this triggers the warning "unexpected path result").

Then when the animal is dead we get all the errors, because the cav tries to gather state with an attack order.

The errors end when gatherring is done and the time between warning and errors is the killing time.

This should have something to do with the changes in the AI/pathfinding, wich allowed the AI (not on purpose) to attack not domestic animals, like domestic animals.

comment:7 by mimo, 9 years ago

I had a look at it, and in fact it is a UnitAI problem, not a pathFinder one. The origin of it is that, when a unit finishes an order and has no other order, FinishOrder set it to IDLE. But this setting does not mean the state is switched to IDLE, this will only be done at the first message processed. In this case, after being set to IDLE, the unit is reordered to gather, and it is only when it starts to move (giving a MoveStarted message) that it is effectively switched to IDLE. And this makes it in a weird state: switching to IDLE (which means attacking nearby dangerous animals like the boar) while it has just started to move to gather chicken.

comment:8 by mimo, 9 years ago

Keywords: review added
Summary: UnitAI - undefined property this.order.data.type while gathering[PATCH] UnitAI - undefined property this.order.data.type while gathering

by mimo, 9 years ago

Attachment: ticket3430.patch added

comment:9 by Stan, 9 years ago

Above patch fixes the warnings.

I still got this error : Maybe it's not related at all

<p class="warning">WARNING: JavaScript warning: simulation/components/UnitAI.js line 2039 Script value conversion check failed: v.isNumber() (got type undefined)</p>

by mimo, 9 years ago

Attachment: ticket3430-v2.patch added

yes, i forgot to upload my current more complete patch, fixing that warning and another undef which may arise in the AI.

comment:10 by Stan, 9 years ago

That's fixed for me. No more warnings/errors.

comment:11 by mimo, 9 years ago

Resolution: fixed
Status: newclosed

In 17079:

fix some flaws revealed by the fix #3430

comment:12 by mimo, 9 years ago

Resolution: fixed
Status: closedreopened

As the fix itself was not commited (I only commited the fixes for the flaws revealed by the fix), this ticket should not have been closed. So reopen it.

comment:13 by mimo, 9 years ago

Resolution: fixed
Status: reopenedclosed

In 17086:

change immediately to IDLE state when no more orders, fixes #3430

comment:14 by mimo, 9 years ago

Keywords: review removed
Note: See TracTickets for help on using tickets.