Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3189 closed enhancement (fixed)

GuiInterface/Mirage code cleanup

Reported by: leper Owned by: leper
Priority: Should Have Milestone: Alpha 19
Component: UI & Simulation Keywords: patch
Cc: Itms, sanderd17, mimo Patch:

Description

Currently GuiInterface has some strange constructs to get the correct data for miraged entities. The attached patch (incomplete (not removing Health() etc makes it work), wip) adds a QueryMiragedInterface to get cmpMirage or the implementation of that interface.

This might cause some issues if cmpMirage doesn't provide functions (for examples see GuiInterface uses) that are used, but those errors should be easy to detect.

Providing the same interface makes client code a lot simpler and less error prone (wrong ordering).

Attachments (2)

guiinterface_mirage_cleanup.diff (6.1 KB ) - added by leper 9 years ago.
wip (as in incomplete); slightly broken (removes Health() and similar though still used (see first point))
QueryMiragedInterface.diff (20.6 KB ) - added by leper 9 years ago.

Download all attachments as: .zip

Change History (7)

by leper, 9 years ago

wip (as in incomplete); slightly broken (removes Health() and similar though still used (see first point))

by leper, 9 years ago

Attachment: QueryMiragedInterface.diff added

comment:1 by leper, 9 years ago

Cc: mimo added
Keywords: patch review added

The above patch adds QueryMiragedInterface and uses that where applicable. It also exposes some more functions via cmpMirage (which eg allows to display the amount of builders when the entity was last seen (not implemented)).

During this process I noticed that cmpResourceSupply.GetGatherers() is not really needed by most of the code (except AI, though I didn't dig into that; so that's why I'm CCing mimo) so I added a cmpResourceSupply.GetNumGatherers() and cleaned up both by using arrow functions.

comment:2 by mimo, 9 years ago

In 16605:

do not transfer the unused full gatherer list to the AIs, refs #3189

comment:3 by mimo, 9 years ago

In fact, the AI also uses only the number of gatherers. I've changed the code accordingly, and in your patch, line 284 of AIProxy.js should better be changed to use the new function GetNumGatherers.

comment:4 by leper, 9 years ago

Resolution: fixed
Status: newclosed

In 16607:

Add QueryMiragedInterface. Fixes #3189.

QueryMiragedInterface allows to make writing Mirage-aware code (GuiInterface)
simpler and less prone to error.
Replaces ResourceSupply's GetGatherers() with GetNumGatherers() as the former
was never used in a way other than the second.

comment:5 by leper, 9 years ago

Keywords: review removed

Thanks for the comments. Still needs code to serialize Set in the engine (similar to #2475).

Note: See TracTickets for help on using tickets.