Warcraft 1.24b

Fhxy

New Member
Reaction score
1
I have found out that my old map that is created in 1.23b is no longer compatible with warcraft 1.24b. How do i solve the problem ?
 

Executor

I see you
Reaction score
57
Well you should replace "H2I"-like functions with the new native "GetHandleId".
And the return bug doesn't work any longer. If you're not that skilled in JASS post your errors, so that we musn't GUESS whats wrong.
 

Fhxy

New Member
Reaction score
1
is there a thread or somewhere i can learn to convert my map?
because i got 2500 script error when i try to save my map in 1.24b editor
 

Fhxy

New Member
Reaction score
1
JASS:
//TESH.scrollpos=138
//TESH.alwaysfold=0
function IsUnitAnEnemy takes nothing returns boolean
    if IsPlayerEnemy(GetOwningPlayer(GetFilterUnit()), udg_Player) and GetUnitAbilityLevel(GetFilterUnit(), 'Aloc') == 0 and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0 then
     return true
    else
     return false
    endif
endfunction

//Rounds off a real\\
function RR takes real r returns real
    return I2R(R2I(r + 0.5))
endfunction

//KaTTaNa's Handle Vars\\
function H2I takes handle h returns integer
    return h
    return 0
endfunction

function LocalVars takes nothing returns gamecache
    return udg_Cache
endfunction

function SetHandleHandle takes handle subject, string name, handle value returns nothing
    if value==null then
        call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(H2I(subject)), name, H2I(value))
    endif
endfunction

