System Advanced Indexing & Data Storage

Bribe

vJass errors are legion
Reaction score
67
JASS:
//
                // Fire things.
                call TriggerEvaluate(OnEnter)
                
            else
                
                // The unit did not pass the filters, so does not need to be auto indexed.
                // However, for certain AIDS structs, it may still require indexing.
                // These structs may index the unit on their creation.
                // We flag that an index must be assigned by setting the current index to 0.
                set ARStackIndex[ARStackLevel]=0
                
                // Fire things.
                call TriggerEvaluate(OnEnter)


Err... add this to the list. The second OnEnter, by your description, should be OnEnterAllocated. As of now, OnEnterAllocated is never evaluated. No lie.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Err... add this to the list. The second OnEnter, by your description, should be OnEnterAllocated. As of now, OnEnterAllocated is never evaluated. No lie.
Dunno what list you mean, but nice spot. It makes no practical difference, but I guess I'll intend to change that over when I update it. It's just a dumb efficiency tweak. :)
 

SanKakU

Member
Reaction score
21
Dunno what list you mean, but nice spot. It makes no practical difference, but I guess I'll intend to change that over when I update it. It's just a dumb efficiency tweak. :)

not so sure. anyway, jesus4lyf, or bribe, have you figured out yet why that spell which isn't even used causes aids to go wonky?
 

tooltiperror

Super Moderator
Reaction score
231
So, I'm wondering what I should be doing instead of using array members. The documentation said I can't use arrays as members, so should I be using globals outside the struct, or is there a better way?
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
So, I'm wondering what I should be doing instead of using array members. The documentation said I can't use arrays as members, so should I be using globals outside the struct, or is there a better way?

A linked list is an alternative.
 

tooltiperror

Super Moderator
Reaction score
231
No, I mean an example of using a Linked List with AIDS instead of an array.
 

Bribe

vJass errors are legion
Reaction score
67
I used a 3-D array in conjunction with AIDS in the past (using hashtables, of course), so trust me, anything can be done. What do you want to accomplish?
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
No, I mean an example of using a Linked List with AIDS instead of an array.

Exactly how detailed..?

JASS:
struct Dummy
    unit whichUnit
    Dummy next
endstruct

struct UnitSpellThing extends array

    Dummy fireRingDummies

    //! runtextmacro AIDS()

endstruct


Essentially, you would create a local Dummy variable when you wanted to iterate through the Dummies, and fireRingDummies would refer to the first dummy in the list of dummies. The other dummies are linked to the first one, as fireRingDummies.next, fireRing Dummies.next.next ... etc., until .next == Dummy(0).

