T32 Question

Risen

New Member
Reaction score
4
When you "implement T32x", it adds this function.

JASS:
function s__structname_T32x__PeriodicLoop takes nothing returns boolean
        local integer this=s__structname_T32x__next[(0)]
        loop
            exitwhen this == 0
            call s__structname_ funcname(this)
            set this=s__structname_T32x__next[this]
        endloop
        return false
endfunction


My question: does "this" need to point to an array?
 

tooltiperror

Super Moderator
Reaction score
231
It doesn't point to an array. Integers are not pointers in JASS.

It's taking the value of the data in the memory slot of [ljass]s__structname_T32x__next[(0)][/ljass].

Structs are arrays, after all.
 

Risen

New Member
Reaction score
4
Wouldn't replacing [ljass]s__structname_T32x__next[(0)] [/ljass] with [ljass]s__structname_T32x__next [/ljass] be more efficient?

Or is it even possible?
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Wouldn't replacing [ljass]s__structname_T32x__next[(0)] [/ljass] with [ljass]s__structname_T32x__next [/ljass] be more efficient?

Or is it even possible?

I'm not sure what you mean. s__structname_T32x__next is an array, so it has to have the [0] index included.
 

Sevion

The DIY Ninja
Reaction score
413
No, that would be impossible.

[ljass]s__structname_T32x__next[(0)][/ljass] points to a specific integer. [ljass]s__structname_T32x__next[this][/ljass] points to this instance's next struct.

I.E.

JASS:
struct a
    thistype next
    thistype prev

    public static method create ... returns thistype
        local thistype this = thistype.allocate()

        // link the list
        set thistype(0).next.prev = this
        set this.next = thistype(0).next
        set thistype(0).next = this
        set this.prev = thistype(0)

        return this
    endmethod
endstruct


Would compile to something resembling this:

JASS:
integer array s__a
integer array s__a__next
integer array s__a__prev

function s__a_create ... returns integer
    set s__a[s__a__allocate_count] = new struct // however JH does this
    
    // Watch this part (link the list)
    set s__a__prev[s__a__next[(0)]] = s__a[s__a__allocate_count]
    set s__a__next[s__a[s__a__allocate_count]] = s__a__next[(0)]
    set s__a__next[(0)] = s__a[s__a__allocate_count]
    set s__a__prev[(0)] = s__a[(0)]

    return s__a[s__a__allocate_count]
endfunction


Thus, you can see that each struct is just an integer array with the struct instance number being the array position.

Because of this, each struct "member" has to be an array. That means that having [ljass]s__structname_T32x__next[/ljass] would not work.
 

Risen

New Member
Reaction score
4
Ah nevermind, I missed another function where the array was actually being used. :/
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top