Closed igroglaz closed 3 years ago
This calculation only uses constants so this doesn't make sense at all...
Yep, but still we can optimize it? it's 5 operations % * < % /
I don't understand why to calculate it a lot of times if we can do it once and store in structure? Please explain to poor rookie :)❤️
Because it changes every turn so you need to calculate it every turn. Storing the result makes no sense since the value would be obsolete immediately.
Hm.. yep, but if we calculate daytime in several parts of the code - we can calculate it once somewhere in the 'top' part of the code and when the program continue to process to the bottom - it won't need to calculate it again.. I mean - if we call the same function in different parts of the code - game has to calculate it again and again? Or compiler optimize it by himself during compilation and calculate it only once?
atm there are a lot of places in the code which checks is it day or night:
check is:
What if we will add new paramenet to player or cave with bool day/night? so each turn it will be counted only once and if it was chenged - it will be recorded to structure and game won't needed to recalculate it some more times.
I'm planning to add some new features based at day/night mechanics - eg vampires won't like walking in daylight, werewolfs will be able to turn into wolves at nights, etc... so maybe it's good idea to optimize this calculations so game will work faster and more effective terms of server resources? I'm rookie, so maybe it's stupid idea ;)