• 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.

[Spell] Cant remove a leak

Status
Not open for further replies.
Level 4
Joined
Mar 23, 2009
Messages
78
When a unit casts a spell (based on shadow dagger with 0 init. damage) i use this function to spawn a dummy and give it an order:
JASS:
    local unit u
    local integer l
    local location loc
    
    set loc = GetUnitLoc(GetSpellTargetUnit())
    set l = GetUnitAbilityLevel(GetSpellAbilityUnit(),'A026')
    call UnitDamageTarget(GetSpellAbilityUnit(),GetSpellTargetUnit(),50+(25*(l-1)),true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,WEAPON_TYPE_METAL_LIGHT_SLICE)
    set u = CreateUnitAtLoc(GetOwningPlayer(GetSpellAbilityUnit()),'h002',loc,0)//dummy
    call UnitAddAbility(u,'A028')//frost nova
    call SetUnitAbilityLevel(u,'A028',l)
    call IssueTargetOrder(u,"frostnova",GetSpellTargetUnit())
    call TriggerSleepAction(0.5)
    call UnitRemoveAbility(u,'A028')
    call RemoveUnit (u)
    call RemoveLocation(loc)
    set u = null
    set loc = null
This leaves a leak. I use this trigger to detect leaks:
JASS:
function Trig_check_Actions takes nothing returns nothing
    local timer Timer = CreateTimer()
    local string S
    local integer i = 0
    if udg_i_test < GetHandleId(Timer) then // !=  <
        set S = ("|cffaaaaaa [Test] H: " + I2S(GetHandleId(Timer) - 1048500) + "|r") 
        call DisplayTextToPlayer(Player(0), 0, 0, S) 
        set S = null
        set udg_i_test = GetHandleId(Timer)
    endif
    call DestroyTimer(Timer)
    set Timer = null
endfunction

function InitTrig_check takes nothing returns nothing
    set gg_trg_check = CreateTrigger()
    call TriggerRegisterTimerEvent(gg_trg_check, 0.1, true)
    call TriggerAddAction(gg_trg_check, function Trig_check_Actions)
endfunction
So, how can i remove a leak left on a spell cast?
 
Level 4
Joined
Mar 23, 2009
Messages
78
crap, that means something else is leaking.
leak detector shows that there are created 4 more objects on a first cast of a spell. this does not repeat. is it ok?
 
Last edited:
Level 14
Joined
Apr 20, 2009
Messages
1,543
crap, that means something else is leaking.
leak detector shows that there are created 4 more objects on a first cast of a spell. this does not repeat. is it ok?

If it does not repeat and it's supposed to stay in memory for the entire game, then no it's not a leak.
Since it's needed the entire game...

See it this way: if you need something to stay in memory throughout the entire game since it's being used frequently, then it's mandatory to keep it in memory. Destroying something that needs to be used frequently throughout the entire game makes no sense.
 
Status
Not open for further replies.
Top