does still anyone use kattana's system?

Trollvottel

never aging title
Reaction score
262
JASS:
I use a static timer for attaching to timers.
PUI for unit attaching.


How to attach to timers with a static timers? :p i guess you mean a struct stack?

I also use a struct stack and not gamecache for timers and PUI for units. BUT

JASS:
Also, take into consideration that most current attachment systems were actually created to replace LHV, because it was slow and unsafe.


Err, its unsafe if you attach HANDLES to someting because you need I2H to Get Them.
And it isnt really slow...

Look if game cache is 4 times slower than arrays and you use it once its like:

local Data d = GHInt(GetExpiredTimer())

that would take about (actually less) as much time as (because struct members are arrays, too):

local Data d = GetCSData(GetExpiredTimer())
local real x
set x = d.a
set x = d.b
set x = d.c

so if you have a complex function etc with more than 100 lines it would not slow down your function at all. And less complex function would not slowed down because of this either.
of course attaching to timers is a bit silly because of several timers running instead of one but if you attach to triggers or dialoques it should not be too bad...

So all in all you can use this system if you want, you wont notice any performance differences if you use it at the right place. Of course there are some slightly faster systems you can use which may have a better interface but if you like LHV, just use it.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
I use my attach system^^, HVAS (HASHed variables attach system). The Old version i created is based on I2H, nw i already changed to store handle directly. I dunno I2H is bad or what, but I2H works in my old version's attach system without any problem.

Kattana's system had limitation -> Only can store 255 elements and slower than others system.

I had Kattana system in my TD map, but the game soon crash because my tower cast the custom spell massly and the game cache soon full up.
 

Azlier

Old World Ghost
Reaction score
461
A game cache doesn't fill up(?), but there is indeed a limit on game caches. 256. You are mistaken.

And yes, I2H is bad. What happens if you cast an integer to an invalid handle? Oh noes. What you gonna do nao?
 

Vexorian

Why no custom sig?
Reaction score
187
I use my attach system^^, HVAS (HASHed variables attach system). The Old version i created is based on I2H, nw i already changed to store handle directly. I dunno I2H is bad or what, but I2H works in my old version's attach system without any problem.

Kattana's system had limitation -> Only can store 255 elements and slower than others system.

I had Kattana system in my TD map, but the game soon crash because my tower cast the custom spell massly and the game cache soon full up.
I2H is evil in epic proportions. Very evil, VERY evil . Not to mention it is useless.

A version of Kattana's handle vars without the stuff that attach handles is likely to be 'safe' (for limited definitions of safe), it could/should be used to port old code so it stops using the I2H stuff and uses structs instead, if the spell was coded right it is easy to do it. I made CSSafeCache as a replacement for CSCache for the same reason.

However, gamecache is a little problematic to use on units, I use Table to attach on units only for things like channeled spells in which you are sure that there was a "Starts" event before the "stops" event. Otherwise I am afraid you need indexing or PUI or to use a group-trick, the group trick however would just prevent bad reads but not leaks caused by removing units.

Table is mostly meant for things like:
JASS:
     set typetag = Table.create()
     set 'I000':typetag = 2
     set 'I001':typetag = 3
     set 'I002':typetag = 3
     set 'I003':typetag = 2

The sort of thing gamecache does very well.

The design on Kattana's / CSCache is very bad and ugly, performance is not really that much of an issue, specially if you use them to just attach a struct. This limits to a single gamecache read per event which really isn't that much.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
This is my newest attaching system. Try and tell me any Pros and Cons.

JASS:

