HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Double free of type: xecast

09-14-2008, 12:39 AM#1
Leopard
>>Hi friends...leopard come here with the best regards and some question need your help


>>I have just complete converting from CS to XE, but every time a unit cast spells, i get this message: "double free of type: xecast"

>>Belows is an example, this idea is simple. Every 0.2 second, a lightning bolt will strike a random enemy unit for up to 6 times...Its fine, right?

Hidden information:
Collapse JASS:
 scope ThunderStorm

//***************************************************
globals
private constant integer AbilityID             = 'A05T'
private constant integer DummyAbilityID        = 'A05U'
private constant string OrderID                = "frostnova"
private unit target
private real x
private real y
private boolexpr CheckGroup = null
endglobals
//****************************************************

private function condition takes nothing returns boolean
return GetSpellAbilityId() == AbilityID
endfunction

private function check takes nothing returns boolean
return target !=GetFilterUnit() and not IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) and not IsUnitType(target, UNIT_TYPE_MECHANICAL) and  IsPlayerEnemy(GetOwningPlayer(target), GetOwningPlayer(GetTriggerUnit()))
endfunction

private function action takes nothing returns nothing
  local xecast   xc  = xecast.createA()
  local unit c = GetTriggerUnit()
  local group enemies = CreateGroup()
  local unit t
  local integer il = GetUnitAbilityLevel(c, AbilityID)
  local integer ic = (2+il)
  set target = GetSpellTargetUnit()
  set x = GetUnitX(target)
  set y = GetUnitY(target)
  set xc.abilityid    = DummyAbilityID                       
  set xc.level        = GetUnitAbilityLevel(c, AbilityID)
  set xc.orderstring  = OrderID                     
  set xc.owningplayer = GetOwningPlayer(c)
  call GroupEnumUnitsInRange(enemies, x, y, 600, CheckGroup)
  loop
    set t = FirstOfGroup(enemies)
    exitwhen t == null or ic == 0
    call xc.castOnTarget(t)
    set ic = ic - 1 
    call GroupRemoveUnit(enemies, t)
    call PolledWait(0.20)
  endloop
  call DestroyGroup(enemies)
  set enemies=null
  set target=null
  set c =null
  set t=null
endfunction   

public function InitTrig takes nothing returns nothing
    local trigger Trig = CreateTrigger()
    set CheckGroup = Condition(function check)
    call TriggerRegisterAnyUnitEventBJ(Trig, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(Trig, Condition( function condition ) )
    call TriggerAddAction(Trig, function action )
    set Trig = null
endfunction
endscope


>>An other problem...Here is my spell "Nature's Grasp" : Gives a chance to entangle enemy melee units that attack the unit under Nature's Grasp effect.
--I do this by: every time a unit attacked, attacked unit has buff Nature's Grasp...then gets a random int and if it meets..order the caster to entangle atacker...But...every time a unit is attacked, i must use :
Collapse JASS:
local xecast   xc  = xecast.createA()
..Will this leak and ineffective?
But local must be at the top..so i cant create it after the requirement meet..(15% chance for example)

Ok, the code, so you can help me out easily:

Hidden information:
Collapse JASS:
scope NatureGrasp

//********************************************************
globals
private constant integer CasterID              = 'H009'
private constant integer AbilityID             = 'A03E'
private constant integer BuffID                = 'B00Z'
private constant integer DummyAbilityID        = 'A03F'
private constant string OrderID                = "entanglingroots"
endglobals
//********************************************************

private function condition takes nothing returns boolean
    return GetUnitTypeId(GetTriggerUnit()) ==CasterID and GetUnitAbilityLevel(GetTriggerUnit(), BuffID) > 0
endfunction

private function action takes nothing returns nothing
    local xecast   xc  = xecast.createA()
    local unit c = GetTriggerUnit()
    local unit t = GetAttacker()
    local integer ic = (2+(il*2))
    local integer ir = GetRandomInt(1, 100)
    set xc.abilityid    = DummyAbilityID                       
    set xc.level        = GetUnitAbilityLevel(c, AbilityID)
    set xc.orderstring  = OrderID                     
    set xc.owningplayer = GetOwningPlayer(c) 
    if ir<=ic and il>=1 and IsUnitType(t, UNIT_TYPE_MELEE_ATTACKER)  then
    call xc.castOnTarget(t)
    endif
    set c=null
    set t=null

endfunction

public function InitTrig takes nothing returns nothing
    local trigger Trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( Trig, EVENT_PLAYER_UNIT_ATTACKED)
    call TriggerAddCondition( Trig, Condition( function condition ) )
    call TriggerAddAction( Trig, function action )
    set Trig = null
endfunction

endscope




>>About
Collapse JASS:
local xecast   xc  = xecast.createA()
..The object will be destroyed automatically, right? but exactly when?

>>About spells use periodic time...for example "every 2 seconds, strike a target and after 10 seconds, stop it"...I have to use 2 timer? One for the periodic and one have a 10 seconds timeout to stop it? or there is another easy way?

>>I like Dusk, am i a gay ???

I could be very happy if someone could help me...thanks
Attached Images
File type: jpgxe error.jpg (260.6 KB)
09-14-2008, 07:09 AM#2
Leopard
Anybody there? Are those issues so hard ???
09-14-2008, 07:56 AM#3
Vestras
it's because you do this more than one time:

call mystruct.destroy()
09-14-2008, 12:20 PM#4
Leopard
Ok..thanks Ves...but my problem is still unsolved...I did hope that Vex would come this with a clear answer
09-14-2008, 12:26 PM#5
the-thingy
Quote:
..The object will be destroyed automatically, right? but exactly when?
No (unless XE destroys stuff automatically) - can't really see what the problem is there... :-\