Multiplayer icon indicating copy to clipboard operation
Multiplayer copied to clipboard

TryGetMeleeVerbPatch can cause lag while selecting drafted pawns

Open SokyranTheDragon opened this issue 2 years ago • 0 comments

https://github.com/rwmt/Multiplayer/blob/master/Source/Client/Patches/Determinism.cs#L58

From a little bit of digging I did it seems the issue is when a pawn has a lot of verbs to pick from - the method returns all available verbs for the pawn, while we only use the first one we get (with non 0 weight).

One potential solution for that would be to re-implement this method, but only return the first valid. From what I saw, calling the constructor to VerbEntry can take a significant part of the GetUpdatedAvailableVerbsList due to it calling VerbUtility.FinalSelectionWeight - which may iterate over the list of all the verbs.

There could be another solution, like potentially caching the result, or looking into when exactly it is used and checking if we always need to call this method.

However, I'll have to be honest - I don't really understand why that patch is needed, and (outside of potentially re-implementing GetUpdatedAvailableVerbsList) I don't think I'd be able to make any improvements here.

SokyranTheDragon avatar Oct 15 '22 15:10 SokyranTheDragon