//==========================================================================================
//      HASHed Variables Attaching System (HVAS) by kingking
//      v3.1
//      Credits to me. ^^
//==========================================================================================
//      This is a attaching system.
//      
//      Supported handles : 
//      All, except TextTags
//
//      Quick functions view : 
//      =======================================
//      a) These functions attaches variables.
//      =======================================
//      SetHVASHandleA(Supported handles, Handle you want to attach)
//      SetHVASHandleB(Supported handles, Handle you want to attach)
//      SetHVASHandleC(Supported handles, Handle you want to attach)
//      SetHVASHandleD(Supported handles, Handle you want to attach)
//      SetHVASHandleE(Supported handles, Handle you want to attach)
//
//      SetHVASIntA(Supported handles, Integer/Struct you want to attach)
//      SetHVASIntB(Supported handles, Integer/Struct you want to attach)
//      SetHVASIntC(Supported handles, Integer/Struct you want to attach)
//      SetHVASIntD(Supported handles, Integer/Struct you want to attach)
//      SetHVASIntE(Supported handles, Integer/Struct you want to attach)
//
//      ***Use SetHVASInt to attach struct.
//
//      SetHVASRealA(Supported handles, Real you want to attach)
//      SetHVASRealB(Supported handles, Real you want to attach)
//      SetHVASRealC(Supported handles, Real you want to attach)
//      SetHVASRealD(Supported handles, Real you want to attach)
//      SetHVASRealE(Supported handles, Real you want to attach)
//
//      SetHVASBooleanA(Supported handles, Boolean you want to attach)
//      SetHVASBooleanB(Supported handles, Boolean you want to attach)
//      SetHVASBooleanC(Supported handles, Boolean you want to attach)
//      SetHVASBooleanD(Supported handles, Boolean you want to attach)
//      SetHVASBooleanE(Supported handles, Boolean you want to attach)
//      
//
//      ===========================================
//      b) These function return attached variables
//      ===========================================
//      1) Returns integer / struct
//      GetHVASIntA(Supported handles)
//      GetHVASIntB(Supported handles)
//      GetHVASIntC(Supported handles)
//      GetHVASIntD(Supported handles)
//      GetHVASIntE(Supported handles)
//
//      2) Returns real
//      GetHVASRealA(Supported handles)
//      GetHVASRealB(Supported handles)
//      GetHVASRealC(Supported handles)
//      GetHVASRealD(Supported handles)
//      GetHVASRealE(Supported handles)

//      3) Returns unit
//      GetHVASUnitA(Supported handles)
//      GetHVASUnitB(Supported handles)
//      GetHVASUnitC(Supported handles)
//      GetHVASUnitD(Supported handles)
//      GetHVASUnitE(Supported handles)
//
//      4) Returns special effect
//      GetHVASEffectA(Supported handles)
//      GetHVASEffectB(Supported handles)
//      GetHVASEffectC(Supported handles)
//      GetHVASEffectD(Supported handles)
//      GetHVASEffectE(Supported handles)
//
//      5) Returns lightning
//      GetHVASLightningA(Supported handles)
//      GetHVASLightningB(Supported handles)
//      GetHVASLightningC(Supported handles)
//      GetHVASLightningD(Supported handles)
//      GetHVASLightningE(Supported handles)
//
//      6) Returns location
//      GetHVASLocA(Supported handles)
//      GetHVASLocB(Supported handles)
//      GetHVASLocC(Supported handles)
//      GetHVASLocD(Supported handles)
//      GetHVASLocE(Supported handles)
//
//      7) Returns timer
//      GetHVASTimerA(Supported handles)
//      GetHVASTimerB(Supported handles)
//      GetHVASTimerC(Supported handles)
//      GetHVASTimerD(Supported handles)
//      GetHVASTimerE(Supported handles)
//
//      8) Returns trigger
//      GetHVASTriggerA(Supported handles)
//      GetHVASTriggerB(Supported handles)
//      GetHVASTriggerC(Supported handles)
//      GetHVASTriggerD(Supported handles)
//      GetHVASTriggerE(Supported handles)
//
//      9) Returns group
//      GetHVASGroupA(Supported handles)
//      GetHVASGroupB(Supported handles)
//      GetHVASGroupC(Supported handles)
//      GetHVASGroupD(Supported handles)
//      GetHVASGroupE(Supported handles)
//
//      10) Returns texttag
//      GetHVASTexttagA(Supported handles)
//      GetHVASTexttagB(Supported handles)
//      GetHVASTexttagC(Supported handles)
//      GetHVASTexttagD(Supported handles)
//      GetHVASTexttagE(Supported handles)
//
//      11) Returns boolean
//      GetHVASBooleanA(Supported handles)
//      GetHVASBooleanB(Supported handles)
//      GetHVASBooleanC(Supported handles)
//      GetHVASBooleanD(Supported handles)
//      GetHVASBooleanE(Supported handles)
//
//      12) Returns string
//      GetHVASStringA(Supported handles)
//      GetHVASStringB(Supported handles)
//      GetHVASStringC(Supported handles)
//      GetHVASStringD(Supported handles)
//      GetHVASStringE(Supported handles)
//
//      ================================
//      c) Clear variables
//      ================================
//      ClearHVASHandleA(Supported handles)
//      ClearHVASHandleB(Supported handles)
//      ClearHVASHandleC(Supported handles)
//      ClearHVASHandleD(Supported handles)
//      ClearHVASHandleE(Supported handles)
//
//      ClearHVASIntA(Supported handles)
//      ClearHVASIntB(Supported handles)
//      ClearHVASIntC(Supported handles)
//      ClearHVASIntD(Supported handles)
//      ClearHVASIntE(Supported handles)
//     
//      ClearHVASRealA(Supported handles)
//      ClearHVASRealB(Supported handles)
//      ClearHVASRealC(Supported handles)
//      ClearHVASRealD(Supported handles)
//      ClearHVASRealE(Supported handles)
//
//      ClearHVASBooleanA(Supported handles)
//      ClearHVASBooleanB(Supported handles)
//      ClearHVASBooleanC(Supported handles)
//      ClearHVASBooleanD(Supported handles)
//      ClearHVASBooleanE(Supported handles)
//
//      Pros : 
//      1) Faster than any game cache-based system since it does not use mission keys.
//      2) Fast and Lite storing.
//      3) Can work good also when use together with other systems.
//      4) Can attaches all types of common handles.
//      5) Does not need to clear variables (optionally)
//
//      Cons :     
//      1) Maximum can have 8190 attached handles at same time.
//
//      How to Implement?
//      1) Copy entire this system's scripts to a new trigger named "HVAS v31"
//      2) Enjoy it!
//
//      Requirement : Jass NewGen Pack 5b
//
//      Comments/Suggestions/Contact/Bugs reporting.
//      <a href="mailto:[email protected]">[email protected]</a>
////////////////////////////////////////////////////////////////////////////////////////////
//
library HVASv31

