#3187 closed defect (fixed)
[PATCH] setup-trade-route - undefined property cmd.source
Reported by: | elexis | Owned by: | leper |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 19 |
Component: | UI & Simulation | Keywords: | patch |
Cc: | Patch: |
Description
In an a18 match this error occured:
Turn 2099 (500)... WARNING: JavaScript warning: simulation/helpers/Commands.js line 582 reference to undefined property cmd.source
The according code in Commands.js is:
"setup-trade-route": function(player, cmd, data) { GetFormationUnitAIs(data.entities, player).forEach(function(cmpUnitAI) { cmpUnitAI.SetupTradeRoute(cmd.target, cmd.source, cmd.route, cmd.queued); }); },
Error reproducable with the attached commands.txt.
Maybe my ally setup a trade route while my market was not completely built yet.
Attachments (4)
Change History (11)
by , 9 years ago
Attachment: | t3187_commands.txt_replaylog.7z added |
---|
comment:1 by , 9 years ago
by , 9 years ago
Attachment: | commands.txt added |
---|
Alternative commands.txt with same error. Almost there...
comment:2 by , 9 years ago
I can reproduce the error in a18 and svn by following those steps:
-make market with both players -make a trade cart with one player -select the cart and right click the market of the other player
Strangely enough the error doesn't appear ingame, but it appears when replaying the commands.txt afterwards. Not sure why the error was displayed in the original game.
comment:3 by , 9 years ago
Milestone: | Backlog → Alpha 19 |
---|---|
Summary: | setup-trade-route - undefined property cmd.source → [PATCH] setup-trade-route - undefined property cmd.source |
by , 9 years ago
Attachment: | t3187_fix_undefined_property_traderoute.patch added |
---|
comment:4 by , 9 years ago
As it turns out, the error only appears when replaying the commands.txt, but not ingame. That is because the cmd.source property of the setup-trade-route command will not be saved to commands.txt if the value is undefined. So I simply changed it to null. The same has to be done to the route property.
I tested the patch with the most recent svn version (16564) and setting up a trade route still works and the error disappeared when replaying the commands.txt.
The patch should work in theory too, because the only place where the source property is checked is in Trader.js in Trader.prototype.SetTargetMarket:
if (source)
and this should have the same result for null as for undefined.
comment:5 by , 9 years ago
Keywords: | patch review added |
---|
by , 9 years ago
Attachment: | t3187_fix_undefined_property_traderoute_trompetin17.patch added |
---|
Alternative patch by trompetin17. Tested and works too.
comment:7 by , 9 years ago
Component: | Core engine → UI & Simulation |
---|---|
Keywords: | review removed |
Thanks.
Player 1 and 2 were allied. Every player had only one market. Player 1 never had any trade carts. Player 2 only had those 2 trade carts that cause the error. No other commands refer to those markets and trade carts.
The entity ID of the market of player 1 is 5155 and the one of player 2 is 5246. The entity ID of the two trade carts of player 2 that caused the error are 5580 and 5637.
Chronological order of all events refering to those entities:
Player 1 started to build the market on turn 1405:
Player 2 started to build the market on turn 1654:
The market of player 1 was already built on turn 1738:
The market of player 2 was already built on turn 2011:
Player 2 stopped the trade speed increase upgrade research on turn 2013:
ERROR: Then player 2 sent his trade carts to the market of player 1 on turn 2099, which is the turn number on which the error occured:
After the error occured player 2 setup the trade route again on turn 2324, indicating that the traderoute setup really failed before: