Page MenuHomeWildfire Games

Fix undefined property warning when bartering following D23
ClosedPublic

Authored by elexis on Jun 11 2017, 5:00 PM.

Details

Summary

As reported by fabio in #4629, when bartering the following warning occurs:

WARNING: JavaScript warning: gui/common/l10n.js line 12
reference to undefined property resources[type]

(The replay happens to reprodue this GUI issue, but that shouldn't matter.)

if (x.y) does not throw an error whereas filter(x => x.y) does (if y is not a property of x).

So we can use filter(x => x.y ? true : false), filter(x => !!x.y), filter(x => x.y || false) or use a for loop.

The resource trickle one would have the same issue in case the simulation doesn't enforce a rate for each resource anymore, so fixing that too would be better.

Test Plan

Run fabios replay and ensure there are no warnings before turn 3000.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

elexis created this revision.Jun 11 2017, 5:00 PM
Vulcan added a subscriber: Vulcan.Jun 11 2017, 5:48 PM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Checking XML files...

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

Executing section Default...
Executing section Source...
Executing section JS...

binaries/data/mods/public/gui/common/tooltips.js
| 565| »   »   '[/color][/font]'·+·"·"·+
|    | [NORMAL] ESLintBear (no-useless-concat):
|    | Unexpected string concatenation of literals.

binaries/data/mods/public/gui/common/tooltips.js
| 398| »   »   let·[rate,·count]·=·types.reduce((sum,·t)·=>·{
|    | [NORMAL] JSHintBear:
|    | Don't make functions within a loop.

binaries/data/mods/public/gui/common/tooltips.js
| 577| »   if·(walk·==·0·&&·run·==·0)
|    | [NORMAL] JSHintBear:
|    | Use '===' to compare with '0'.

binaries/data/mods/public/gui/common/tooltips.js
| 577| »   if·(walk·==·0·&&·run·==·0)
|    | [NORMAL] JSHintBear:
|    | Use '===' to compare with '0'.
Executing section XML GUI...
Executing section Python...
Executing section Perl...

http://jw:8080/job/phabricator_lint/175/ for more details.

s0600204 accepted this revision.Jun 12 2017, 4:31 PM

Patch makes logical sense, and running the entirety of the replay results in no warnings.

This revision is now accepted and ready to land.Jun 12 2017, 4:31 PM
This revision was automatically updated to reflect the committed changes.