To put it simply, Linked Lists are a different way of iterating through data sets, but if you HAVE to have the same type of usage as an array in an AIDS struct (which would only be the case if you had extraordinarily large data sets), go with a hashtable.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
    //! textmacro AIDS
        // This magic line makes default methods get called which do nothing
        // if the methods are otherwise undefined.
        
        //-----------------------------------------------------------------------
        // Gotta know whether or not to destroy on deallocation...
        private boolean AIDS_instanciated
        
        //-----------------------------------------------------------------------
        static method operator[] takes unit whichUnit returns thistype
            return GetUnitId(whichUnit)
        endmethod
        
        method operator unit takes nothing returns unit
            // Allows structVar.unit to return the unit.
            return GetIndexUnit(this)
        endmethod
        
        //-----------------------------------------------------------------------
        method AIDS_addLock takes nothing returns nothing
            call AIDS_AddLock(this)
        endmethod
        method AIDS_removeLock takes nothing returns nothing
            call AIDS_RemoveLock(this)
        endmethod
        
        //-----------------------------------------------------------------------
        
        static if thistype.AIDS_onCreate.exists then
            private static method AIDS_onEnter takes nothing returns boolean
                // At this point, the unit might not have been assigned an index.
                static if thistype.AIDS_filter.exists then
                    if thistype.AIDS_filter(AIDS_GetEnteringIndexUnit()) then
                        // Flag it for destruction on deallocation.
                        set thistype(AIDS_GetIndexOfEnteringUnit()).AIDS_instanciated=true
                        // Can use inlining "Assigned" function now, as it must be assigned.
                        call thistype(AIDS_GetIndexOfEnteringUnitAllocated()).AIDS_onCreate()
                    endif
                else
                    // Flag it for destruction on deallocation.
                    set thistype(AIDS_GetIndexOfEnteringUnit()).AIDS_instanciated=true
                    // Can use inlining "Assigned" function now, as it must be assigned.
                    call thistype(AIDS_GetIndexOfEnteringUnitAllocated()).AIDS_onCreate()
                endif
                    
                return false
            endmethod
        
            private static method AIDS_onEnterAllocated takes nothing returns boolean
                // At this point, the unit must have been assigned an index.
                static if thistype.AIDS_filter.exists then
                    if thistype.AIDS_filter(AIDS_GetEnteringIndexUnit()) then
                        // Flag it for destruction on deallocation. Slightly faster!
                        set thistype(AIDS_GetIndexOfEnteringUnitAllocated()).AIDS_instanciated=true
                        // Can use inlining "Assigned" function now, as it must be assigned.
                        call thistype(AIDS_GetIndexOfEnteringUnitAllocated()).AIDS_onCreate()
                    endif
                else
                    // Flag it for destruction on deallocation. Slightly faster!
                    set thistype(AIDS_GetIndexOfEnteringUnitAllocated()).AIDS_instanciated=true
                    // Can use inlining "Assigned" function now, as it must be assigned.
                    call thistype(AIDS_GetIndexOfEnteringUnitAllocated()).AIDS_onCreate()
                endif
                
                return false
            endmethod
        endif
        
        static if thistype.AIDS_onDestroy.exists then
            private static method AIDS_onDeallocate takes nothing returns boolean
                if thistype(AIDS_GetDecayingIndex()).AIDS_instanciated then
                    call thistype(AIDS_GetDecayingIndex()).AIDS_onDestroy()
                    // Unflag destruction on deallocation.
                    set thistype(AIDS_GetDecayingIndex()).AIDS_instanciated=false
                endif
                
                return false
            endmethod
        endif
        
        //-----------------------------------------------------------------------
        private static method onInit takes nothing returns nothing
            static if thistype.AIDS_onCreate.exists then
                call AIDS_RegisterOnEnter(Filter(function thistype.AIDS_onEnter))
                call AIDS_RegisterOnEnterAllocated(Filter(function thistype.AIDS_onEnterAllocated))
            endif
            
            static if thistype.AIDS_onDestroy.exists then
                call AIDS_RegisterOnDeallocate(Filter(function thistype.AIDS_onDeallocate))
            endif
            
            // Because I robbed you of your struct's onInit method.
            static if thistype.AIDS_onInit.exists then
                call thistype.AIDS_onInit()
            endif
        endmethod
    //! endtextmacro

A slightly more efficient textmacro. :D
 

Jesus4Lyf

Good Idea™
Reaction score
397
A slightly more efficient textmacro. :D
Noted. And I actually always intended not to call the methods if they didn't exist, but at the time this was developed, that feature did not work. :)

Haven't tested it or anything, but maybe one day I'll take a look at it.. :thup:
 

Laiev

Hey Listen!!
Reaction score
188
AIDS Struct just work for unit that will enter in map, has some way to make it work for placed units?
 

Laiev

Hey Listen!!
Reaction score
188
Because this I ask:
JASS:
//          - AIDS structs cannot be created or destroyed manually. Instead, they
//            are automatically created when an appropriate unit enters the map.


hmm... so I think I'm doing something wrong because for some reason, units placed in my map just don't set the variable inside the onCreate function...

also entering units do (I add just a TimedEffect on unit when the struct is created, just for test)


the problem may be caused because some struct initialize before others and set variable are slowly then initialize struct?

because... i do something like this:

JASS:
//in some library in the initializer function:
set id = 'U001'
set data d = data.Register(id)
set d.id

//then in the struct
method AIDS_onCreate ...
    local data d = GetId(.unit)
    set .id = d.id


some problem here?
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
It's not "speed" it's "order initialisation".
Because one day grim001 asked for a special feature, and Vexorian doesn't support vJass anymore now module initializers are running before any other initializers (library,scope,struct).
It still follow the library depencies but modules initializers are done before all other ones.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top