Entity ID Revamp


The task of fully revamping the entity ID system has been completed after several hours of going through possibly more than 50 source files and handling many unexpected implementation details. My hope was that this change was going to be unnoticeable when playing the game, but there are a few side-effects that thankfully are mostly inconsequential, though very noticeable. The most obvious one is that the colors assigned to entities are more varied now than they used to be, which is actually nice, if unexpected. This is the result of using an entity's ID hash instead of the ID value directly to generate its color. So now it's going to be less likely for neighboring entities to be assigned the same color.

Still, there are a few drawbacks to the new ID system. First, memory usage will increase quite a bit since IDs are no longer just simple 64 bit values, but instead, full structures that need to be replicated internally a few times. This will also introduce a big problem with save files since they will become larger due to all the extra ID data they now need to store. I'm not going to worry about those two details quite yet though; As long as there are no memory leaks, I doubt the extra memory usage is going to be an issue except for PCs with very limited resources. The save file size issue will have to be handled later when the entires save/load system is rewritten, which is not going to happen anytime soon.

So, I'm going back to working on regions and super regions after this reimplementation detour. I hope to have super-regions completed over the next weekend. Then I'll start working on the migration algorithm changes that will depend on how regions are defined now.

Get Worlds - History Simulator

Comments

Log in with itch.io to leave a comment.

Awesome i got the game!

Cool, but for the IDs being replicated, don't you use pointers to ID?

IDs are basically numbers that need to be stored in the game's DB when playing and into files when saving. The most important part about IDs is saving/loading. Entities have relationships to each other and those relationships are saved into file as ID references. To restore those relationships after reloading I need to query the rebuilt game DB for the entities those IDs refer to.