at 0x108 is a int16 maxIndex. it´s -1 if the container is empty.
at 0x10C is a int32 numEntrys
so if there are 3 entrys, maxIndex is 2.
at 0x108 is a int16 maxIndex. it´s -1 if the container is empty.
at 0x10C is a int32 numEntrys
so if there are 3 entrys, maxIndex is 2.
It is indeed Int16, explains a comment I found in my code (ignore it being named count)
// NOTE: Count should be short?? Invalid count gives short.MaxValue (0x0000FFFF)
are you sure that maxIndex is int16?
for me:
and it seems the proper way to handle the for loop is:Code:int wtfIsThis1 = MR.ReadInt(addr_actors_container + 0x100 ); // =1024 int wtfIsThis2 = MR.ReadInt(addr_actors_container + 0x104 ); // =1068 int maxIndex = MR.ReadInt(addr_actors_container + 0x108 ); // =153 int wtfIsThis3 = MR.ReadInt(addr_actors_container + 0x10C ); // =136
Code:for (int i = 0; i <= maxIndex; i++)
Do not send me private messages unless it is absolutely necessary or the content is sensitive or when I ask you to do that...
If it goes to -1 you suddenly loop 65536 times! So make sure you handle it as Int16
If you treat maxIndex as Int32 (when it is Int16) then you'll always get positive values as 0x0000FFFF is nowhere near negative.
I'm also enumerating using maxIndex, since I didn't understand why 0x10C wasn't maxIndex-1.
Your wtfIsThis1 is the container limit and wtfIsThis2 is the item size.Code:public IEnumerable<Actor> EnumerateActors() { var container = ObjectManager.Storage.Actors; int sizeOf = container.SizeOf; int current = Memory.Read<int>(container.List); for (int i = 0; i <= container.MaxIndex; i++) { yield return new Actor(Memory, current); current += sizeOf; } }
oh yeah you are right john. numEntrys can be smaller. my guess is, that 0x10C is the count of entrys with valid guid.
One is the highest index the other one is the count, not every actor is valid tho.
Take a look at any of the funcs that iterate acd's or RActors.
Do you have the new offset for 1.0.8a ?