Why is this code leaking? Please,help T_T

Zwiebelchen

You can change this now in User CP.
Reaction score
60
Btw, instead of ForGroup, you can also use this to avoid making a second function:

JASS:

loop
    set U = FirstOfGroup(G)
    exitwhen U = null
    //Your code here
    call GroupRemoveUnit(G, U)
endloop


But beware ... this empties your group! If you don't need your group again, it doesn't matter though.
 

newtonrox

Member
Reaction score
2
ok, thx man.

Well tonight I let my map run for 6 hours with the trigger enabled.
It didn't crash... But, when I close War3 and tested again the map, it crashed in one minute. Then i tried 3 more times, and it crashed again.

I don't know what the fu** is happening with my map >=(

Whoever figure out the problem will be in my map's credits when it's released XD
cuz practically it's the only thing that's left to do in my map besides making a system to set the alliances.

any idea?

this is the crash window log:

Program: c:\program files (x86)\warcraft iii\war3.exe
File: .\cmemblock.cpp
Line: 372

I would post the entire Error Log but it's too loooooooooooong(cat) XD



I was wondering if the order(placement) of the triggers, influences on anything. Like, when u call a trigger that comes after the calling trigger.
Might it cause any error? Even if the calling trigger parameters do not depend directly on the called trigger?

and here is the ability off trigger:

JASS:
//=======================  Filtro do GroupEnumUnitsInRect()==================//
function RetBool takes nothing returns boolean
return true
endfunction
//===========================================================================//





function Ability_Off_Seleciona takes nothing returns nothing
local unit U = GetEnumUnit()


if  ( IsUnitType(U, UNIT_TYPE_STRUCTURE) == false ) then 

    if ( GetUnitRace(U) == RACE_DEMON ) then    
       call UnitRemoveAbility( U,'A002')
    else   
       call UnitRemoveAbility( U,'A003')
    endif


endif

set U = null

endfunction



function Trig_Ability_Off_Actions takes nothing returns nothing
local boolexpr Bool = null


    set Bool = Condition(function RetBool)


    call GroupEnumUnitsInRect(udg_ALLMAP,udg_PlayableArea,Bool)            
    call ForGroup(udg_ALLMAP, function Ability_Off_Seleciona )
  
    call GroupClear(udg_ALLMAP)
    set Bool = null
           



endfunction

//===========================================================================
function InitTrig_Ability_Off takes nothing returns nothing
    set gg_trg_Ability_Off = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Ability_Off, function Trig_Ability_Off_Actions )
endfunction


it takes away the ability that has been granted by the first trigger.

I have a periodic event trigger that:
Runs the first trigger (Ability On)
waits N seconds
Runs the second trigger(Ability Off)

I still need help.
thx in advance!
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
I'm assuming you mean [ljass]GroupEnumUnitsInRect[/ljass].


Well, yeah. Dead units are units too!
 

newtonrox

Member
Reaction score
2
yeah that's what i meant (can't say the name of the functions by heart) XD
thx
i'll put a condition to check if the unit is alive before adding the ability!
 

newtonrox

Member
Reaction score
2
after some calculation, I discovered that the function UnitAddAbility() is called:
840 units * 4(calls)/minute = 3360calls/minute = 201.600 calls/hour

a periodic trigger calls it every 15s (for test's sake)
P.S: the 840 units are constant. If they die other units spawn at the base and go to the battle once again.

So, I was wondering that, if this function leaks a little and after 200k calls it crashes my game! (besides the UnitRemoveAbility() that is also called 200k times).
Is that possible?
cuz i've tried everything already.

my last try was this one:

JASS:
//=======================  Filtro do GroupEnumUnitsInRect()======================//
// Adds the Filter Unit to group udg_ALLMAP or to group udg_ALLMAP2 or to no group, depending on the conditions below:


function Filter_Ability_On takes nothing returns boolean
local unit F = GetFilterUnit()


if( GetUnitState(F, UNIT_STATE_LIFE) > 0 ) then


   if  ( GetUnitAbilityLevelSwapped('A01W',F ) > 0)  then
   set F = null
   return true
   else
       if ( GetUnitAbilityLevelSwapped('A01X',F ) > 0) then
          call GroupAddUnit(udg_ALLMAP2, F)
          set F = null
          return false
       endif
   endif

endif

set F = null
return false

endfunction

//===============================================================================//



//==================== Adds Skill A to ALLMAP group ============================//
function Add_Skill_A  takes nothing returns nothing

     call UnitAddAbility(GetEnumUnit(), 'A003')

endfunction
//=============================================================================//




//==================== Adds Skill B to ALLMAP2 group =========================//
function Add_Skill_B takes nothing returns nothing

     call UnitAddAbility(GetEnumUnit(), 'A002')

endfunction
//===========================================================================//




function Trig_Ability_On_Actions takes nothing returns nothing

      call GroupEnumUnitsInRect(udg_ALLMAP,udg_PlayableArea,Filter(function Filter_Ability_On) )
         
      call ForGroup(udg_ALLMAP, function Add_Skill_A )
      call ForGroup(udg_ALLMAP2, function Add_Skill_B )


      call GroupClear(udg_ALLMAP)
      call GroupClear(udg_ALLMAP2)

endfunction




//==========================================================================//
function InitTrig_Ability_On takes nothing returns nothing
    set gg_trg_Ability_On = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Ability_On, function Trig_Ability_On_Actions )
endfunction

PS: this time I used dummy abilities ('A01W' and 'A01X', based on Channel ability) as flags, instead of using race.

and it still crashed!
any more ideas? help... pls!
 

ZugZugZealot

New Member
Reaction score
33
I suppose it does having testing it. Not a problem I've ran into since I use unit stack methods instead of enumeration.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top