• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] strange handleid bug

Status
Not open for further replies.
Level 6
Joined
Oct 23, 2011
Messages
182
Very strange handle ID bug

My trigger's handleId is changed when it's fired and I retrieve the id

It is very strange.
What's even more strange is that all triggers created seem to have same handle id when I use GetHandleId(GetTriggeringTrigger())

Seems to be related with the post below
http://www.hiveworkshop.com/forums/world-editor-help-zone-98/really-weird-trigger-handle-bug-187468/

JASS:
        private method onEn takes nothing returns boolean
            local thistype this = ...
            
            set .trg = CreateTrigger()
            set data[GetHandleId(.trg)] = this
                    
            call BJDebugMsg(I2S(GetHandleId(.trg)))
                    
            call TriggerRegisterUnitInRange(.trg, .fx.dummy, 200, null)
            call TriggerAddCondition(.trg, Condition(function thistype.onEnter))
            
            return false
        endmethod
        
        private static method onEnter takes nothing returns boolean
            local thistype this = data[GetHandleId(GetTriggeringTrigger())]
            
            call BJDebugMsg(I2S(GetHandleId(GetTriggeringTrigger()))) // ITS DIFFERENT
            
            return false
        endmethod
 
Last edited:
If you give us the rest of the code, we might be able to determine the problem.
According to my test:

JASS:
struct Demo extends array

    private static method action takes nothing returns nothing
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, I2S(GetHandleId(GetTriggeringTrigger())))
    endmethod

    private static method onInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerAddAction(t, function thistype.action)
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, I2S(GetHandleId(t)))
        call TriggerExecute(t)
        set t = null
    endmethod
    
endstruct

Nothing seems to be wrong.
 
Level 6
Joined
Oct 23, 2011
Messages
182
JASS:
scope BoomTrap

    private struct Data extends array
    
        thistype next
        thistype prev
        unit dummy
        trigger trg
        integer i
        
        static Table data
    
        implement CT32
        
            local thistype this = thistype(0).next
            local integer lv
            local integer id
            
            loop
                exitwhen 0 == this
                
                set .i = .i - 1
                
                if .i >= 0 then
                    set .next.prev = .prev
                    set .prev.next = .next
                    
                    set .trg = CreateTrigger()
                    set data[GetHandleId(.trg)] = this

                    call BJDebugMsg(I2S(GetHandleId(.trg)))
                    
                    call TriggerRegisterUnitInRange(.trg, .dummy, 200, null)
                    call TriggerAddCondition(.trg, Condition(function thistype.onEnter))
                endif
                
                set this = .next
            endloop
        
        implement CT32End
        
        private static method onEnter takes nothing returns boolean
            local thistype this = data[GetHandleId(GetTriggeringTrigger())]
            
            call BJDebugMsg(I2S(GetHandleId(GetTriggeringTrigger())))
            
            return false
        endmethod
        
        private static method onCast takes nothing returns boolean
            local unit fx = CreateUnit(Player(0), 'hfoo', 0, 0, 0)
            local thistype this = GetUnitId(f.dummy)
            
            set .next = thistype(0).next
            set .prev = 0
            set thistype(0).next.prev = this
            set thistype(0).next = this
            
            set .dummy = fx
            set .i = 255
            
            return false
        endmethod
            
        private static method onInit takes nothing returns nothing
            set data = Table.create()
            
            call RegisterSpellEffectEvent('A06G', function thistype.onCast)
        endmethod
    endstruct
    
endscope
 
Last edited:
Pro-tips:

  • Don't use CT32, use CTL. That way, this wouldn't run with 0 instances on it.
  • Using CTL instead of CT32 wouldn't require you to manage the Linked list, you would just need to call thistype.create() and that would return an allocated instance along with registering that instance to the list.

edit
Okay, a possible solution: Move onEnter above the loop. (top of the struct, under the globals.)
 
Status
Not open for further replies.
Top