Opened 12 years ago

Closed 12 years ago

#1599 closed defect (fixed)

FinishOrder called when order queue is empty

Reported by: historic_bruno Owned by:
Priority: Should Have Milestone: Alpha 11
Component: UI & Simulation Keywords:
Cc: Patch:

Description

Getting a few of these errors in multiplayer matches, I haven't looked into why they might be occurring.

Change History (6)

comment:1 by Erik Johansson, 12 years ago

Iirc those errors appear when a building is destroyed which has units being built in it. I could be wrong though :)

comment:2 by rjs23, 12 years ago

This happened on a farm with unit gathering it.  Farm was destroyed by a seige and then error comes up saying FinishOrder warnings. It only happened once to me.  I'll try to reproduce it again next time to confirm that destroying farm with unit gathering causes the errors to come up.

comment:3 by Deiz, 12 years ago

Fiddled around with various combinations of siege units and farmers to no avail.

Even though this is a minor issue, I'd like to get it nailed down before release. Seems difficult to reproduce, at any rate.

comment:4 by Deiz, 12 years ago

Managed to hit the issue with the recent increased-verbosity changes in place:

ERROR: FinishOrder called for entity 8674 (units/mace_mechanical_siege_ram) when order queue is empty
  ()@simulation/components/UnitAI.js:2020
  ([object Object])@simulation/components/UnitAI.js:626
  ([object Object],[object Object])@simulation/helpers/FSM.js:274
  (0)@simulation/components/UnitAI.js:2760
  ()@simulation/components/Formation.js:101
  ([object Object])@simulation/components/UnitAI.js:524
  ([object Object],[object Object])@simulation/helpers/FSM.js:274
  ("Attack",[object Object])@simulation/components/UnitAI.js:2068
  ("Attack",[object Object])@simulation/components/UnitAI.js:2129
  ("Attack",[object Object],false)@simulation/components/UnitAI.js:2855
  (6531,false)@simulation/components/UnitAI.js:2913
  ([object Object],0,[object Array])@simulation/helpers/Commands.js:78
  ProcessCommand(1,[object Object])@simulation/helpers/Commands.js:77

I've spent a few minutes looking at it, and I haven't yet figured it out. This particular code path seems to correspond to the formation controller receiving an attack order, triggering a disband, leading to the FormationLeave message being processed and FinishOrder being called.

Here's where it gets weird, though: In my testing just now, when you make a formation attack, the units are already in INDIVIDUAL.COMBAT.APPROACHING by the time the FormationLeave message is sent, which means the message is ignored. The real error, though, has the unit still in the formation at that time.

comment:5 by Deiz, 12 years ago

Okay, well... I've solved the issue. I'm still not 100% on the circumstances under which it occurs.

Right before disbanding the formation, UnitAI calls the Attack function for each entity. For this particular edge case to be hit, the attack needs to seem possible to attack (target exists and isn't a non-attackable type, etc.).

It's when it gets into Order.Attack that things get messy. The attack order isn't queued, so it clobbers the order queue. Order.Attack then fails for some reason (the target is dead, or is no longer attackable, etc.), finishes itself, and the state is left as FORMATIONMEMBER.IDLE.

Then the whole formation is disbanded, the FormationLeave message is processed inside FORMATIONMEMBER, and the bug appears, because the IDLE state is only hit when there are no orders left.

comment:6 by Deiz, 12 years ago

Resolution: fixed
Status: newclosed

Fixed in r12548.

Note: See TracTickets for help on using tickets.