Closed robojumper closed 2 weeks ago
I don't know of any mod/base-game mechanism that does it this way, but a warning would be appropriate. Alternatively,
IsA
checks can be used to automatically include subclasses.
As it turns out, this is not correct; this Highlander uses wrapper functions in X2DownloadableContentInfo. We would probably need to handle sets of dependent functions and check those too.
https://discord.com/channels/165245941664710656/273238884433788928/1139536225242468443
This can only be optimized if we break backward compatibility. nvm. I didn't fully read the initial post
This is a proof of concept: https://github.com/X2CommunityCore/X2WOTCCommunityHighlander/compare/master...remcoros:X2WOTCCommunityHighlander:fixes/DLCInfo_hook_manager
It also deals with X2DLCI classes with custom base classes as discussed on discord. Not by excluding them and/or dealing with them differently, but just walking up the inheritance chain and checking those classes too.
Open to naming / style changes and no docs yet, but that will come when finalized.
(edit) and of-course implemented in more places.
Some results after the changes:
The first spike is mainly due to 'DrawDebugLabels', I also disabled that in the second profile (right)
The screenshots show aggregate function calls of the entire profile, note that there are no more calls to XComGame.X2DownloadableContentInfo! This is most noticeable in the "UpdateHumanPawnMeshComponent/Material" calls, and slightly in the "DisplayQueuedDynamicPopup" call.
This is a profile of a single "move" action of a soldier.
I don't see in the original issue other specific cases of known 'lag' due to triggering events which I can do a before/after test on, but if anyone knows a good place/situation to do another trace (tactical / geoscape?) let me know.
Adding a DLC Hook to the X2DownloadableContentInfo class is a simple way to expose hooks to Mods. This is an example call:
https://github.com/X2CommunityCore/X2WOTCCommunityHighlander/blob/47a00149c83d86b9826da64866313192cb41b18c/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComHumanPawn.uc#L967-L971
The problem is that performance becomes worse with every mod installed, since almost all mods include an X2DownloadableContentInfo file. If we limited the function calls to only those classes that actually implement the function, we could improve performance dramatically and make DLC hooks more viable in code segments that are called often. We would incur a small overhead for filtering the classes in the first place, but if we cache the classes, this should improve performance quite a bit.
Whether a class implements a function can be checked by
There is one problem: If users create an "abstract" X2DownloadableContentInfo subclass and let functions in this class call functions that are overridden in subclasses, it will break, because the subclass functions don't really exist. I don't know of any mod/base-game mechanism that does it this way, but a warning would be appropriate. Alternatively,
IsA
checks can be used to automatically include subclasses.