chobibo
Level 1 Crypt Lord
- Reaction score
- 48
Actually what I wanted t say was "that's wrong, please change that.", I'm glad you didn't take that offensively."haha you're wrong"
About 1.03, you switching to a linked list?
Actually what I wanted t say was "that's wrong, please change that.", I'm glad you didn't take that offensively."haha you're wrong"
Struct index is always starting from 1. thistype(0) is struct #0, it is not used in default.
if this.prev==0 then // We must be removing the first node.
set First=this.next // or "set First=First.next"
else
set this.prev.next=this.next
endif
set this.next.prev=this.prev
private static method PeriodicLoop takes nothing returns boolean
local thistype this=thistype(0).next
loop
exitwhen this==0
if this.periodic() then
// This is some real magic.
set this.prev.next=this.next//Im guessing this is the thing that stops timer from calling .periodic()?
set this.next.prev=this.prev//whats this do aswell?
// This will even work for the starting element.
endif
set this=this.next//why are you setting this=this.next?
endloop
return false
endmethod
method startPeriodic takes nothing returns nothing
set thistype(0).next.prev=this //???why are you setting all these stuff
set this.next=thistype(0).next
set thistype(0).next=this
set this.prev=thistype(0)
endmethod
set thistype(0).next.prev=this
Linked list (as a whole):
+--------------+-------------------+------------------------+--------------------------...
|thistype First|thistype First.next|thistype First.next.next|thistype First.next.next.next
+--------------+-------------------+------------------------+--------------------------...
Until .next is equal to 0 (null, or in other words, no more structs left).
(Hence exitwhen this==0)
For each single struct, to make this chain effect, we know:
+------------------+------------------+------------------+ <-- Your struct.
|thistype this.prev|"THIS" STRUCT HERE|thistype this.next|
+------------------+------------------+------------------+
+----------------------------------+------------------+------------------+ <-- "First".
|thistype this.prev (==thistype(0))|"THIS" STRUCT HERE|thistype this.next|
+----------------------------------+------------------+------------------+
this|whatUsedToBeFirst(andDoesn'tKnowThere'sSomethingBeforeItStill)|whateverElseIsInTheList
set this.prev = thistype(0)
set this.next=thistype(0).next
set this.next.prev = this
// Put "implement T32" BELOW this method.
library AWESOME
globals
private timer array TA
private integer array IA
private integer array TD
private integer size = 0
endglobals
function GetTimerIndex takes timer t returns integer
local integer use = 0
local boolean b = false
loop
exitwhen b == true
if t == TA[use] then
set b = true
endif
set use = use + 1
endloop
return use - 1
endfunction
function SetTimerData takes timer t, integer i returns nothing
local integer use = 0
local boolean b = false
loop
exitwhen b == true
if t == TA[use] then
set b = true
endif
set use = use + 1
endloop
set TD[use - 1] = i
endfunction
function GetTimerData takes timer t returns integer
local integer use = 0
local boolean b = false
loop
exitwhen b == true
if t == TA[use] then
set b = true
endif
set use = use + 1
endloop
return TD[use - 1]
endfunction
function ReleaseTimer takes timer t returns nothing
local integer use = 0
local boolean b = false
loop
exitwhen b == true
if t == TA[use] then
set b = true
endif
set use = use + 1
endloop
set IA[use - 1] = 0
endfunction
function NewTimer takes nothing returns timer
local integer use = -1
local boolean b = false
loop
set use = use + 1
if IA[use] == 0 then
set b = true
endif
exitwhen use == size or b == true
endloop
if use == size then
set TA[use] = CreateTimer()
set size = size + 1
endif
set IA[use] = 1
return TA[use]
endfunction
endlibrary