globals
    private constant integer HASH_DOWN = 524288
    private constant integer HASH_UP = 2134900736
    private constant integer HASH_BIAS = 4096
    //This sytem use Hash to calculate the integer after converting handles.
endglobals

private function H2I takes handle h returns integer//H2I is a common function use in converting handle into integer
    return h
    return 0
endfunction

//Below are functions that convert handle into multiple types of variables.
private function H2T takes handle h returns trigger
    return h
    return null
endfunction

private function H2U takes handle h returns unit
    return h
    return null
endfunction

private function H2E takes handle h returns effect
    return h
    return null
endfunction

private function H2L takes handle h returns lightning
    return h
    return null
endfunction

private function H2G takes handle h returns group
    return h
    return null
endfunction

private function H2Loc takes handle h returns location
    return h
    return null
endfunction

private function H2T2 takes handle h returns timer
    return h
    return null
endfunction

private function H2TT takes handle h returns texttag
    return h
    return null
endfunction

private function H2S takes handle h returns string
    return h
    return null
endfunction

/////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////Storing Engine////////////////////////////////////////////
private struct StoredHandle

    handle h
    
        static method StoreHandle takes handle attached returns StoredHandle
            local StoredHandle Index = StoredHandle.allocate()
            set Index.h = attached
            return Index
        endmethod
        
        method GetHandle takes nothing returns handle
            return .h
        endmethod
        
        method onDestroy takes nothing returns nothing
            set .h = null
        endmethod
endstruct

private struct StoredInt

    integer i

        static method StoreInt takes integer i returns StoredInt
            local StoredInt Index = StoredInt.allocate()
            set Index.i = i
            return Index
        endmethod

        method GetInt takes nothing returns integer
            return .i
        endmethod
        
endstruct

private struct StoredReal

    real r

        static method StoreReals takes real r returns StoredHandle
            local StoredReal Index = StoredReal.allocate()
            set Index.r = r
            return Index
        endmethod

        method GetReal takes nothing returns real
            return .r
        endmethod
        
