Page MenuHomeWildfire Games

Fix IsInjured call to mirages
ClosedPublic

Authored by wraitii on Jun 27 2019, 8:35 AM.

Details

Reviewers
None
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rP22411: Fix IsInjured call on miraged entities.
Summary

rP22298 introduced an "IsInjured" function, used in the GUIInterface.
Sadly, I did not realise that mirages actually needed a clone of this function, and missed the required change.

This ought to fix that.

I'm not sure if we can systematically test for such things?

Test Plan

Review changes, click on a mirages entity, notice there are no longer errors

Diff Detail

Repository
rP 0 A.D. Public Repository
Branch
temp
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 8109
Build 13198: Vulcan BuildJenkins
Build 13197: arc lint + arc unit

Event Timeline

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Mirage.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Mirage.js
|  73|  73| 	this.classesList = clone(cmpIdentity.GetClassesList());
|  74|  74| };
|  75|  75| 
|  76|    |-Mirage.prototype.GetClassesList = function() { return this.classesList };
|    |  76|+Mirage.prototype.GetClassesList = function() { return this.classesList; };
|  77|  77| 
|  78|  78| // Foundation data
|  79|  79| 

binaries/data/mods/public/simulation/components/Mirage.js
|  76| Mirage.prototype.GetClassesList·=·function()·{·return·this.classesList·};
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/differential/1827/display/redirect

Stan added a subscriber: Stan.Jun 27 2019, 8:50 AM

Well in tests you could check that Mirages have all the health keys that are functions ?

The thing we need to test is that all calls to mirages entities are properly mirages.

It might be possible by mocking QueryMiragedInterface and running the GetEntityState function in GUIInterface... I need to look into it more.

I don't know anything about tests, but I applied the diff and can confirm it stops the errors.

wraitii updated this revision to Diff 8641.Jun 29 2019, 1:41 PM

Missed the init in the constructor.

I think a test isn't doable, but perhaps we could do some simple static analysis using a linter.

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...
Executing section JS...
|    | [NORMAL] ESLintBear (semi):
|    | Missing semicolon.
|----|    | /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Mirage.js
|    |++++| /mnt/data/jenkins-phabricator/workspace/differential/binaries/data/mods/public/simulation/components/Mirage.js
|  74|  74| 	this.classesList = clone(cmpIdentity.GetClassesList());
|  75|  75| };
|  76|  76| 
|  77|    |-Mirage.prototype.GetClassesList = function() { return this.classesList };
|    |  77|+Mirage.prototype.GetClassesList = function() { return this.classesList; };
|  78|  78| 
|  79|  79| // Foundation data
|  80|  80| 

binaries/data/mods/public/simulation/components/Mirage.js
|  77| Mirage.prototype.GetClassesList·=·function()·{·return·this.classesList·};
|    | [NORMAL] JSHintBear:
|    | Missing semicolon.
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/differential/1839/display/redirect

This revision was not accepted when it landed; it landed in state Needs Review.Jun 29 2019, 7:17 PM
This revision was automatically updated to reflect the committed changes.

The selection problem is fixed, but there's a related problem I did not notice until now. When trying to task a unit to capture/attack an enemy building in the FOW:

ERROR: JavaScript error: simulation/components/GuiInterface.js line 257 TypeError: cmpHealth.IsInjured is not a function GuiInterface.prototype.GetEntityState@simulation/components/GuiInterface.js:257:49 GuiInterface.prototype.ScriptCall@simulation/components/GuiInterface.js:1975:1 GetEntityState@gui/session/session.js:214:21 getActionInfo@gui/session/unit_actions.js:1523:20 g_UnitActions.garrison.hotkeyActionCheck@gui/session/unit_actions.js:679:21 determineAction@gui/session/input.js:266:12 updateCursorAndTooltip@gui/session/input.js:94:16 onTick@gui/session/session.js:795:2 __eventhandler102 (tick)@session tick:0:1

ERROR: Error calling component script function ScriptCall