Giter Site home page Giter Site logo

Comments (1)

SmileyAG avatar SmileyAG commented on June 11, 2024

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

This is what I did in #516 request:
https://github.com/SmileyAG/BunnymodXT/blob/b1082da20599e1da86e1daeb34537c49fa8cf02b/BunnymodXT/modules/ClientDLL.cpp#L1183-L1211
https://github.com/SmileyAG/BunnymodXT/blob/b1082da20599e1da86e1daeb34537c49fa8cf02b/BunnymodXT/helper_functions.hpp#L34-L52
https://github.com/SmileyAG/BunnymodXT/blob/b1082da20599e1da86e1daeb34537c49fa8cf02b/BunnymodXT/helper_functions.cpp#L268-L284
https://github.com/SmileyAG/BunnymodXT/blob/b1082da20599e1da86e1daeb34537c49fa8cf02b/BunnymodXT/helper_functions.cpp#L485-L512

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

from bunnymodxt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.