You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would say that in general the game directory search code is poorly designed in terms of performance and this is definitely my fault (but at the time I did it I didn't really think about optimization at all), since at the moment every time the function is called to get the game directory, a large number of different operations take place (allocating and freeing of 1024 bytes for local variable [max game directory length in engine code is 260, so that 1024 size is even incorrect], strlen / while loops / strncpy from COM_FileBase to convert from absolute to relative path, and we also convert it all to lowercase at the end) as a result of which we will have the same result throughout the entire process (since the initial data, i.e. the game directory can only change when restarting or exiting the game, the rest of the time it will be the same)
This means that we need initialize only once, store the result globally in memory, and simply return that for all subsequent calls to that function
This also includes setting boolean variables that serve to identify some of the games; we can set them once in the same function in which we initialize the process of finding and processing the game directory and use this
Another question is that it is not particularly clear where exactly it is best to call in the game functions, because we prefer to call immediately after the game directory has already been initialized, preferably this should use the hooks we already have (it would great if it would be exported ones such as HUD_Init)
So, as a temporary and alternative solution, macros were placed to initialize the game directory in those places where they are used if the directory has not yet been initialized
BunnymodXT/BunnymodXT/modules/HwDLL.cpp
Lines 3416 to 3418 in 76aefb2
The variable is only set when loading a TAS file, not upon starting the game or starting a map.
BunnymodXT/BunnymodXT/modules/HwDLL.cpp
Line 6795 in 76aefb2
Maybe we should have a way to know the current game dir as soon as the game starts so stuffs like this don't scatter around.
The text was updated successfully, but these errors were encountered: