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

[JASS] Leaking? I don't think so...

Status
Not open for further replies.
Level 7
Joined
Dec 30, 2008
Messages
72
What is causing this remarkably strange problem

SOLVED

So the conclusion is... Avatar is buggy - don't use it
Use Channel instead ^_^

The title has now been changed from "Leaking? I don't think so..."
As my code was not leaking (well one minor leak that didn't actually influence anything)

After I use the ability there is a very noticable lag in obeying commands for the unit that cast the ability...

If someone could check my code and see if they know what is causing the problem, i would be most grateful ^_^

JASS:
function corpse_call_conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A01H'
endfunction

function unit_dead takes nothing returns boolean
    return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) <= 0
endfunction

function corpse_call_actions takes nothing returns nothing
    //Variables
    local unit Caster
    local group All
    local rect Map
    local effect EffectMid
    local effect EffectBot
    local effect EffectHead
    local string CorpseEffect
    
    //Preload Resources
    set CorpseEffect = "Abilities\\Spells\\Human\\Feedback\\ArcaneTowerAttack.mdl"
    call Preload(CorpseEffect)
    
    //Initialise
    set Caster = GetSpellAbilityUnit()
    set Map = bj_mapInitialPlayableArea
    set All = CreateGroup()
    call GroupEnumUnitsInRect(All, Map, Condition(function unit_dead))
    
    //Body of Ability
    set EffectBot = AddSpecialEffectTarget(CorpseEffect, Caster, "origin")
    set EffectMid = AddSpecialEffectTarget(CorpseEffect, Caster, "chest")
    set EffectHead = AddSpecialEffectTarget(CorpseEffect, Caster, "head")   
    set bj_groupCountUnits = 0
    call ForGroup(All, function CountUnitsInGroupEnum)
    call SetUnitState(Caster, UNIT_STATE_LIFE, GetUnitState(Caster, UNIT_STATE_LIFE)+(25*bj_groupCountUnits))
    
    call TriggerSleepAction(1.00)
    
    //Clean up
    call DestroyGroup(All)
    call DestroyEffect(EffectBot)
    call DestroyEffect(EffectMid)
    call DestroyEffect(EffectHead)
    set Caster = null
    set EffectBot = null
    set EffectMid = null
    set EffectHead = null
    set Map = null
    set All = null
    set CorpseEffect = null
endfunction


function AntiLeakFilterCorpseCall takes nothing returns boolean
    return true
endfunction

//===========================================================================
function InitTrig_Corpse_Call takes nothing returns nothing
    local trigger CorpseCall
    local filterfunc filter
    local integer index
    set CorpseCall = CreateTrigger(  )
    set filter = Filter(function AntiLeakFilterCorpseCall)
    set index = 0
    loop
        call TriggerRegisterPlayerUnitEvent(CorpseCall, Player(index), EVENT_PLAYER_UNIT_SPELL_CAST, filter)
        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    call TriggerAddCondition( CorpseCall, Condition( function corpse_call_conditions ) )
    call TriggerAddAction( CorpseCall, function corpse_call_actions )
    call DestroyFilter(filter)
    set CorpseCall = null
    set filter = null
endfunction

OKAY
Now after reading that let me point some things out
IT IS NOT THE ABILITY ITSELF WHICH LAGS
did you read that?
awesome!
Now read this...
IT IS THE COMMANDS ISSUED AFTER THE ABILITY HAS BEEN CAST WHICH LAG
did you read that?
Now re-read it just in case.
awesome!

#####
The preload tag is just there so that I know I need to include that resource when i do the init trigger.

*EDIT* I have rewritten the script to lower the amount of units in the group, just in case... but to no avail

same old problem
 
Last edited:
Level 9
Joined
Nov 28, 2008
Messages
704
That doesn't leak (as far as I'm aware).

JASS:
set Map = GetPlayableMapRect()
is pretty much useless. It simply returns bj_mapInitialPlayableArea, which you should use.

JASS:
    call DestroyFilter(filter)
    set filter = null

Your event uses that filter. I may be wrong, but I'm pretty sure you should not be destroying it. That *could* be your leak, because whenever it tries to use a dead filter, it may use a null one instead when it can't find that one, causing a leak. Remember, that filter is not used immediately, like it is when used in a GroupEnum. It is used later on.

Other then that, I have no idea. Perhaps DSG or Poot will grave us with an amazingly win answer.
 
