structs.

Vexorian

Why no custom sig?
Reaction score
187
Yes, structs are much faster than gamecache.

Yes, structs are much Safer than gamecache

Yes, structs are a little less dynamic than gamecache.

Yes, structs are easier to use than gamecache.

Yes, to be used effectively you need a hacked WE.

Code:
struct unitdata
    integer kool =0
    real   test = 0.0
endstruct




function WhenAunitiscreated takes unit u returns nothing
 local unitdata k=unitdata.create()

    call SetUnitUserData(u,k)
endfunction

function unitSetKool takes unit u, integer newkool returns nothing
 local unitdata k=GetUnitUserData(u)
    set k.kool = newkool
endfunction


function unitremoveKool takes unit u returns nothing
 local unitdata k=GetUnitUserData(u)
    call UnitRemoveAbility( u, k.kool)
endfunction


function beforetheunitdies takes unit u returns nothing
 local unitdata k=GetUnitUserData(u)

    //deallocate the instance, there is a limit of 8190 instances per struct type.
     call k.destroy()

endfunction

http://www.wc3campaigns.net/showthread.php?t=88142
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
This is madness :D


> structs are easier to use than gamecache.

Hm... are they?
I guess that only applies if you already used them in some real programming language.

Otherwise you still need to "learn them".


Actually, the example in the thread you linked to is much clearer than the one posted here.


Definitely interesting.
 

Vexorian

Why no custom sig?
Reaction score
187
structs are still easier to use than gamecache because it makes more sense to use them to store stuff in memory than gamecache which was designed for the hard drive.
 

Chocobo

White-Flower
Reaction score
409
structs are still easier to use than gamecache because it makes more sense to use them to store stuff in memory than gamecache which was designed for the hard drive.

Because it uses Variables instead of Game Cache, which is slower than HandleVars2 (Variables).


This uses Custom Unit's Value?
 
C

Capt Griffen

Guest
Doesn't have to use custom unit values, but that would be the easiest way to attach the struct to a unit. The loss is nothing, as you add more integers onto the unit.
 
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