HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Crash only on Multiplayer

02-01-2009, 07:55 PM#1
Bobo_The_Kodo
Ok i got a simple spell, and for some reason, it crashes after awhile on multiplayer... And its 100% this spell because i disabled it and the crashes stopped

Collapse JASS:
scope IncendiaryRounds

    globals
        private constant integer Rawcode = 'A00N'
        
        private constant integer AuraRawcode = 'A00O'
        private constant integer BuffRawcode = 'B005'
        
        private constant real Duration = 10
    endglobals
    
    private struct Data
        unit caster
    endstruct
    
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == Rawcode
    endfunction
    
    private function Loop takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local Data dat = GetTimerData( t )
        call UnitRemoveBuff( dat.caster, AuraRawcode, BuffRawcode )
        call ReleaseTimer( t )
        call dat.destroy()
    endfunction

    private function Actions takes nothing returns nothing
        local unit caster = GetTriggerUnit()
        local timer t = NewTimer()
        local Data dat = Data.create()
        call UnitAddBuff( caster, AuraRawcode )
        set dat.caster = caster
        call SetTimerData( t, dat )
        call TimerStart( t, Duration, false, function Loop )
        set caster = null
    endfunction

    public function InitTrig takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddAction( t, function Actions )
        call TriggerAddCondition( t, Condition( function Conditions ) )
    endfunction
    
endscope

Collapse JASS:
library Abilities

    function UnitAddBuff takes unit whichUnit, integer id returns nothing
        call UnitAddAbility( whichUnit, id )
    endfunction
    
    function UnitRemoveBuff takes unit whichUnit, integer id, integer buffId returns nothing
        call UnitRemoveAbility( whichUnit, id )
        call UnitRemoveAbility( whichUnit, buffId )
    endfunction

endlibrary
02-04-2009, 06:02 AM#2
Blackroot
This looks wrong:

Collapse JASS:
        set caster = null

Never null things you aren't removing, especially if you're passing them in a struct.

If that doesn't do it, consider checking if SetTimerData is exceeding it's stack capabilities (if it has them)

Otherwise I don't see anything wrong.
02-04-2009, 01:33 PM#3
Anitarf
Nonsense, he should set caster to null to avoid leaks.
TimerUtils also shouldn't crash the game if they fail.

Are you certain this spell is the problem? It looks very simple. Why did you decide to turn of this particular spell and not something else?
02-04-2009, 03:07 PM#4
DioD
you shoud null locals in every case expect fully dynamic timers.

you shoud not touch struct data on your own if dont know what are you doing.

there is only one way to crush map using this, direct call of timer callback.