#3149 closed defect (fixed)
[PATCH] Clicking CC in Observer mode causes undefined mirage error
Reported by: | elexis | Owned by: | leper |
---|---|---|---|
Priority: | Nice to Have | Milestone: | Alpha 19 |
Component: | UI & Simulation | Keywords: | patch |
Cc: | Patch: |
Description
Each time I click a civic centre as observer, the following error appears. This happens on svn, a17 and a18.
WARNING: JavaScript warning: simulation/components/Fogging.js line 160 reference to undefined property this.miraged[player]
Reproduce by hosting and joining as observer in a second instance of 0ad and then clicking the CC.
Attachments (1)
Change History (9)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
The error occurs in the last line of this function in simulation/components/Fogging.js
Fogging.prototype.IsMiraged = function(player) { if (player >= this.mirages.length) return false; return this.miraged[player]; };
comment:3 by , 9 years ago
This error also happens if the player is defeated and the CC becomes gaia before it is built (don't ask how that happened...)
In simulation/components/Fogging.js (line 302-309) there is this call to the function above:
var cmpFogging = Engine.QueryInterface(ent, IID_Fogging); if (cmpFogging) { if (cmpFogging.IsMiraged(player)) ret.fogging = {"mirage": cmpFogging.GetMirage(player)}; else ret.fogging = {"mirage": null}; }
If you add the following line before the call to cmpFogging.IsMiraged(player),
error("TEST");
then "TEST" will appear right before the error.
comment:4 by , 9 years ago
If you change the debug message in simulation/components/Fogging.js to
error("TEST" + player);
then you can see that the player number is -1 (the number of the observer right?).
comment:5 by , 9 years ago
Keywords: | review added |
---|---|
Summary: | Clicking CC in Observer mode causes undefined mirage error → [PATCH] Clicking CC in Observer mode causes undefined mirage error |
comment:6 by , 9 years ago
Component: | Core engine → UI & Simulation |
---|---|
Keywords: | patch added |
Hello elexis, the patch should fix the error, but it would be better to fix WasSeen
, GetMirage
and OnVisibilityChanged
the same way, to avoid other possible failures.
While you're at it, you might change WasSeen
to test against this.mirages.length
, for consistency with the other functions.
Thanks for working on a patch :)
by , 9 years ago
Attachment: | ticket3149_observer_undefined_mirage.patch added |
---|
sry typo in last patch
The error appears only the first time one clicks the CC in observer mode. The error also appears if the CC is not built yet (nomad map).