• 🏆 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!

[vJASS] Fucked up my double linked index help!

Status
Not open for further replies.
Level 15
Joined
Nov 30, 2007
Messages
1,202
JASS:
private struct UnitList 
        thistype next
        thistype prev
        unit u
        real x
        real y
        texttag txt
        static integer count = 0
        static trigger t = CreateTrigger()
        
        static method add takes unit u, string name returns nothing 
            local thistype new = thistype.allocate()
            local integer id = GetHandleId(u)
            call BJDebugMsg("added")
            call SaveInteger(hash, id, 0, new)
            call SaveBoolean(hash, id, 1, true)
            set new.u = u
            set new.prev = thistype(0)
            set new.next = thistype(0).next
            set new.next.prev = new
            set thistype(0).next = new
            set thistype.count = thistype.count + 1
            set new.txt = CreateTextTag()
            call SetTextTagText(new.txt, name, 10.)
            call SetTextTagVisibility(new.txt, true)
            if thistype.count == 1 then 
                call EnableTrigger(thistype.t)
            endif
        endmethod
        
        static method remove takes unit u returns nothing
            local integer id = GetHandleId(u)
            local thistype old = LoadInteger(hash, id, 0) 
            call FlushChildHashtable(hash, id) 
            set old.next.prev = old.prev
            set old.prev.next = old.next
            set thistype.count = thistype.count - 1
            call DestroyTextTag(old.txt)
            if thistype.count == 0 then 
                call DisableTrigger(thistype.t)
            endif
            call old.deallocate()
        endmethod
        
        static method periodic takes nothing returns nothing
            local UnitList index = UnitList(0).next
            local real uX
            local real uY
            loop
                exitwhen index.u == null
                set uX = GetUnitX(index.u)
                set uY = GetUnitY(index.u)
                if not (index.x == uX and index.y == uY) then 
                    set index.x = uX
                    set index.y = uY
                    call SetTextTagPosUnit(index.txt, index.u, 100)
                endif
                set index = index.next
            endloop
        endmethod
        
        static method onInit takes nothing returns nothing 
            call TriggerRegisterTimerEvent(thistype.t, 0.1, true)
            call TriggerAddAction(thistype.t, function thistype.periodic)
            call DisableTrigger(thistype.t)
        endmethod
    endstruct

- I want to attach a name to a unit but no floating text appears.

Nobody? I think it might be the floating texts not working properly...
 
Last edited by a moderator:
Status
Not open for further replies.
Top