• 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] struct allocation...

Status
Not open for further replies.
Level 8
Joined
Aug 4, 2006
Messages
357
Hey guys I need some vJass experts to help me out here. I am stumped. So, basically I have the following code in one trigger:
JASS:
library test
    //! textmacro Pair takes type, listType
    struct $listType$Pair
        $type$ a
        $type$ b
    endstruct
    //! endtextmacro
    
    //! runtextmacro Pair("integer", "Integer")
    //! runtextmacro Pair("real", "Real")
endlibrary
and I have another library that I want to be able to use different types of "Pair"s:
JASS:
library test2 requires test
    
    struct twoPairs
        private IntegerPair p1 = IntegerPair.create()
        private RealPair p2 = RealPair.create()
    endstruct
    
endlibrary
However when I save the map, I get compile errors saying that it can't find the RealPair allocate function. For some reason, it creates the IntegerPair allocate/destroy functions before the twoPairs allocate/destroy functions before the RealPair allocate/destroy functions. It's completely ignoring the requirements of the libraries and just placing the struct allocate functions in random order. See the attached screenshot.
 

Attachments

  • struct allocation.JPG
    struct allocation.JPG
    162.3 KB · Views: 108
Level 8
Joined
Aug 4, 2006
Messages
357
Well that's pretty lame...
So would this be the solution?
JASS:
library test2 requires test
    
    struct twoPairs
        IntegerPair p1
        RealPair p2
    
        static method create takes nothing returns thistype
            local thistype tp = thistype.allocate()
            set tp.p1 = IntegerPair.create()
            set tp.p2 = RealPair.create()
            return tp
        endmethod
    endstruct
endlibrary
 
Status
Not open for further replies.
Top