Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#4131 closed defect (fixed)

[PATCH] SwitchMarketOrder error

Reported by: elexis Owned by: elexis
Priority: Should Have Milestone: Alpha 21
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description

This error occured when a player was defeated with r18581:

ERROR: JavaScript error: simulation/components/UnitAI.js line 5222
TypeError: this.order is undefined
  UnitAI.prototype.SwitchMarketOrder@simulation/components/UnitAI.js:5222:1
  Trader.prototype.SwitchMarket@simulation/components/Trader.js:260:3
  Mirage.prototype.UpdateTraders@simulation/components/Mirage.js:182:3
  Mirage.prototype.OnVisibilityChanged@simulation/components/Mirage.js:196:3

Not sure if it's that, but noone investigated this case yet as far as I know:

2016-06-03-QuakeNet-#0ad-dev.log:22:17 <@leper> another possible issue with that commit: what happens if one of the markets changes owner right before the trade is done?

Attachments (2)

commands.txt (1.5 MB ) - added by elexis 8 years ago.
Error occurs on turn 9015
ticket4131.patch (1.5 KB ) - added by mimo 8 years ago.

Download all attachments as: .zip

Change History (7)

by elexis, 8 years ago

Attachment: commands.txt added

Error occurs on turn 9015

by mimo, 8 years ago

Attachment: ticket4131.patch added

comment:1 by mimo, 8 years ago

Keywords: review added; mimo removed
Summary: SwitchMarketOrder error[PATCH] SwitchMarketOrder error

comment:2 by elexis, 8 years ago

  • How can we reproduce the bug? Was it related to that comment?

It's fully reproducible in the replay you provided. And no relation with the comment which imo is already taken into account. The problem is when changing ownership, UnitAI does a Stop which stops the trading route, but the route content in the Trader component was not reset (now done with the StopTrading). In addition, WorkOrders were not reset (now done).

  • Perhaps there could be some test that ensures that a trade cart has no more work orders after ownership change etc.?

Not needed after the patch.

  • This one hunk could become return this.MoveToPoint(point.x, point.z)) || this.MoveToMarket(targetMarket)

Yes, this should work too.

Last edited 8 years ago by mimo (previous) (diff)

comment:3 by mimo, 8 years ago

Sorry, I edited previous elexis post instead of replying to it :)

comment:4 by elexis, 8 years ago

Owner: set to elexis
Resolution: fixed
Status: newclosed

In 18749:

Fix a trade cart UnitAI error occuring rarely on defeat, by clearing the traderoute if the trader changed ownership. Patch by mimo, fixes #4131.

Also simplify MoveToMarket.

comment:5 by elexis, 8 years ago

Keywords: patch added; review removed

Thanks for the patch mimo! Sorry that we couldn't get to review this sooner.

Note: See TracTickets for help on using tickets.