struct UnitList extends array // Jesus4Lyf's magic unit list struct.
readonly thistype next
readonly thistype prev
private method AIDS_onCreate takes nothing returns nothing
set thistype(0).prev.next=this
set this.prev=thistype(0).prev
set thistype(0).prev=this
set this.next=thistype(0)
endmethod
private method AIDS_onDestroy takes nothing returns nothing
set this.prev.next=this.next
set this.next.prev=this.prev
endmethod
//! runtextmacro AIDS()
// These shouldn't be in the struct, it should use the struct remotely (encapsulation).
// but...
static method enumUnitsAll takes group g returns nothing
local thistype this=thistype(0).next
loop
exitwhen this==0
call GroupAddUnit(g,this.unit)
set this=this.next
endloop
endmethod
private static thistype enumThis
private static trigger filterTrig=CreateTrigger()
static method getFilterUnit takes nothing returns unit
return thistype.enumThis.unit
endmethod
static method enumUnits takes group g, boolexpr filter returns nothing
call TriggerAddCondition(thistype.filterTrig,filter)
set thistype.enumThis=thistype(0).next
loop
exitwhen thistype.enumThis==0
if TriggerEvaluate(thistype.filterTrig) then
call GroupAddUnit(g,thistype.enumThis.unit)
endif
set thistype.enumThis=thistype.enumThis.next
endloop
call TriggerClearConditions(thistype.filterTrig)
endmethod
endstruct