Alright so as I'm writing the state management code for combatants I made the decision to use size_t for my constants that correspond to the index in the attribute array for which the name of the constant corresponds.

Part of the reason was simply that size_t was used by vector which I'm using to store attributes. Another reason is that my research into size_t reveled it guarantees at least 32bit but is actually the word size of the architecture if it is in fact larger than 32bit. So by using this I'm insuring the portability of my code while still guaranteeing I have enough room to index all of the elements in my attribute arrays. So in short although I don't plan on using more than a handfull of static attributes once I add functionality for attaching attributes dynamically from scripts for example I will have plenty of space to grow specially if the server happens to be 64bit.

I also created a typedef of size_t called Attribute for use as values for the attributes of an entity. The reason for this is similar to above but using my own typedef allows me to change it later.

One thing to note with both of these cases. There is a performance penalty on 16bit platforms. The reason being that two instructions are required for each operation on each size_t object because it would in that case be two registers.

I plan on running this on a 32bit server so the above isn't really all that important for my uses. However it may come in handy for someone else once I release the code.


Popular posts from this blog

VK9 - Milestone13 Completed

VK9 - Milestone16 Completed

VK9 - Milestone23 Completed