• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] TriggerRegisterUnitEvent question

Status
Not open for further replies.
Level 23
Joined
Nov 29, 2006
Messages
2,482
Okay, so I was unsure about one thing. Let say I do the following:

JASS:
function Reg takes nothing returns boolean
    call TriggerRegisterUnitEvent(A_trigger, GetFilterUnit(), EVENT_UNIT_DAMAGED)
    return false
endfunction
function IsTest takes nothing returns nothing
    call GroupEnumUnitsInRect(g, WORLD_MAP, Filter(function Reg))
endfunction

What if the unit dies(without decaying)/decays/explodes/removes (and such), will this cause event leaks? I mean, the event will not be used anymore since the unit doesn't exist, therefor it will only take up space in memory?

Is this something to bother about, and/or is there a possible solution?

/regards
 
Level 11
Joined
Apr 6, 2008
Messages
760
JASS:
function Reg takes nothing returns boolean
    local unit u = GetFilterUnit()
    set trig [a] = CreateTrigger()
    call SetUnitUserData(u,a)
    call TriggerRegisterUnitEvent(trig[a],u,EVENT_UNIT_DAMAGED)
    set a = a + 1
    return false
endfunction
function IsTest takes nothing returns nothing
    call GroupEnumUnitsInRect(g, WORLD_MAP, Filter(function Reg))
endfunction


and when a unit dies
JASS:
function Dies takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer a = GetUnitUserData(u)
    call DestroyTrigger(trig[a])
endfunction


could be better and could be worse


EDIT: Typo
 
Last edited:
Level 23
Joined
Nov 29, 2006
Messages
2,482
emperor_d3st: yup I have been thinking that way for a long time, to create a trigger for each unit.

Ciebron, yea although I suppose you know DestroyTrigger[a] doesn't exist for real...
It could be better and it could be worse yes, since this is only the half solution to my next problem.

Edit: I found a way through that problem, no need to discuss it =)

Thx to both of you
 
Status
Not open for further replies.
Top