This issue is quite complicated, but I'll try to explain what I want to accomplish and what I've currently done as detailed as possible.What I want to doMy Add-On
EventScript currently uses
findText on the client for
GuiPopUpMenuCtrl to get the id for an event in a selection. However, this function is case-sensitive, which resulted in a
suggestion to solve.
Therefore, I planned to override/package four functions that handled the registration of event names and NT names, giving me a lookup table for names, also indirectly giving me a case-insensitive way to get names.
clientCmdRegisterInputEvent
clientCmdRegisterOutputEvent
SimGroup::CLIENTaddNTName
SimGroup::CLIENTremoveNTName
What I have doneI found out that the last two was actually possible to override completely, replacing the existing functionality with one that is significantly faster.
The two first is an another story. I've checked through trace, but they are untraceable. I tried override, but they are not called by BL, but when I call them manually, they are called normally. When I package them, it's the same as override.
Here is a pastebin with what I've done so far:
event_table.csPossible solutions- Package WrenchEventsDlg, so when opened it'll just generate the lookup table on the fly. This is worse performance-wise, as it means that it'll be called each time when opening the window instead of when the user joins the server.
- Generate the table locally before going through the events to reduce the maximum lookup to a minimum. Could work, but as this script parsing is done in one run, it means that there could be a possibility of small lag when there is lots of events that needs to be parsed. Especially for output events.
- Just don't do it. It's not worth the effort and are considered micro-optimization. It's not that big of a hit to the performance than one might thing, considering that everyone else is doing it. At worst, you'll have 60 lookups on a list of 60 events, which is only 3600 iterations in total.
- Package GuiPopUpMenuCtrl::add and store the table list in there, ignoring the findText entirely. Two problems arise here: It will be added for all lists and therefore will be a really ugly way to add such thing; If the same value is added twice, then this wont work, but luckily it wont as events are limited that way anyway.
Anyone got a better solution?Feel free to discuss better possible solutions, or maybe if you got an answer to how to fix this, as that would be the best optimization on all cases.