HomeWildfire Games

Apply modifications to template values based on entity owner instead watching…

Description

Apply modifications to template values based on entity owner instead watching player

When observer selects some building he can see possible units to be trained. Data about that templates are returned with id of observer what means no technologies or bonuses for selected player have been applied to the template. So observer does not see correct information in tooltip.

Differential Revision: https://code.wildfiregames.com/D2054
Fixes: #5109
Tested by: Nescio

Event Timeline

elexis added a subscriber: elexis.Dec 15 2019, 1:27 AM
elexis added inline comments.
/ps/trunk/binaries/data/mods/public/gui/session/selection_panels.js
250

(The split into two arrays is a bit ugly (the idea is that the functions have all the same signature/ same argument. This makes it a bit easier to read (as one can directly see that its one array of tooltip functions) and functions could be inserted (not currently as it's local, but once the array is stored in a prototype or object property).)
Perhaps the entity owner could be stored in the entity state ("template"), this way it could be reused by the other tooltip functions as well.)

/ps/trunk/binaries/data/mods/public/gui/session/session.js
222

(In general this function may be called often and object creation can make the difference between code finishing in a second or 2 minutes (for rmgen). I recognize the NativeWrappers RegisterScriptFunction functions only works for fixed number of arguments, that's why it only supports one argument in GuiInterfaceCall (IIRC), but whenever you see object creation, we should remember it's a performance antipattern. I suppose once this is in a class, this argument object may be a one-time allocated vector, similar to those sprintf objects in new gui code)

/ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js
567

Should be the same as data.owner || player

Does this return the wrong value if owner is gaia / 0?