- Mar 5, 2024
- 80
- 45
I have been able to reduce the runtime for the conclude day (with midnight calculations) for my game from more than 7 seconds to about 3 seconds, just by doing some preprocessing and restructuring some code (especially if-blocks). (And I expect that the runtime improvement would be even larger, if I had a few floor crawlers, a guard captain (with maybe some guards) and a few more workshops or a few more npcs, as I am currently not at the cap). The midnight calculations alone, without conclude day do currently take maybe 1.5 seconds with the changes, without the changes the midnight calculations without conclude day would currently take more than 4.5 seconds.
While currently the runtime of the code should probably not be the primary concern of Grimdark (GD-studios), it might still be a good idea to not totally neglate the runtime of the code (ie. if inefficient code blocks are copy and pasted before some modifications to the pasted code block, it will be more work to make the code blocks efficient later on as there will be more code blocks, which need to be changed), as the code base (or code size) will probably get larger in future versions and the runtime will increase (eventhough this is probably only necessary in the long run for the code executed during the "midnight calculations" and the "conclude day calculations" and for possible future computation heavy code).
ps. At least for random npcs there is a problem if the npc successfully escapes (in v8.31), as in that case "ClearSlot" is called too early (so that the melee and other stats of the npc are no longer available, eventhough they are still used for calculating the damage to guards etc.).
You don't have permission to view the spoiler content.
Log in or register now.
While currently the runtime of the code should probably not be the primary concern of Grimdark (GD-studios), it might still be a good idea to not totally neglate the runtime of the code (ie. if inefficient code blocks are copy and pasted before some modifications to the pasted code block, it will be more work to make the code blocks efficient later on as there will be more code blocks, which need to be changed), as the code base (or code size) will probably get larger in future versions and the runtime will increase (eventhough this is probably only necessary in the long run for the code executed during the "midnight calculations" and the "conclude day calculations" and for possible future computation heavy code).
ps. At least for random npcs there is a problem if the npc successfully escapes (in v8.31), as in that case "ClearSlot" is called too early (so that the melee and other stats of the npc are no longer available, eventhough they are still used for calculating the damage to guards etc.).