function SetHandleInt takes handle subject, string name, integer value returns nothing
    if value==0 then
        call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleBoolean takes handle subject, string name, boolean value returns nothing
    if value==false then
        call FlushStoredBoolean(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreBoolean(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleReal takes handle subject, string name, real value returns nothing
    if value==0 then
        call FlushStoredReal(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreReal(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleString takes handle subject, string name, string value returns nothing
    if value==null then
        call FlushStoredString(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreString(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function GetHandleHandle takes handle subject, string name returns handle
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTA takes handle subject, string name returns triggeraction
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleInt takes handle subject, string name returns integer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleBoolean takes handle subject, string name returns boolean
    return GetStoredBoolean(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleReal takes handle subject, string name returns real
    return GetStoredReal(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleString takes handle subject, string name returns string
    return GetStoredString(LocalVars(), I2S(H2I(subject)), name)
endfunction

function GetHandleUnit takes handle subject, string name returns unit
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTimer takes handle subject, string name returns timer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleTrigger takes handle subject, string name returns trigger
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleEffect takes handle subject, string name returns effect
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleGroup takes handle subject, string name returns group
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleLightning takes handle subject, string name returns lightning
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction
function GetHandleWidget takes handle subject, string name returns widget
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

function FlushHandleLocals takes handle subject returns nothing
    call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction

//divided line

function H2i takes handle h returns item
    return h
endfunction

function H2TC takes handle h returns triggercondition
    return h
endfunction



function Wait takes real duration returns nothing
    local timer t
    local real  timeRemaining

    if (duration > 0.00) then
        set t = CreateTimer ()
        call TimerStart     (t,duration,false,null)
        loop
            set timeRemaining       = TimerGetRemaining (t)
            exitwhen timeRemaining <= 0.00

            if (timeRemaining > 0.271828) then
                call TriggerSleepAction (timeRemaining / 10.00)
            else
                call TriggerSleepAction (0.10)
            endif
        endloop
        call PauseTimer   (t)
        call DestroyTimer (t)
    endif
    set t = null
endfunction


note sure how to convert , i think there are a lot of errors here
 

Fhxy

New Member
Reaction score
1
There are a lot of
Code:
expected a code statement,a name, endif, a function name, a variable name, a name, endloop errors...
OMG
 

Fhxy

New Member
Reaction score
1
can some1 help me convert it to 1.24b compatible ? :confused:
 

Attachments

  • (8)PlainsOfSnow.w3x
    890.2 KB · Views: 165

Aedes

Member
Reaction score
8
Your map has a lot of "return bug" functions. You should start working on it. In 1.24b patch, if you return something, i.e, a unit, it must be a unit and not any storedintegers. It doesn't work anymore. You can return the unit as null or load the unit via Hashtable. Same thing with group, timer, etc.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
List of works :
Update ABC.
Update Table.
Update TimerUtils.
Add Faux Handle Vars.

Remove AbilityCache.

Replace this with your original library:
JASS:
library REGROWTREES initializer Init
globals
    private constant real RegrowAfter = 23.0 // seconds to wait until tree regrows
    private constant real Range = 250.0      // distance around tree that needs to be free of units before regrowing
    private unit u
    private group g = CreateGroup()
    private boolexpr b
    private boolean ok
endglobals
private function IsTree takes nothing returns boolean
    local boolean b
    call SetUnitX(u, GetWidgetX(GetFilterDestructable()))
    call SetUnitY(u, GetWidgetY(GetFilterDestructable()))
    set b = IssueTargetOrder(u, "harvest", GetFilterDestructable())
    call IssueImmediateOrder(u, "stop")
    return b
endfunction
private function IsUnitNear takes nothing returns boolean
    if GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.5 then
        set ok = false
    endif
    return false
endfunction
private function Regrow takes nothing returns nothing
    local destructable t = GetTriggerDestructable()
    call TriggerSleepAction(RegrowAfter)
    loop
        set ok = true
        call GroupClear(g)
        call GroupEnumUnitsInRange(g, GetDestructableX(t), GetDestructableY(t), Range, b)
        exitwhen ok
        call TriggerSleepAction(3.0)
    endloop
    call DestructableRestoreLife(t, GetDestructableMaxLife(t), true)
    set t = null
endfunction
private function Register takes nothing returns nothing
    call TriggerRegisterDeathEvent(bj_destInRegionDiesTrig, GetEnumDestructable())
endfunction
private function Init takes nothing returns nothing
    set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), 'nmpe', 0, 0, 0) // Mur'gul Slave...
    call SetUnitInvulnerable(u, true)
    call ShowUnit(u, false)
    call UnitAddAbility(u, 'Aloc') // Locust
    call UnitAddAbility(u, 'Ahrl') // Harvest Lumber
    set bj_destInRegionDiesTrig = CreateTrigger()
    call EnumDestructablesInRect(bj_mapInitialPlayableArea, Condition(function IsTree), function Register)
    call TriggerAddAction(bj_destInRegionDiesTrig, function Regrow)
    set b = Condition(function IsUnitNear)
    call RemoveUnit(u)
    set u = null
endfunction
endlibrary


Fix error in your spell's script.

Should work now.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
//==============================================================================
//  ABC -- STRUCT ATTACHMENT SYSTEM BY COHADAR -- v6.1
//==============================================================================


//==============================================================================
//  Quick function index:
//==============================================================================
//
//    ----------------------------------------------------------------------
//      Set Functions - these functions attach struct to a handle
//    ----------------------------------------------------------------------
//    SetTimerStructA(timer, struct)
//    SetTimerStructB(timer, struct)
//    SetTimerStructC(timer, struct)
//
//    SetTriggerStructA(trigger, struct)
//    SetTriggerStructB(trigger, struct)
//    SetTriggerStructC(trigger, struct)
//
//    SetDialogStructA(dialog, struct)
//    SetDialogStructB(dialog, struct)
//    SetDialogStructC(dialog, struct)
//
//    SetRegionStructA(region, struct)
//    SetRegionStructB(region, struct)
//    SetRegionStructC(region, struct)
//
//    ----------------------------------------------------------------------
//      Get Functions - these functions retrieve attached structs
//    ----------------------------------------------------------------------
//    GetTimerStructA(timer) -> struct
//    GetTimerStructB(timer) -> struct
//    GetTimerStructC(timer) -> struct
//
//    GetTriggerStructA(trigger) -> struct
//    GetTriggerStructB(trigger) -> struct
//    GetTriggerStructC(trigger) -> struct
//
//    GetDialogStructA(dialog) -> struct
//    GetDialogStructB(dialog) -> struct
//    GetDialogStructC(dialog) -> struct
//
//    GetRegionStructA(region) -> struct
//    GetRegionStructB(region) -> struct
//    GetRegionStructC(region) -> struct
//
//    ----------------------------------------------------------------------
//      Clear Functions - these functions clear and return attached value
//    ----------------------------------------------------------------------
//    ClearTimerStructA(timer) -> struct
//    ClearTimerStructB(timer) -> struct
//    ClearTimerStructC(timer) -> struct
//
//    ClearTriggerStructA(trigger) -> struct
//    ClearTriggerStructB(trigger) -> struct
//    ClearTriggerStructC(trigger) -> struct
//
//    ClearDialogStructA(dialog) -> struct
//    ClearDialogStructB(dialog) -> struct
//    ClearDialogStructC(dialog) -> struct
//
//    ClearRegionStructA(region) -> struct
//    ClearRegionStructB(region) -> struct
//    ClearRegionStructC(region) -> struct
//
//==============================================================================


//==============================================================================
//  DOCUMENTATION:
//==============================================================================
//
//  PURPOUSE OF ABC:
//       * Type safe handle attaching.
//      
//       * Currently supported handle types are timer, trigger, dialog and region
//
//  PROS: 
//       * ABC is faster than gamecache based systems.
//
//       * You can attach up to 3 structs on the same handle
//         
//       * System reports collision, and clearing of non-existent value.
//
//       * This system will work even if your map leaks
//         and will NOT slow down because of it.
//
//  CONS:
//       * you must manually clear the stored value - REMEMBER THIS RULE!!!
//         Don't forget to use Clear functions
//
//  DETAILS:
//       * You can use Get to check if struct is attached to handle
//         It will return 0 if it is not.
//
//       * ABC will not interfere with other attachment systems
//         You can freely use any other system alongside ABC
//
//       * For unit attaching I recommend using PUI
//
//  SPECIAL THANKS TO: 
//       * NagelBagel - for finding errors in versions 4.3 and 4.4
//       * Here-b-Trollz - for testing ABC and for making cool spells with it.
//       * Toadcop - for being pain in the ass and for pushing me to improve ABC.
//       * emjlr3 - for pointing out the need for non-generic trigger attachments
//       * PandaMine - I found a bug in ABC by examining his HSAS vs ABC test
//       * All those people out there who use and support my systems
//         Thank you guys.
//
//  HOW TO IMPORT:
//       * Just create a trigger named ABC
//       * convert it to text and replace the whole trigger text with this one
//
//==============================================================================


//==============================================================================
//  Macro function cores
//==============================================================================

//------------------------------------------------------------------------------
//! textmacro ABC_Set takes X, NAME, TYPE
    local integer i = GetHandleId(key)
    set i = i - (i / HASH) * HASH

    if $NAME$Key$X$<i> == null then
        set $NAME$Key$X$<i> = key
        set $NAME$Value$X$<i> = value
    else
        debug   set $NAME$Collision$X$<i> = $NAME$Collision$X$<i> + 1
        debug   if $NAME$MaxCollision$X$ &lt; $NAME$Collision$X$<i> then
        debug       set $NAME$MaxCollision$X$ = $NAME$Collision$X$<i>
        debug       call BJDebugMsg(&quot;|cFFFF00FFWarning: Set$NAME$Struct$X$(&quot;+I2S(GetHandleId(key))+&quot;, &quot;+I2S(value)+&quot;) - index: &quot;+I2S(i)+&quot;, collision: &quot;+I2S($NAME$MaxCollision$X$))
        debug   endif
        call SaveInteger($NAME$Hash, &#039;$X$&#039;, GetHandleId(key), value)
	endif
//! endtextmacro

//------------------------------------------------------------------------------
//! textmacro ABC_Get takes X, NAME, TYPE
    local integer i = GetHandleId(key)
    set i = i - (i / HASH) * HASH
	
    if $NAME$Key$X$<i> == key then
        return $NAME$Value$X$<i>
    else
        return LoadInteger($NAME$Hash, &#039;$X$&#039;, GetHandleId(key))
	endif
//! endtextmacro    

//------------------------------------------------------------------------------
//! textmacro ABC_Clear takes X, NAME, TYPE
    local integer ret
    local integer i = GetHandleId(key)
    set i = i - (i / HASH) * HASH
	
    if $NAME$Key$X$<i> == key then
        set ret = $NAME$Value$X$<i>
        set $NAME$Key$X$<i> = null
        set $NAME$Value$X$<i> = 0
    else
        if HaveSavedInteger($NAME$Hash, &#039;$X$&#039;, GetHandleId(key)) then
            debug set $NAME$Collision$X$<i> = $NAME$Collision$X$<i> - 1
            set ret = LoadInteger($NAME$Hash, &#039;$X$&#039;, GetHandleId(key))
            call RemoveSavedInteger($NAME$Hash, &#039;$X$&#039;, GetHandleId(key))
        else
            call BJDebugMsg(&quot;|cFFFF0000ERROR: Clear$NAME$Struct$X$(&quot;+I2S(GetHandleId(key))+&quot;) - clear attempt on bad key&quot;)
            set ret = 0
        endif
    endif
    
    return ret
//! endtextmacro    


//==============================================================================
library ABC initializer Init

globals
    private constant integer HASH = 8191

    private timer   array TimerKeyA
    private timer   array TimerKeyB
    private timer   array TimerKeyC
    private trigger array TriggerKeyA
    private trigger array TriggerKeyB
    private trigger array TriggerKeyC
    private dialog  array DialogKeyA
    private dialog  array DialogKeyB
    private dialog  array DialogKeyC
    private region  array RegionKeyA
    private region  array RegionKeyB
    private region  array RegionKeyC
    
    private integer array TimerValueA
    private integer array TimerValueB
    private integer array TimerValueC
    private integer array TriggerValueA
    private integer array TriggerValueB
    private integer array TriggerValueC
    private integer array DialogValueA
    private integer array DialogValueB
    private integer array DialogValueC
    private integer array RegionValueA
    private integer array RegionValueB
    private integer array RegionValueC

    private integer array TimerCollisionA
    private integer array TimerCollisionB
    private integer array TimerCollisionC
    private integer array TriggerCollisionA
    private integer array TriggerCollisionB
    private integer array TriggerCollisionC
    private integer array DialogCollisionA
    private integer array DialogCollisionB
    private integer array DialogCollisionC
    private integer array RegionCollisionA
    private integer array RegionCollisionB
    private integer array RegionCollisionC    
    
    private integer TimerMaxCollisionA   = 0
    private integer TimerMaxCollisionB   = 0
    private integer TimerMaxCollisionC   = 0
    private integer TriggerMaxCollisionA = 0
    private integer TriggerMaxCollisionB = 0
    private integer TriggerMaxCollisionC = 0
    private integer DialogMaxCollisionA  = 0
    private integer DialogMaxCollisionB  = 0
    private integer DialogMaxCollisionC  = 0
    private integer RegionMaxCollisionA  = 0
    private integer RegionMaxCollisionB  = 0
    private integer RegionMaxCollisionC  = 0 
    
    private hashtable TimerHash
    private hashtable TriggerHash
    private hashtable DialogHash
    private hashtable RegionHash
endglobals

//==============================================================================
//  Collision check functions
//==============================================================================

//------------------------------------------------------------------------------
function GetTimerCollisionA takes nothing returns integer
    return TimerMaxCollisionA
endfunction

//------------------------------------------------------------------------------
function GetTimerCollisionB takes nothing returns integer
    return TimerMaxCollisionB
endfunction

//------------------------------------------------------------------------------
function GetTimerCollisionC takes nothing returns integer
    return TimerMaxCollisionC
endfunction

//------------------------------------------------------------------------------
function GetTriggerCollisionA takes nothing returns integer
    return TriggerMaxCollisionA
endfunction

//------------------------------------------------------------------------------
function GetTriggerCollisionB takes nothing returns integer
    return TriggerMaxCollisionB
endfunction

//------------------------------------------------------------------------------
function GetTriggerCollisionC takes nothing returns integer
    return TriggerMaxCollisionC
endfunction

//------------------------------------------------------------------------------
function GetDialogCollisionA takes nothing returns integer
    return DialogMaxCollisionA
endfunction

//------------------------------------------------------------------------------
function GetDialogCollisionB takes nothing returns integer
    return DialogMaxCollisionB
endfunction

//------------------------------------------------------------------------------
function GetDialogCollisionC takes nothing returns integer
    return DialogMaxCollisionC
endfunction

//------------------------------------------------------------------------------
function GetRegionCollisionA takes nothing returns integer
    return RegionMaxCollisionA
endfunction

//------------------------------------------------------------------------------
function GetRegionCollisionB takes nothing returns integer
    return RegionMaxCollisionB
endfunction

//------------------------------------------------------------------------------
function GetRegionCollisionC takes nothing returns integer
    return RegionMaxCollisionC
endfunction


//==============================================================================
//  Set functions
//==============================================================================

//------------------------------------------------------------------------------
function SetTimerStructA takes timer key, integer value returns nothing
//! runtextmacro ABC_Set(&quot;A&quot;, &quot;Timer&quot;, &quot;timer&quot;)
endfunction

//------------------------------------------------------------------------------
function SetTimerStructB takes timer key, integer value returns nothing
//! runtextmacro ABC_Set(&quot;B&quot;, &quot;Timer&quot;, &quot;timer&quot;)
endfunction

//------------------------------------------------------------------------------
function SetTimerStructC takes timer key, integer value returns nothing
//! runtextmacro ABC_Set(&quot;C&quot;, &quot;Timer&quot;, &quot;timer&quot;)
endfunction

//------------------------------------------------------------------------------
function SetTriggerStructA takes trigger key, integer value returns nothing
//! runtextmacro ABC_Set(&quot;A&quot;, &quot;Trigger&quot;, &quot;trigger&quot;)
endfunction

//------------------------------------------------------------------------------
function SetTriggerStructB takes trigger key, integer value returns nothing
//! runtextmacro ABC_Set(&quot;B&quot;, &quot;Trigger&quot;, &quot;trigger&quot;)
endfunction

//------------------------------------------------------------------------------
function SetTriggerStructC takes trigger key, integer value returns nothing
//! runtextmacro ABC_Set(&quot;C&quot;, &quot;Trigger&quot;, &quot;trigger&quot;)
endfunction

//------------------------------------------------------------------------------
function SetDialogStructA takes dialog key, integer value returns nothing
//! runtextmacro ABC_Set(&quot;A&quot;, &quot;Dialog&quot;, &quot;dialog&quot;)
endfunction

//------------------------------------------------------------------------------
function SetDialogStructB takes dialog key, integer value returns nothing
//! runtextmacro ABC_Set(&quot;B&quot;, &quot;Dialog&quot;, &quot;dialog&quot;)
endfunction

//------------------------------------------------------------------------------
function SetDialogStructC takes dialog key, integer value returns nothing
//! runtextmacro ABC_Set(&quot;C&quot;, &quot;Dialog&quot;, &quot;dialog&quot;)
endfunction

//------------------------------------------------------------------------------
function SetRegionStructA takes region key, integer value returns nothing
//! runtextmacro ABC_Set(&quot;A&quot;, &quot;Region&quot;, &quot;region&quot;)
endfunction

//------------------------------------------------------------------------------
function SetRegionStructB takes region key, integer value returns nothing
//! runtextmacro ABC_Set(&quot;B&quot;, &quot;Region&quot;, &quot;region&quot;)
endfunction

//------------------------------------------------------------------------------
function SetRegionStructC takes region key, integer value returns nothing
//! runtextmacro ABC_Set(&quot;C&quot;, &quot;Region&quot;, &quot;region&quot;)
endfunction


//==============================================================================
//  Get functions
//==============================================================================

//------------------------------------------------------------------------------
function GetTimerStructA takes timer key returns integer
//! runtextmacro ABC_Get(&quot;A&quot;, &quot;Timer&quot;, &quot;timer&quot;)
endfunction

//------------------------------------------------------------------------------
function GetTimerStructB takes timer key returns integer
//! runtextmacro ABC_Get(&quot;B&quot;, &quot;Timer&quot;, &quot;timer&quot;)
endfunction

//------------------------------------------------------------------------------
function GetTimerStructC takes timer key returns integer
//! runtextmacro ABC_Get(&quot;C&quot;, &quot;Timer&quot;, &quot;timer&quot;)
endfunction

//------------------------------------------------------------------------------
function GetTriggerStructA takes trigger key returns integer
//! runtextmacro ABC_Get(&quot;A&quot;, &quot;Trigger&quot;, &quot;trigger&quot;)
endfunction

//------------------------------------------------------------------------------
function GetTriggerStructB takes trigger key returns integer
//! runtextmacro ABC_Get(&quot;B&quot;, &quot;Trigger&quot;, &quot;trigger&quot;)
endfunction

//------------------------------------------------------------------------------
function GetTriggerStructC takes trigger key returns integer
//! runtextmacro ABC_Get(&quot;C&quot;, &quot;Trigger&quot;, &quot;trigger&quot;)
endfunction

//------------------------------------------------------------------------------
function GetDialogStructA takes dialog key returns integer
//! runtextmacro ABC_Get(&quot;A&quot;, &quot;Dialog&quot;, &quot;dialog&quot;)
endfunction

//------------------------------------------------------------------------------
function GetDialogStructB takes dialog key returns integer
//! runtextmacro ABC_Get(&quot;B&quot;, &quot;Dialog&quot;, &quot;dialog&quot;)
endfunction

//------------------------------------------------------------------------------
function GetDialogStructC takes dialog key returns integer
//! runtextmacro ABC_Get(&quot;C&quot;, &quot;Dialog&quot;, &quot;dialog&quot;)
endfunction

//------------------------------------------------------------------------------
function GetRegionStructA takes region key returns integer
//! runtextmacro ABC_Get(&quot;A&quot;, &quot;Region&quot;, &quot;region&quot;)
endfunction

//------------------------------------------------------------------------------
function GetRegionStructB takes region key returns integer
//! runtextmacro ABC_Get(&quot;B&quot;, &quot;Region&quot;, &quot;region&quot;)
endfunction

//------------------------------------------------------------------------------
function GetRegionStructC takes region key returns integer
//! runtextmacro ABC_Get(&quot;C&quot;, &quot;Region&quot;, &quot;region&quot;)
endfunction


//==============================================================================
//  Clear functions
//==============================================================================

//------------------------------------------------------------------------------
function ClearTimerStructA takes timer key returns integer
//! runtextmacro ABC_Clear(&quot;A&quot;, &quot;Timer&quot;, &quot;timer&quot;)
endfunction

//------------------------------------------------------------------------------
function ClearTimerStructB takes timer key returns integer
//! runtextmacro ABC_Clear(&quot;B&quot;, &quot;Timer&quot;, &quot;timer&quot;)
endfunction

//------------------------------------------------------------------------------
function ClearTimerStructC takes timer key returns integer
//! runtextmacro ABC_Clear(&quot;C&quot;, &quot;Timer&quot;, &quot;timer&quot;)
endfunction

//------------------------------------------------------------------------------
function ClearTriggerStructA takes trigger key returns integer
//! runtextmacro ABC_Clear(&quot;A&quot;, &quot;Trigger&quot;, &quot;trigger&quot;)
endfunction

//------------------------------------------------------------------------------
function ClearTriggerStructB takes trigger key returns integer
//! runtextmacro ABC_Clear(&quot;B&quot;, &quot;Trigger&quot;, &quot;trigger&quot;)
endfunction

//------------------------------------------------------------------------------
function ClearTriggerStructC takes trigger key returns integer
//! runtextmacro ABC_Clear(&quot;C&quot;, &quot;Trigger&quot;, &quot;trigger&quot;)
endfunction

//------------------------------------------------------------------------------
function ClearDialogStructA takes dialog key returns integer
//! runtextmacro ABC_Clear(&quot;A&quot;, &quot;Dialog&quot;, &quot;dialog&quot;)
endfunction

//------------------------------------------------------------------------------
function ClearDialogStructB takes dialog key returns integer
//! runtextmacro ABC_Clear(&quot;B&quot;, &quot;Dialog&quot;, &quot;dialog&quot;)
endfunction

//------------------------------------------------------------------------------
function ClearDialogStructC takes dialog key returns integer
//! runtextmacro ABC_Clear(&quot;C&quot;, &quot;Dialog&quot;, &quot;dialog&quot;)
endfunction

//------------------------------------------------------------------------------
function ClearRegionStructA takes region key returns integer
//! runtextmacro ABC_Clear(&quot;A&quot;, &quot;Region&quot;, &quot;region&quot;)
endfunction

//------------------------------------------------------------------------------
function ClearRegionStructB takes region key returns integer
//! runtextmacro ABC_Clear(&quot;B&quot;, &quot;Region&quot;, &quot;region&quot;)
endfunction

//------------------------------------------------------------------------------
function ClearRegionStructC takes region key returns integer
//! runtextmacro ABC_Clear(&quot;C&quot;, &quot;Region&quot;, &quot;region&quot;)
endfunction


//==============================================================================
//  Initialization
//==============================================================================
private function Init takes nothing returns nothing
    set TimerKeyA[HASH-1] = null
    set TimerKeyB[HASH-1] = null
    set TimerKeyC[HASH-1] = null
    set TriggerKeyA[HASH-1] = null
    set TriggerKeyB[HASH-1] = null
    set TriggerKeyC[HASH-1] = null
    set DialogKeyA[HASH-1] = null
    set DialogKeyB[HASH-1] = null
    set DialogKeyC[HASH-1] = null
    set RegionKeyA[HASH-1] = null
    set RegionKeyB[HASH-1] = null
    set RegionKeyC[HASH-1] = null
    
    set TimerValueA[HASH-1] = 0
    set TimerValueB[HASH-1] = 0
    set TimerValueC[HASH-1] = 0
    set TriggerValueA[HASH-1] = 0
    set TriggerValueB[HASH-1] = 0
    set TriggerValueC[HASH-1] = 0
    set DialogValueA[HASH-1] = 0
    set DialogValueB[HASH-1] = 0
    set DialogValueC[HASH-1] = 0
    set RegionValueA[HASH-1] = 0
    set RegionValueB[HASH-1] = 0
    set RegionValueC[HASH-1] = 0    
    
    set TimerCollisionA[HASH-1] = 0
    set TimerCollisionB[HASH-1] = 0
    set TimerCollisionC[HASH-1] = 0
    set TriggerCollisionA[HASH-1] = 0
    set TriggerCollisionB[HASH-1] = 0
    set TriggerCollisionC[HASH-1] = 0
    set DialogCollisionA[HASH-1] = 0
    set DialogCollisionB[HASH-1] = 0
    set DialogCollisionC[HASH-1] = 0
    set RegionCollisionA[HASH-1] = 0
    set RegionCollisionB[HASH-1] = 0
    set RegionCollisionC[HASH-1] = 0    
    
    set TimerHash   = InitHashtable()
    set TriggerHash = InitHashtable()
    set DialogHash  = InitHashtable()
    set RegionHash  = InitHashtable()
endfunction

endlibrary
//==============================================================================
//  END OF ABC STRUCT ATTACHMENT SYSTEM
//==============================================================================
</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>


JASS:
library Table
//***************************************************************
//* Table object 3.0
//* ------------
//*
//*   set t=Table.create() - instanceates a new table object
//*   call t.destroy()     - destroys it
//*   t[1234567]           - Get value for key 1234567
//*                          (zero if not assigned previously)
//*   set t[12341]=32      - Assigning it.
//*   call t.flush(12341)  - Flushes the stored value, so it
//*                          doesn&#039;t use any more memory
//*   t.exists(32)         - Was key 32 assigned? Notice
//*                          that flush() unassigns values.
//*   call t.reset()       - Flushes the whole contents of the
//*                          Table.
//*
//*   call t.destroy()     - Does reset() and also recycles the id.
//*
//*   If you use HandleTable instead of Table, it is the same
//* but it uses handles as keys, the same with StringTable.
//*
//*  You can use Table on structs&#039; onInit  if the struct is
//* placed in a library that requires Table or outside a library.
//*
//*  You can also do 2D array syntax if you want to touch
//* mission keys directly, however, since this is shared space
//* you may want to prefix your mission keys accordingly:
//*
//*  set Table[&quot;thisstring&quot;][ 7 ] = 2
//*  set Table[&quot;thisstring&quot;][ 5 ] = Table[&quot;thisstring&quot;][7]
//*
//***************************************************************

//=============================================================
    globals
        private constant integer MAX_INSTANCES=8100 //400000
        //Feel free to change max instances if necessary, it will only affect allocation
        //speed which shouldn&#039;t matter that much.

    //=========================================================
        private hashtable ht
    endglobals

    private struct GTable[MAX_INSTANCES]

        method reset takes nothing returns nothing
            call FlushChildHashtable(ht, integer(this) )
        endmethod

        private method onDestroy takes nothing returns nothing
            call this.reset()
        endmethod

        //=============================================================
        // initialize it all.
        //
        private static method onInit takes nothing returns nothing
            set ht = InitHashtable()
        endmethod

    endstruct

    //Hey: Don&#039;t instanciate other people&#039;s textmacros that you are not supposed to, thanks.
    //! textmacro Table__make takes name, type, key
    struct $name$ extends GTable

        method operator [] takes $type$ key returns integer
            return LoadInteger(ht, integer(this), $key$)
        endmethod

        method operator []= takes $type$ key, integer value returns nothing
            call SaveInteger(ht,  integer(this)  ,$key$, value)
        endmethod

        method flush takes $type$ key returns nothing
            call RemoveSavedInteger(ht, integer(this), $key$)
        endmethod

        method exists takes $type$ key returns boolean
            return HaveSavedInteger( ht,  integer(this)  ,$key$)
        endmethod

        static method flush2D takes string firstkey returns nothing
            call $name$(- StringHash(firstkey)).reset()
        endmethod

        static method operator [] takes string firstkey returns $name$
            return $name$(- StringHash(firstkey) )
        endmethod

    endstruct
    //! endtextmacro

    //! runtextmacro Table__make(&quot;Table&quot;,&quot;integer&quot;,&quot;key&quot; )
    //! runtextmacro Table__make(&quot;StringTable&quot;,&quot;string&quot;, &quot;StringHash(key)&quot; )
    //! runtextmacro Table__make(&quot;HandleTable&quot;,&quot;handle&quot;,&quot;GetHandleId(key)&quot; )

endlibrary


JASS:
/*******************************************************************************************
 Faux Handle Vars
 ----------------
    Do not use these functions for new stuff, it is just not the right thing to do...

    The intention of Faux Handle Vars is to be a patch fix for a map&#039;s migration to
  patch 1.24 This library might not cover all uses of handle vars, some of them are just
  impossible with the new rules set in patches 1.23b and 1.24, but they should work for
  most of the cases....

    All of them but the SetHandle*** ones are inline friendly. I follow the interface
  in official Kattana&#039;s handle vars from wc3jass.com, if your handle vars functions
  look different, then you were not using handle vars but another thing...

*******************************************************************************************/

//==========================================================================================
library HandleVars initializer init

 globals
    private hashtable ht
 endglobals
 
    // too bad the Handle vars&#039; old functionality forces me to make these things
    // inline-unfriendly
    function SetHandleHandle takes agent subject,  string label, agent value returns nothing
        if(value==null) then
            call RemoveSavedHandle( ht, GetHandleId(subject), StringHash(label))
        else
            call SaveAgentHandle( ht, GetHandleId(subject), StringHash(label), value)
        endif
    endfunction

    function SetHandleInt takes agent subject, string label, integer value returns nothing
        if value==0 then
            call RemoveSavedInteger(ht, GetHandleId(subject), StringHash(label))
        else
            call SaveInteger(ht, GetHandleId(subject), StringHash(label), value)
        endif        
    endfunction

    function SetHandleBoolean takes agent subject, string label, boolean value returns nothing
        if (value == false) then
            call RemoveSavedBoolean(ht, GetHandleId(subject), StringHash(label))
        else
            call SaveBoolean(ht, GetHandleId(subject), StringHash(label), value)
        endif
    endfunction

    function SetHandleReal takes agent subject, string label, real value returns nothing
        if (value == 0.0) then
            call RemoveSavedReal(ht, GetHandleId(subject), StringHash(label))
        else
            call SaveReal(ht, GetHandleId(subject), StringHash(label), value)
        endif
    endfunction

    function SetHandleString takes agent subject, string label, string value returns nothing
        if ((value==&quot;&quot;) or (value==null)) then
            call RemoveSavedString(ht, GetHandleId(subject), StringHash(label)) 
        else
            call SaveStr(ht, GetHandleId(subject), StringHash(label), value) //yay for blizz&#039; consistent naming scheme...
        endif
    endfunction

    function GetHandleHandle takes agent subject, string label returns agent
        debug call BJDebugMsg(&quot;[debug] What the heck? Why would you call HandleHandle I guess this was caused by a search and replace mistake&quot;)
        return null
    endfunction

    // these are inline friendly, ok, maybe they aren&#039;t because jasshelper does not recognize
    // GetHandleId as non-state changing. But they will be once I fix jasshelper...

    function GetHandleInt takes agent subject, string label returns integer
        return LoadInteger(ht, GetHandleId(subject), StringHash(label))
    endfunction

    function GetHandleBoolean takes agent subject, string label returns boolean
        return LoadBoolean(ht, GetHandleId(subject), StringHash(label))
    endfunction

    function GetHandleString takes agent subject, string label returns string
        return LoadStr(ht, GetHandleId(subject), StringHash(label))
    endfunction

    function GetHandleReal takes agent subject, string label returns real
        return LoadReal(ht, GetHandleId(subject), StringHash(label))
    endfunction

    // got bored so I now use a textmacro...
    //! textmacro FAUX_HANDLE_VARS_GetHandleHandle takes NAME, TYPE
         function SetHandle$NAME$ takes agent subject,  string label, $TYPE$ value returns nothing
             if(value==null) then
                call RemoveSavedHandle( ht, GetHandleId(subject), StringHash(label))
             else
                call Save$NAME$Handle( ht, GetHandleId(subject), StringHash(label), value)
             endif
         endfunction

         function GetHandle$NAME$ takes agent subject, string label returns $TYPE$
             return Load$NAME$Handle( ht, GetHandleId(subject), StringHash(label))
         endfunction
    //! endtextmacro
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Player&quot;,&quot;player&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Widget&quot;,&quot;widget&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Destructable&quot;,&quot;destructable&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Item&quot;,&quot;item&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Unit&quot;,&quot;unit&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Ability&quot;,&quot;ability&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Timer&quot;,&quot;timer&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Trigger&quot;,&quot;trigger&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;TriggerCondition&quot;,&quot;triggercondition&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;TriggerAction&quot;,&quot;triggeraction&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;TriggerEvent&quot;,&quot;event&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Force&quot;,&quot;force&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Group&quot;,&quot;group&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Location&quot;,&quot;location&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Rect&quot;,&quot;rect&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;BooleanExpr&quot;,&quot;boolexpr&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Sound&quot;,&quot;sound&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Effect&quot;,&quot;effect&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;UnitPool&quot;,&quot;unitpool&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;ItemPool&quot;,&quot;itempool&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Quest&quot;,&quot;quest&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;QuestItem&quot;,&quot;questitem&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;DefeatCondition&quot;,&quot;defeatcondition&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;TimerDialog&quot;,&quot;timerdialog&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Leaderboard&quot;,&quot;leaderboard&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Multiboard&quot;,&quot;multiboard&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;MultiboardItem&quot;,&quot;multiboarditem&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Trackable&quot;,&quot;trackable&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Dialog&quot;,&quot;dialog&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Button&quot;,&quot;button&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;TextTag&quot;,&quot;texttag&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Lightning&quot;,&quot;lightning&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Image&quot;,&quot;image&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Ubersplat&quot;,&quot;ubersplat&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Region&quot;,&quot;region&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;FogState&quot;,&quot;fogstate&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;FogModifier&quot;,&quot;fogmodifier&quot;)
    //! runtextmacro FAUX_HANDLE_VARS_GetHandleHandle(&quot;Hashtable&quot;,&quot;hashtable&quot;)


    function FlushHandleVars takes agent subject returns nothing
        call FlushChildHashtable(ht, GetHandleId(subject))
    endfunction
    function FlushHandleLocals takes agent subject returns nothing
        call FlushHandleVars(subject)
    endfunction


    private function init takes nothing returns nothing
        set ht=InitHashtable()
    endfunction

endlibrary


JASS:
library_once TimerUtils initializer init
//*********************************************************************
//* TimerUtils (Blue flavor for 1.23b or later) 
//* ----------
//*
//*  To implement it , create a custom text trigger called TimerUtils
//* and paste the contents of this script there.
//*
//*  To copy from a map to another, copy the trigger holding this
//* library to your map.
//*
//* (requires vJass)   More scripts: htt://www.wc3campaigns.net
//*
//* For your timer needs:
//*  * Attaching
//*  * Recycling (with double-free protection)
//*
//* set t=NewTimer()      : Get a timer (alternative to CreateTimer)
//* ReleaseTimer(t)       : Relese a timer (alt to DestroyTimer)
//* SetTimerData(t,2)     : Attach value 2 to timer
//* GetTimerData(t)       : Get the timer&#039;s value.
//*                         You can assume a timer&#039;s value is 0
//*                         after NewTimer.
//*
//* Blue Flavor: Slower than the red flavor, it got a 408000 handle id
//*             limit, which means that if more than 408000 handle ids
//*             are used in your map, TimerUtils might fail, this
//*             value is quite big and it is much bigger than the 
//*             timer limit in Red flavor.
//*
//********************************************************************

    //==================================================================================================
    globals
        private hashtable hasht //I &lt;3 blizz
    endglobals

    //It is dependent on jasshelper&#039;s recent inlining optimization in order to perform correctly.
    function SetTimerData takes timer t, integer value returns nothing
        call SaveInteger(hasht,0, GetHandleId(t), value)
    endfunction

    function GetTimerData takes timer t returns integer
        return LoadInteger(hasht, 0, GetHandleId(t))
    endfunction

    //==========================================================================================
    globals
        private timer array tT
        private integer tN = 0
        private constant integer HELD=0x28829022
        //use a totally random number here, the more improbable someone uses it, the better.
    endglobals

    //==========================================================================================
    function NewTimer takes nothing returns timer
        if (tN==0) then
            set tT[0]=CreateTimer()
        else
            set tN=tN-1
        endif
        call SetTimerData(tT[tN],0)
     return tT[tN]
    endfunction

    //==========================================================================================
    function ReleaseTimer takes timer t returns nothing
        if(t==null) then
            debug call BJDebugMsg(&quot;Warning: attempt to release a null timer&quot;)
            return
        endif
        if (tN==8191) then
            debug call BJDebugMsg(&quot;Warning: Timer stack is full, destroying timer!!&quot;)

            //stack is full, the map already has much more troubles than the chance of bug
            call DestroyTimer(t)
        else
            call PauseTimer(t)
            if(GetTimerData(t)==HELD) then
                debug call BJDebugMsg(&quot;Warning: ReleaseTimer: Double free!&quot;)
                return
            endif
            call SetTimerData(t,HELD)
            set tT[tN]=t
            set tN=tN+1
        endif    
    endfunction

    private function init takes nothing returns nothing
        set hasht = InitHashtable()
    endfunction

endlibrary
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top