endstruct

private struct StoredBoolean

    boolean b

        static method StoreBooleans takes boolean b returns StoredHandle
            local StoredBoolean Index = StoredBoolean.allocate()
            set Index.b = b
            return Index
        endmethod

        method GetBoolean takes nothing returns boolean
            return .b
        endmethod
        
endstruct
/////////////////////////////////////////////////////////////////////////////////////////////

//! textmacro HVAS takes number
globals
    private integer array Sandbox$number$//We use text macroes to create multi instanceable system.
endglobals


function SetHVASHandle$number$ takes handle attacher, handle attached returns nothing
    local StoredHandle S = StoredHandle.StoreHandle(attached)
    set Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS] = S
endfunction

function SetHVASInt$number$ takes handle attacher, integer attached returns nothing
    local StoredInt S = StoredInt.StoreInt(attached)
    set Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS] = S
endfunction

function SetHVASReal$number$ takes handle attacher, real attached returns nothing
    local StoredReal S = StoredReal.StoreReals(attached)
    set Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS] = S
endfunction

function SetHVASBoolean$number$ takes handle attacher, boolean attached returns nothing
    local StoredBoolean S = StoredBoolean.StoreBooleans(attached)
    set Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS] = S
endfunction

function GetHVASInt$number$ takes handle attacher returns integer
    local StoredInt S = Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS]
    return S.GetInt()
endfunction

function GetHVASBoolean$number$ takes handle attacher returns boolean
    local StoredBoolean S = Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS]
    return S.GetBoolean()
endfunction

function GetHVASReal$number$ takes handle attacher returns real
    local StoredReal S = Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS]
    return S.GetReal()
endfunction

function GetHVASUnit$number$ takes handle attacher returns unit
    local StoredHandle S = Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS]
    return H2U(S.GetHandle())
endfunction

function GetHVASEffect$number$ takes handle attacher returns effect
    local StoredHandle S = Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS]
    return H2E(S.GetHandle())
endfunction

function GetHVASLightning$number$ takes handle attacher returns lightning
    local StoredHandle S = Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS]
    return H2L(S.GetHandle())
endfunction

function GetHVASLoc$number$ takes handle attacher returns location
    local StoredHandle S = Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS]
    return H2Loc(S.GetHandle())
endfunction

function GetHVASTimer$number$ takes handle attacher returns timer
    local StoredHandle S = Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS]
    return H2T2(S.GetHandle())
endfunction

function GetHVASTrigger$number$ takes handle attacher returns trigger
    local StoredHandle S = Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS]
    return H2T(S.GetHandle())
endfunction

function GetHVASGroup$number$ takes handle attacher returns group
    local StoredHandle S = Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS]
    return H2G(S.GetHandle())
endfunction

function GetHVASTextTag$number$ takes handle attacher returns texttag
    local StoredHandle S = Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS]
    return H2TT(S.GetHandle())
endfunction

function GetHVASString$number$ takes handle attacher returns string
    local StoredHandle S = Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS]
    return H2S(S.GetHandle())
endfunction

function ClearHVASHandle$number$ takes handle attacher returns nothing
    local StoredHandle S = Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS]
    call S.destroy()
endfunction

function ClearHVASInt$number$ takes handle attacher returns nothing
    local StoredInt S = Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS]
    call S.destroy()
endfunction

function ClearHVASReal$number$ takes handle attacher returns nothing
    local StoredReal S = Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS]
    call S.destroy()
endfunction

function ClearHVASBoolean$number$ takes handle attacher returns nothing
    local StoredBoolean S = Sandbox$number$[(H2I(attacher)*HASH_UP)/HASH_DOWN+HASH_BIAS]
    call S.destroy()
endfunction

//! endtextmacro
//! runtextmacro HVAS(&quot;A&quot;)
//! runtextmacro HVAS(&quot;B&quot;)
//! runtextmacro HVAS(&quot;C&quot;)
//! runtextmacro HVAS(&quot;D&quot;)
//! runtextmacro HVAS(&quot;E&quot;)

endlibrary


Enjoy it!
 

Romek

Super Moderator
Reaction score
963
Make your own thread.
 
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