- Joined
- Mar 22, 2009
- Messages
- 172
I have a struct started here. I need to determine if an instance of a struct was actually created, and hence exists.
I can see a way to do this, but I want to know if there is an intrinsic method of doing it.
I would add an extra member variable, isAllocated. Set it to true when creating, false when destroying.
However, considering that the struct stack doesn't grow until it hits the 8191 limit, even when you destroy one in the middle of the stack, (I guess its not a stack, but still) there must be something in the resulting code that determines if an index is in use or not.
Basically, is there a way to ask an instance of a struct if it exists?
Also, what does comparing an instance of a struct with null do? Or -1? I've seen both, and am unsure.
I can see a way to do this, but I want to know if there is an intrinsic method of doing it.
I would add an extra member variable, isAllocated. Set it to true when creating, false when destroying.
However, considering that the struct stack doesn't grow until it hits the 8191 limit, even when you destroy one in the middle of the stack, (I guess its not a stack, but still) there must be something in the resulting code that determines if an index is in use or not.
Basically, is there a way to ask an instance of a struct if it exists?
Also, what does comparing an instance of a struct with null do? Or -1? I've seen both, and am unsure.
JASS:
struct PlayerData
static method operator[] takes integer iIndex returns PlayerData
local PlayerData this = iIndex + 1
return this
endmethod
static method create takes player iPlayer returns PlayerData
local PlayerData this = PlayerData.allocate()
return this
endmethod
endstruct
Last edited: