Closed nestharus closed 10 years ago
DDS is viable with the current state of Trigger and BooleanExpression!
No need for garbage collector
The below, which is worse than about the most complex damage handling system you can make, runs without any problems.
BooleanExpression and Trigger are officially extremely safe to use ;D. Not to mention that they are totally awesome!
The thing that has the most overhead is registering code to a trigger. However, for any given resource, it'll usually only register 1 piece of code. About the only time it's going to crash is when you're registering 11-12.
module Run
private static method init takes nothing returns nothing
call DestroyTimer(GetExpiredTimer())
call run()
endmethod
private static method onInit takes nothing returns nothing
call TimerStart(CreateTimer(), 0, false, function thistype.init)
endmethod
endmodule
struct Test extends array
/*
* DDS Entry Points
*/
private static Trigger t0
private static Trigger t1
private static Trigger t2
private static Trigger t3
private static Trigger t4
private static Trigger t5
private static Trigger t6
private static Trigger t7
private static Trigger t8
private static Trigger t9
private static Trigger t10
private static Trigger t11
private static Trigger t12
private static Trigger t13
private static Trigger t14
private static Trigger t15
private static method d1 takes nothing returns boolean
return false
endmethod
private static method d2 takes nothing returns boolean
return false
endmethod
private static method d3 takes nothing returns boolean
return false
endmethod
private static method d4 takes nothing returns boolean
return false
endmethod
private static method d5 takes nothing returns boolean
return false
endmethod
private static method d6 takes nothing returns boolean
return false
endmethod
private static method d7 takes nothing returns boolean
return false
endmethod
private static method d8 takes nothing returns boolean
return false
endmethod
private static method d9 takes nothing returns boolean
return false
endmethod
private static method d10 takes nothing returns boolean
return false
endmethod
private static method d11 takes nothing returns boolean
return false
endmethod
private static method d12 takes nothing returns boolean
return false
endmethod
private static method d13 takes nothing returns boolean
return false
endmethod
private static method d14 takes nothing returns boolean
return false
endmethod
private static method d15 takes nothing returns boolean
return false
endmethod
private static method d16 takes nothing returns boolean
return false
endmethod
private static method d17 takes nothing returns boolean
return false
endmethod
private static method d18 takes nothing returns boolean
return false
endmethod
private static method d19 takes nothing returns boolean
return false
endmethod
private static method d20 takes nothing returns boolean
return false
endmethod
private static method d21 takes nothing returns boolean
return false
endmethod
private static method d22 takes nothing returns boolean
return false
endmethod
private static method d23 takes nothing returns boolean
return false
endmethod
private static method d24 takes nothing returns boolean
return false
endmethod
private static method d25 takes nothing returns boolean
return false
endmethod
private static method d26 takes nothing returns boolean
return false
endmethod
private static method d27 takes nothing returns boolean
return false
endmethod
private static method d28 takes nothing returns boolean
return false
endmethod
private static method d29 takes nothing returns boolean
return false
endmethod
private static method d30 takes nothing returns boolean
return false
endmethod
private static method run takes nothing returns nothing
call init()
call registerCode()
call clean()
endmethod
private static method init takes nothing returns nothing
/*
* create entry points
*/
set t0 = Trigger.create()
set t1 = Trigger.create()
set t2 = Trigger.create()
set t3 = Trigger.create()
set t4 = Trigger.create()
set t5 = Trigger.create()
set t6 = Trigger.create()
set t7 = Trigger.create()
set t8 = Trigger.create()
set t9 = Trigger.create()
set t10 = Trigger.create()
set t11 = Trigger.create()
set t12 = Trigger.create()
set t13 = Trigger.create()
set t14 = Trigger.create()
set t15 = Trigger.create()
/*
* link entry points
*/
call t0.reference(t1)
call t0.reference(t2)
call t0.reference(t3)
call t0.reference(t4)
call t0.reference(t5)
call t0.reference(t6)
call t0.reference(t7)
call t0.reference(t8)
call t0.reference(t9)
call t0.reference(t10)
call t0.reference(t11)
call t0.reference(t12)
call t0.reference(t13)
call t0.reference(t14)
call t0.reference(t15)
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60000, "Trigger Initialization Complete")
endmethod
private static boolean array complete
private static method registerCode takes nothing returns nothing
local integer i = 0
/*
* register code
*/
call registerCode1()
call registerCode2()
call registerCode3()
call registerCode4()
call registerCode5()
call registerCode6()
call registerCode7()
call registerCode8()
call registerCode9()
call registerCode10()
call registerCode11()
call registerCode12()
call registerCode13()
call registerCode14()
call registerCode15()
loop
set i = i + 1
if (not complete[i]) then
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60000, "Trigger Code Registration Failure: " + I2S(i))
endif
exitwhen i == 15
endloop
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60000, "Trigger Code Registration Complete")
endmethod
private static method registerCode1 takes nothing returns nothing
call t1.register(Condition(function thistype.d1))
call t1.register(Condition(function thistype.d2))
call t1.register(Condition(function thistype.d3))
set complete[1] = true
endmethod
private static method registerCode2 takes nothing returns nothing
call t2.register(Condition(function thistype.d4))
call t2.register(Condition(function thistype.d5))
set complete[2] = true
endmethod
private static method registerCode3 takes nothing returns nothing
call t3.register(Condition(function thistype.d6))
call t3.register(Condition(function thistype.d7))
call t3.register(Condition(function thistype.d8))
set complete[3] = true
endmethod
private static method registerCode4 takes nothing returns nothing
call t4.register(Condition(function thistype.d9))
set complete[4] = true
endmethod
private static method registerCode5 takes nothing returns nothing
call t5.register(Condition(function thistype.d10))
call t5.register(Condition(function thistype.d11))
set complete[5] = true
endmethod
private static method registerCode6 takes nothing returns nothing
call t6.register(Condition(function thistype.d12))
call t6.register(Condition(function thistype.d13))
call t6.register(Condition(function thistype.d14))
call t6.register(Condition(function thistype.d15))
set complete[6] = true
endmethod
private static method registerCode7 takes nothing returns nothing
call t7.register(Condition(function thistype.d16))
set complete[7] = true
endmethod
private static method registerCode8 takes nothing returns nothing
call t8.register(Condition(function thistype.d17))
call t8.register(Condition(function thistype.d18))
set complete[8] = true
endmethod
private static method registerCode9 takes nothing returns nothing
call t9.register(Condition(function thistype.d19))
call t9.register(Condition(function thistype.d20))
call t9.register(Condition(function thistype.d21))
call t9.register(Condition(function thistype.d22))
call t9.register(Condition(function thistype.d23))
set complete[9] = true
endmethod
private static method registerCode10 takes nothing returns nothing
call t10.register(Condition(function thistype.d24))
call t10.register(Condition(function thistype.d25))
set complete[10] = true
endmethod
private static method registerCode11 takes nothing returns nothing
call t11.register(Condition(function thistype.d26))
set complete[11] = true
endmethod
private static method registerCode12 takes nothing returns nothing
call t12.register(Condition(function thistype.d27))
set complete[12] = true
endmethod
private static method registerCode13 takes nothing returns nothing
call t13.register(Condition(function thistype.d28))
set complete[13] = true
endmethod
private static method registerCode14 takes nothing returns nothing
call t14.register(Condition(function thistype.d29))
set complete[14] = true
endmethod
private static method registerCode15 takes nothing returns nothing
call t15.register(Condition(function thistype.d30))
set complete[15] = true
endmethod
private static method clean takes nothing returns nothing
call t0.destroy()
call t1.destroy()
call t2.destroy()
call t3.destroy()
call t4.destroy()
call t5.destroy()
call t6.destroy()
call t7.destroy()
call t8.destroy()
call t9.destroy()
call t10.destroy()
call t11.destroy()
call t12.destroy()
call t13.destroy()
call t14.destroy()
call t15.destroy()
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60000, "Trigger Destruction Complete")
endmethod
implement Run
endstruct
Before I change everything around, I'm going to make sure that unit specific damage events don't cause thread crashes on creation/destruction. They are very, very heavy, especially with the use of Table instead of arrays.