Page MenuHomeWildfire Games

Stop relying on the internal structure of the current Trader component.
ClosedPublic

Authored by leper on Feb 24 2017, 5:01 PM.
Tags
None
Referenced Files
F5167368: D161.id601.diff
Sat, Sep 7, 1:17 PM
Unknown Object (File)
Thu, Sep 5, 2:50 AM
Unknown Object (File)
Wed, Sep 4, 7:00 PM
Unknown Object (File)
May 4 2017, 2:27 AM
Unknown Object (File)
Apr 17 2017, 9:20 AM
Unknown Object (File)
Mar 21 2017, 8:03 AM
Unknown Object (File)
Mar 14 2017, 5:13 AM
Unknown Object (File)
Mar 14 2017, 4:18 AM
Subscribers
Tokens
"Like" token, awarded by elexis.

Details

Summary

Get the required information by returning it in the proper places.
Also clean up some pointless modulo operations.


This is pulled out of the Silk Road code (#4314), this part is independent of everything else and related to some patch you merged/finished quite some time ago.

The remaining WIP code there goes quite some of the way for actually implementing trade routes (#1207 and #3872), but ignores the whole GUI issue. It also does not (yet?) consider routes/waypoints at all.

Test Plan

Make sure it does the same, that is open up the trade demo map and trade a bit. (Should work fine, but I haven't actually tested this diff apart from porting it over and having tested that quite some time ago.

Diff Detail

Repository
rP 0 A.D. Public Repository
Branch
trader_information_hiding
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 589
Build 932: Vulcan BuildJenkins
Build 931: arc lint + arc unit

Event Timeline

shookees added inline comments.
binaries/data/mods/public/simulation/components/Trader.js
218

why does PerformTrade return nextMarket?

binaries/data/mods/public/simulation/components/Trader.js
218

Because we need to return it in order to get it in UnitAI's PerformTradeAndMoveToNextMarket. Sure we could add a getter, but that would just result in strange edge cases when called at some points in time.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (302 tests)..............................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (302 tests)..............................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/400/ for more details.

Looks good to me, and works fine.

binaries/data/mods/public/simulation/components/UnitAI.js
5362

as PerformTrade can return INVALID_ENTITY, we should test on it here
(the test on !amount is not enough as line 212 of Trader.js does not make it null).

binaries/data/mods/public/simulation/components/Trader.js
218

I understand that it might look more convenient by passing through that variable, but code readability wise that's a plain wtf

Check if we don't have a valid next market.

leper added inline comments.
binaries/data/mods/public/simulation/components/Trader.js
218

I don't really share that sentiment.

binaries/data/mods/public/simulation/components/UnitAI.js
5362

Good catch!

mimo added inline comments.
binaries/data/mods/public/simulation/components/Trader.js
218

I'm also fine with this.

This revision is now accepted and ready to land.Feb 24 2017, 10:42 PM
This revision was automatically updated to reflect the committed changes.
leper marked an inline comment as done.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (302 tests)..............................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (302 tests)..............................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/402/ for more details.