Level 14
Joined
Nov 18, 2007
Messages
816
general things: dont destroy the rect. Youre destroying a global variable used during the next cast of that spell and by many triggers in GUI.
If you care enough, you should recycle groups (instead of destroying them).
Also, do the preloading of the effect in your InitTrig.

concerning your problem: I dont know what causes this. Try commenting out certain lines to isolate the bug. I think Id very much like to know about bugs in WC3.
 
Level 8
Joined
Aug 6, 2008
Messages
451
GroupEnum leaks with teporary group. You dont need DestroyGroup, just use one global group, created at map init for GroupEnum. Get GroupUtils system from wc3c.net script section. ( You should maybe also read that thread too )
 
Level 8
Joined
Aug 6, 2008
Messages
451
Actually no.

You dont loose anything, you just gain some speed, make GroupEnum stuff faster to type and fix one leak.
 
Level 7
Joined
Dec 30, 2008
Messages
72
Well, that would improve the leaklessness of the map, but as this is an ultimate and gets used max 30 times in a game, it's not to big of an issue atm

The problem is the lag after it has been cast once...
i don't think one leak will cause that much lag????

###
I did have a look, but unless you link me i'm probably not going to be able to find it with such little info... wc3net is enormous

#edit#
Oh, and this is a jass spell... not vjass
 
Level 13
Joined
May 11, 2008
Messages
1,198
does it lag the second time you cast it? if not, thenr your problem is you're not preloading the ability. do that, and then you're ok to go. basically preloading the ability will put the loading time for the ability at the map initialization instead of in the middle of the game.
 
Level 7
Joined
Dec 30, 2008
Messages
72
lol, you guys went off topic a bit =P
yeah, well, 0 should catch most, if not all corpses...

anyway, thats not a major concern... the major concern IS in fact that command lag, caus that could cause problems... well it will cause problems.

@Mooglefrooglian
No, thats a wrapper function that calls the getstate function... there is no flag given to a unit
#Edit#
@Mooglefrooglian
Oh, i get what you were saying, but no... that has no relevance whatsoever... no spam please
 
Level 7
Joined
Dec 30, 2008
Messages
72
Lol... can i just make this clear

THE SPELL DOES NOT LAG ON CAST

Thankyou, now please read what is lagging

The commands issued after the cast are lagging, i.e. movement commands, attack commands... it is only after I use this ability and I am trying to determine what is causing this...
 
Level 7
Joined
Dec 30, 2008
Messages
72
@ Element of Water and anyone else who doesn't actually read

Right, i'm just going to jump in here and say...
i really don't know what to say.

YOU ARE ILLETERATE.. READ PLEASE.. like the post just above purples last one. *highly audible sigh* why do people just assume they know what the problem is..
If you had actually read a little you would have discovered that the preload tag i wrote in there is to remind me that this ability needs preloading... and that it IS NOT THE ABILITY THAT IS LAGGING RAWR!!!!! actually, i'm just going to go and modify the OP and make it a tad bit clearer T_T
 
Level 7
Joined
Dec 30, 2008
Messages
72
Not really... just that if you had bothered to read a tad, you would have discovered the answer just two posts down from the top.. which shows you didn't actually read it. Although i must thankyou, caus it prompted me to change the OP to ensure I don't have to keep correcting people who mis-read it.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
My evidence supporting this "myth" was with trees. When they die they leave stumps as we all know which still can be manipulated as destrucables. However I noticed my spell bugging when I got a mortar to kill some trees which were used in it, as the trees would appear dead yet would still be counted as alive (although there was a check for if their HP was 0) and would remain "living" even if more damage was done to the stump. Some trees ofcourse died perfectly fine as the last hit must have reduced the HP below 0 which is then made to 0. When using less than 0.405 as the check of weather the tree was alive or not, the bug completly dissapeared and all trees which were killed were known as killed and all trees which were alive were known as alive.

Thus I can garuntee you with destructables it does exist, however whether it is 0.405 or some other number I am not sure. 0.405 seems to work prefectly though as I did not get any other bugs forming where trees were alive but known as dead or when trees were dead but known as alive.
 
Level 7
Joined
Dec 30, 2008
Messages
72
lol, why is it always in my threads =P

BREAK THOUGH

I discovered the problem is with the base ability (after hours of painful testing, i moved onto the next ability based it of avatar and same thing happened)

So the conclusion is... Avatar is buggy - don't use it
Use Channel instead ^_^
 
Status
Not open for further replies.
Top