HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Doing some experiment, did i clean the leaks correctly ?

10-22-2006, 05:04 AM#1
zen87
ok, i'm doing some experiment on the Tables in CSCache, so i try on a trigger like below, all it does is blink the shadow strike caster to the target after shadow strike has been casted. I can't run the blinking instantly after the spell is casted (not even with "unit start effect of") as it will result in no mana/cooldown is used

my question here is simple, the trigger below work perfectly, but did i clean the memory leaks correctly? because i'm not sure is this the right way to clean the leaks in tables
Collapse JASS:
function Trig_shadow_strike_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A005'
endfunction

function ShadowStrikeMove takes nothing returns nothing
 local unit u = GetTableUnit("shadowstrike","caster")
 local unit c = GetTableUnit("shadowstrike","target")
 local location x = GetUnitLoc(c)
    call DestroyTimer(GetExpiredTimer())
    call DestroyTable("shadowstrike")
    call SetUnitPositionLoc(u,x)
    call IssueTargetOrder(u,"attack",c)
 set u=null
 set c=null
 set x=null
endfunction

function Trig_shadow_strike_Actions takes nothing returns nothing
 local unit u = GetSpellAbilityUnit()
 local unit c = GetSpellTargetUnit()
    call SetTableObject("shadowstrike","caster",u)
    call SetTableObject("shadowstrike","target",c)
    call TimerStart(CreateTimer(),0,false,function ShadowStrikeMove)
 set u=null
 set c=null
endfunction

//===========================================================================
function InitTrig_mistress_spells takes nothing returns nothing
 local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Trig_shadow_strike_Conditions ) )
    call TriggerAddAction( t, function Trig_shadow_strike_Actions )
 set t=null
endfunction

===

btw vex, in your caster system's tutorial about CSCache Module, there is this line :
Quote:
___________________________________________________________________________
function AttachObject takes handle h, string label, handle x returns nothing
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
This works exactly as attaching an integer or string or that stuff, but you can attach a handle
see above to know what can a handle be, ex:

call AttachObject( gg_trg_kill_mephisto,"mephisto",bj_lastCreatedUnit)

will attach the last created unit to the kill mephisto trigger, labeled as mephisto

call AttachObject( GetSummonedUnit() , "master", GetSummonnedUnit() )

will attach the summoned unit to the summoning unit with the "master" label , so later you will be
able to know who summoned that unit.
the line
call AttachObject( GetSummonedUnit() , "master", GetSummonnedUnit() )
is rather confusing @@ or does it mean this ? (errr typo?)
call AttachObject( GetSummoningUnit() , "master", GetSummonnedUnit() )
10-22-2006, 05:08 AM#2
Vexorian
yes and yes
10-22-2006, 05:25 AM#3
zen87
wow, thanks for super fast replies O_o now i can do lots more with the table :)
11-05-2006, 05:46 PM#4
Meanie
Tables are terrible outdated but it is easier to understand and easier for beginners. Consider using DynamicArrays or something

Edit: Took me about 5 minutes to realize it was a Blink Strike :D