[Solved] Is there a way to prevent the leaks generated by deleting & rebuilding a trigger by creating a trigger and adding events?

Status
Not open for further replies.
JASS:
//麣鼶爨矲韠龖龘纛灪麤麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠灪麤麣鼶爨矲韠
//麣鼶爨矲韠龖龘纛灪麤 REBUILD 韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠灪麤麣鼶爨矲韠
//麣鼶爨矲韠龖龘纛灪麤         麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖
function U_DD_on_damage takes nothing returns nothing
  local unit dsrc
  local unit dmged
  local location dmgedp
  local integer dsrctid
  local real dmg
  set dsrc = GetEventDamageSource()
  set dmged = GetTriggerUnit()
  set dmgedp = GetUnitLoc(dmged)
  set dsrctid = GetUnitTypeId(dsrc)
  set dmg = GetEventDamage()
  if GetUnitAbilityLevelSwapped('A04E', dsrc) > 0 and dmg > 100 then
    call U_DD_GS(dsrc, dmged,"frostnova")
  endif
  if dmg > 50 and U_DD_RE_conds(1,dsrc,dmged,true) then
    if udg_Cam_Shakiness + 4 < 8.5 then
      set udg_Cam_Shakiness = udg_Cam_Shakiness + 4
    else 
      set udg_Cam_Shakiness = 8.5
    endif
    call CameraSetEQNoiseForPlayer( Player(0), udg_Cam_Shakiness )
    //call U_DD_OPD(dsrc, dmged, "stomp")
    call U_DD_se(dmgedp, 2, "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl")
    call U_DD_dmgar (dsrc, dmged, 250, 50, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL)
  endif
  set dsrc = null
  set dmged = null
  call RemoveLocation(dmgedp)
  set dmgedp = null
endfunction
//  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖 
//龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  
//  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖 
function U_DD_R_grpxtion takes nothing returns nothing
  local unit atkd
  local unit atkr
  local integer ord
  set atkd = GetEnumUnit()
  set atkr = LoadUnitHandleBJ(1, GetHandleIdBJ(atkd), udg_U_DD_Temp)
  set ord = GetUnitCurrentOrder(atkr)
  if CountUnitsInGroup(U_DD_getatkrs(atkd)) == 0 or IsUnitDeadBJ(atkd)then
    //call U_DD_pr("no related attackers left - " +GetUnitName(atkd))
    call GroupRemoveUnitSimple( atkd, udg_U_DD_Registered )
  else
    //call U_DD_pr("\"" +I2S(CountUnitsInGroup(U_DD_getatkrs(atkd)))+ "\"" + "followed up - " +GetUnitName(atkd))
    call TriggerRegisterUnitEvent( gg_trg_Damage_Detection_Detect, atkd, EVENT_UNIT_DAMAGED )
  endif
  set atkd = null
  set atkr = null
endfunction
//  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖 
//龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  
//  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖  龖 
function U_DD_on_iteration takes nothing returns nothing
  set udg_U_DD_I = udg_U_DD_I + 1
  call DestroyTrigger(gg_trg_Damage_Detection_Detect)
  set gg_trg_Damage_Detection_Detect = CreateTrigger(  )
  call ForGroup(udg_U_DD_Registered, function U_DD_R_grpxtion)
  call TriggerAddAction( gg_trg_Damage_Detection_Detect, function U_DD_on_damage )
endfunction
//麣鼶爨矲韠龖龘纛灪麤         麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠
//麣鼶爨矲韠龖龘纛灪麤 REBUILD 韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠灪麤麣鼶爨矲韠
//麣鼶爨矲韠龖龘纛灪麤麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠麣鼶爨矲韠龖龘纛灪麤彠麣鼶爨矲韠灪麤麣鼶爨矲韠
 
Why do you need/want to do this?
It's part of my Damage Detection system.
 
Because On Damage event is only detected through specific units, and I need to build a trigger which registers / self-destructs dynamically.
What version are we talking about here?
Because 1.31.1 has EVENT_PLAYER_UNIT_DAMAGING and EVENT_PLAYER_UNIT_DAMAGED that you can register to a native TriggerRegisterPlayerUnitEvent takes trigger whichTrigger, player whichPlayer, playerunitevent whichPlayerUnitEvent, boolexpr filter returns event
 
Right. I don't think that you can clean up any events on any game version without some major modifications.
Edit: I clicked send before it was ready, so edited it a few times :p
Edit2: There are a few ways of dodging the problem, but they all come with some draw-backs...
 
What version are we talking about here?
Because 1.31.1 has EVENT_PLAYER_UNIT_DAMAGING and EVENT_PLAYER_UNIT_DAMAGED that you can register to a native TriggerRegisterPlayerUnitEvent takes trigger whichTrigger, player whichPlayer, playerunitevent whichPlayerUnitEvent, boolexpr filter returns event
Thanks for the help. Just updated. This worked perfectly.
 
Status
Not open for further replies.
Top