- Joined
- Apr 6, 2008
- Messages
- 760
I want to destroy a struct which is saved in a indexer, but i have 2 places it can get destroyed. 1. Inside the loop and 2. from a method.
JASS:
globals
private timer Timer = CreateTimer()
private ASDF array A
private integer Index = 0
endglobals
struct ASDF
integer INDEX
static method create takes nothing returns thistype
local thistype this = thistype.allocate()
//struff
set this.INDEX = Index
if Index == 0 then
call TimerStart(//blaH)
endif
set A[Index] = this
set Index = Index + 1
endmethod
method Destroy takes nothing returns nothing
//Here is the question, will this break the indexer?
//Is there are better way, then how?
call this.destroy()
set Index = Index - 1
set A[this.INDEX] = A[Index]
if Index == 0 then
call PauseTimer(Timer)
endif
endmethod
endstruct