billw2015
King
- Joined
- Jun 22, 2015
- Messages
- 837
Also, the amount of memory you would save by putting GlobalDefines in a header instead is going to be so trivial as to be not worth the effort (I'm just going to assert that unless someone has data showing otherwise), *and* the xml can be reloaded dynamically so modders can experiment with different values without restarting the game (I did this with the new paging system to tweak the values).
Certainly inner loops and such like should not be repeatedly looking up the same value over and over, whether it be a global define setting or any other value from a map; just look it up once before the loop and put it into a variable.
One thing we *could* do with global defines (and other settings) though would be to generate a class GlobalDefines header from the xml structure, along with a load function for it (probably just the constructor itself can load the xml). That way we can avoid using lookup by string entirely, get full type safety, AND fast access, all without any extra caching or variable required anywhere.
Certainly inner loops and such like should not be repeatedly looking up the same value over and over, whether it be a global define setting or any other value from a map; just look it up once before the loop and put it into a variable.
One thing we *could* do with global defines (and other settings) though would be to generate a class GlobalDefines header from the xml structure, along with a load function for it (probably just the constructor itself can load the xml). That way we can avoid using lookup by string entirely, get full type safety, AND fast access, all without any extra caching or variable required anywhere.