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

[Solved] LinkedList error

Status
Not open for further replies.
Level 6
Joined
Oct 23, 2011
Messages
182
is there a problem with this list?

JASS:
struct PercentMod extends array
    
        thistype prev
        thistype next
        real percent
        
        static integer index = 0
        
        method destroyHead takes nothing returns nothing
            set .next.prev = thistype(0).prev
            set thistype(0).prev = this
        endmethod
        
        method destroy takes nothing returns nothing
            set .prev.next = .next
            set .next.prev = .prev
            set .prev = thistype(0).prev
            set thistype(0).prev = this
        endmethod
        
        static method allocate takes nothing returns thistype
            local thistype this = thistype(0).prev
            
            if this == 0 then
                set index = index + 1
                set this = index
            else
                set thistype(0).prev = .prev
            endif
            
            return this
        endmethod
        
        static method createHead takes nothing returns thistype
            local thistype this = thistype.allocate()
            
            set .prev = this
            set .next = this
            
            return this
        endmethod
        
        static method create takes thistype head, real v returns thistype
            local thistype this = thistype.allocate()
            
            set .prev = head.prev
            set head.prev.next = this
            set head.prev = this
            set .next = head
            set .percent = v / 100.
            
            return this
        endmethod
    endstruct
 
Last edited:
Status
Not open for further replies.
Top