Help Please - Type Object
TarotRedhand
Member Posts: 1,481
Having noticed that according to the lexicon, a variable of type object is just a single int, I sat down and thought about how this would work. Having thought about it for a while the most efficient solution I could come up with was this -
My question is quite simple really. Is the above true? Is that how the NwN EE game engine actually works or have I missed something or am I totally wrong?
All help gratefully accepted.
TR
Given that the value held by a variable of type object is just a simple int, how does this work? The games engine holds a list of everything that you have placed into the game. In order to accommodate those things created and/or destroyed during the course of the game, this list is what is termed dynamic. That is it can expand and contract as the need arises. This list in turn points toward the actual data of these things and the int is an index into the list.
My question is quite simple really. Is the above true? Is that how the NwN EE game engine actually works or have I missed something or am I totally wrong?
All help gratefully accepted.
TR
0
Comments
The Object table is generated on each run, with almost all objects starting from 0x00000000 (the module is always object 0) and players starting from 0x7FFFFFFF (INT_MAX) counting down.
As the table is generated each run, this is why SetLocalObject can't truly persist - It is only the reference, but on the next run the table may be generated in a different order, and therefore the reference/pointer will point to a different actual object.
Depending on the programming language used, altering the size of an array is not necessarily a problem. Even if it were, in languages such as C++ you can create (if it isn't a built-in object) an object called a sparse array which allows for such expansion/contraction amongst other things.
TR