- Joined
- Sep 4, 2007
- Messages
- 407
Ok, i need a leak check for jass... xD check this out:
This is a cluster organizer (there are more triggers for such, but i'll only put this one, if i solve this one, i solve the rest.) basically it will send units from a cluster with more than 5 untis to a cluster with less than that. It is MUI and stuff. A00X is an dummy ability I use to separate the klusters, it has like 100 levels (100 clusters are possible). This trigger has other effects but i'll only exeplain if needed to =). help?
since there are so many loops, i suppose it will leak when changin the loop integer number and the variables are not destroy or cleaned. the problem is, if I destroy the variables I won't be able to use them again in the next integer number of the loop. got it? how do I solve this?
Oh, and any help improving the effect of it will be welcome with +rep
This is a cluster organizer (there are more triggers for such, but i'll only put this one, if i solve this one, i solve the rest.) basically it will send units from a cluster with more than 5 untis to a cluster with less than that. It is MUI and stuff. A00X is an dummy ability I use to separate the klusters, it has like 100 levels (100 clusters are possible). This trigger has other effects but i'll only exeplain if needed to =). help?
JASS:
function Trig_SP_TA_Func001A takes nothing returns boolean
return ( GetUnitAbilityLevelSwapped('A00X', GetFilterUnit()) == GetForLoopIndexB())
endfunction
function Trig_SP_TA_Func001B takes nothing returns boolean
return ( GetUnitAbilityLevelSwapped('A00X', GetFilterUnit()) == GetForLoopIndexA())
endfunction
function Trig_SP_TA_Actions takes nothing returns nothing
local unit newpackunit
local group packs
local group overpack
local integer LoopD
local integer xlvl
local integer packnumb
set LoopD = 1
loop
exitwhen LoopD > 12
if (udg_CC_SocialBehavior[LoopD] == 3) then
set bj_forLoopBIndex = 1
set bj_forLoopBIndexEnd = 10
loop
exitwhen bj_forLoopBIndex > bj_forLoopBIndexEnd
set packs = GetUnitsOfPlayerMatching(ConvertedPlayer(LoopD), Condition(function Trig_SP_TA_Func001A))
if (GetBooleanAnd((CountUnitsInGroup(packs) < 5), (CountUnitsInGroup(packs) != 0 ))) then
set packnumb = CountUnitsInGroup(packs)
set xlvl = GetForLoopIndexB()
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 10
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
set overpack = GetUnitsOfPlayerMatching(ConvertedPlayer(LoopD), Condition(function Trig_SP_TA_Func001B))
if (CountUnitsInGroup(overpack) > 5 ) then
set newpackunit = GroupPickRandomUnit(overpack)
call SetUnitAbilityLevelSwapped( 'A00X', newpackunit, xlvl )
if ( CountUnitsInGroup(packs) >= 5 ) then
set bj_forLoopAIndex = 10
set newpackunit = null
else
endif
else
if (CountUnitsInGroup(overpack) == (5 - packnumb)) then
set newpackunit = GroupPickRandomUnit(overpack)
call SetUnitAbilityLevelSwapped( 'A00X', newpackunit, xlvl )
if ( CountUnitsInGroup(packs) >= 5 ) then
set bj_forLoopAIndex = 10
set newpackunit = null
else
endif
else
endif
endif
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
else
endif
set bj_forLoopBIndex = bj_forLoopBIndex + 1
endloop
else
endif
set LoopD = LoopD + 1
endloop
set newpackunit = null
call DestroyGroup(packs)
call DestroyGroup(overpack)
endfunction
//===========================================================================
function InitTrig_SP_TogetherAdjustment takes nothing returns nothing
set gg_trg_SP_TogetherAdjustment = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_SP_TogetherAdjustment, 0.20 )
call TriggerAddAction( gg_trg_SP_TogetherAdjustment, function Trig_SP_TA_Actions )
endfunction
since there are so many loops, i suppose it will leak when changin the loop integer number and the variables are not destroy or cleaned. the problem is, if I destroy the variables I won't be able to use them again in the next integer number of the loop. got it? how do I solve this?
Oh, and any help improving the effect of it will be welcome with +rep