Convert this Code to 1.24

Silencer

New Member
Reaction score
0
How to convert this code to 1.24b ?

JASS:
function SHHandle takes handle s, string n, handle v returns nothing
    if v==null then
        call FlushStoredInteger(udg_cache,I2S(H2I(s)),n)
    else
        call StoreInteger(udg_cache, I2S(H2I(s)), n, H2I(v))
    endif
endfunction
function SHInt takes handle s, string n, integer v returns nothing
    if v==0 then
        call FlushStoredInteger(udg_cache,I2S(H2I(s)),n)
    else
        call StoreInteger(udg_cache, I2S(H2I(s)), n, v)
    endif
endfunction
function SHBoolean takes handle s, string n, boolean v returns nothing
    if v==false then
        call FlushStoredBoolean(udg_cache,I2S(H2I(s)),n)
    else
        call StoreBoolean(udg_cache, I2S(H2I(s)), n, v)
    endif
endfunction
function SHReal takes handle s, string n, real v returns nothing
    if v==0 then
        call FlushStoredReal(udg_cache, I2S(H2I(s)), n)
    else
        call StoreReal(udg_cache, I2S(H2I(s)), n, v)
    endif
endfunction
function SHString takes handle s, string n, string v returns nothing
    if v==null then
        call FlushStoredString(udg_cache, I2S(H2I(s)), n)
    else
        call StoreString(udg_cache, I2S(H2I(s)), n, v)
    endif
function GHBoolean takes handle s, string n returns boolean
    return GetStoredBoolean(udg_cache, I2S(H2I(s)), n)
endfunction
function GHReal takes handle s, string n returns real
    return GetStoredReal(udg_cache, I2S(H2I(s)), n)
endfunction
function GHUnit takes handle s, string n returns unit
    return GetStoredInteger(udg_cache, I2S(H2I(s)), n)
    return null
endfunction
function FHLocals takes handle s returns nothing
    call FlushStoredMission(udg_cache, I2S(H2I(s)) )
endfunction
function RemoveUnitTimed takes unit u, real dur returns nothing
    call RemoveTimedEnum.execute(u,dur)
endfunction
function TimedEffectPt takes real x, real y, real duration, string efx returns nothing
    local effect fx = AddSpecialEffect(efx, x, y)
    local timer t = CreateTimer()
    call SHHandle(t, "fx", fx)
    call TimerStart(t, duration, false, function EffectDestroy)
    set t = null
    set fx = null
endfunction

function SETRemove takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u = GHUnit(t,"u")
    local string s = GHString(t,"s")
    call SHBoolean(u,s,false)
    call FHLocals(t)
    call DestroyTimer(t)
    set t = null
    set u = null
endfunction


Also i get a jass error (syntax error, unexspected "takes" ?) here and i dont know why =/

JASS:
function GHBoolean takes handle s, string n returns boolean
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Here you go :
JASS:
function H2I takes handle h returns integer
    return GetHandleId(h)
endfunction
function SHHandle takes handle s, string n, handle v returns nothing
    if v==null then
        call FlushStoredInteger(udg_cache,I2S(H2I(s)),n)
    else
        call StoreInteger(udg_cache, I2S(H2I(s)), n, H2I(v))
    endif
endfunction
function SHInt takes handle s, string n, integer v returns nothing
    if v==0 then
        call FlushStoredInteger(udg_cache,I2S(H2I(s)),n)
    else
        call StoreInteger(udg_cache, I2S(H2I(s)), n, v)
    endif
endfunction
function SHBoolean takes handle s, string n, boolean v returns nothing
    if v==false then
        call FlushStoredBoolean(udg_cache,I2S(H2I(s)),n)
    else
        call StoreBoolean(udg_cache, I2S(H2I(s)), n, v)
    endif
endfunction
function SHReal takes handle s, string n, real v returns nothing
    if v==0 then
        call FlushStoredReal(udg_cache, I2S(H2I(s)), n)
    else
        call StoreReal(udg_cache, I2S(H2I(s)), n, v)
    endif
endfunction
function SHString takes handle s, string n, string v returns nothing
    if v==null then
        call FlushStoredString(udg_cache, I2S(H2I(s)), n)
    else
        call StoreString(udg_cache, I2S(H2I(s)), n, v)
    endif
endfunction
function GHBoolean takes handle s, string n returns boolean
    return GetStoredBoolean(udg_cache, I2S(H2I(s)), n)
endfunction
function GHReal takes handle s, string n returns real
    return GetStoredReal(udg_cache, I2S(H2I(s)), n)
endfunction
function I2I takes integer i returns integer
    return i
endfunction
function GHUnit takes handle s, string n returns unit
    call I2I(GetStoredInteger(udg_cache, I2S(H2I(s)), n))
    if false then
        return null
    endif
endfunction
function FHLocals takes handle s returns nothing
    call FlushStoredMission(udg_cache, I2S(H2I(s)) )
endfunction
function RemoveUnitTimed takes unit u, real dur returns nothing
    call RemoveTimedEnum.execute(u,dur)
endfunction
function TimedEffectPt takes real x, real y, real duration, string efx returns nothing
    local effect fx = AddSpecialEffect(efx, x, y)
    local timer t = CreateTimer()
    call SHHandle(t, "fx", fx)
    call TimerStart(t, duration, false, function EffectDestroy)
    set t = null
    set fx = null
endfunction

function SETRemove takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u = GHUnit(t,"u")
    local string s = GHString(t,"s")
    call SHBoolean(u,s,false)
    call FHLocals(t)
    call DestroyTimer(t)
    set t = null
    set u = null
endfunction
 

Silencer

New Member
Reaction score
0
Have you a tool to convert? Or do it by hand?

JASS:
function GHTrigger takes handle s, string n returns trigger
    return GetStoredInteger(udg_cache, I2S(H2I(s)), n)
    if false then
        return null
    endif
endfunction


Jass tell me that it misses a "return" ?! Dont know if it is that... but the map is still unplayable and this is the only JASS trigger in there.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Hashtable version :
JASS:
library HandleVars
    globals
        private hashtable udg_cache = InitHashtable()
    endglobals
    
    //! textmacro HANDLE_VARS takes NAME, FUNCTION, TYPE, NULL_VALUE
    function SH$NAME$ takes handle s, string n, $TYPE$ v returns nothing
        if v==$NULL_VALUE$ then
            call RemoveSaved$NAME$(udg_cache,GetHandleId(s),StringHash(n))
        else
            call Save$FUNCTION$(udg_cache, GetHandleId(s), StringHash(n), v)
        endif
    endfunction
    //! endtextmacro
    //! runtextmacro HANDLE_VARS ("Handle", "AgentHandle", "agent", "null")
    //! runtextmacro HANDLE_VARS ("Integer", "Integer", "integer", "0")
    //! runtextmacro HANDLE_VARS ("Real", "Real", "real", "0.")
    //! runtextmacro HANDLE_VARS ("Boolean", "Boolean", "boolean", "false")
    //! runtextmacro HANDLE_VARS ("String", "Str", "string", "null")
    
    //! textmacro HANDLE_VARS_GET takes TYPE, FUNC, type
    function GetH$TYPE$ takes handle s, string n returns $type$
        return Load$FUNC$(udg_cache,GetHandleId(s),StringHash(n))
    endfunction
    //! endtextmacro
    //! runtextmacro HANDLE_VARS_GET ("Integer","Integer","integer")
    //! runtextmacro HANDLE_VARS_GET ("Real","Real","real")
    //! runtextmacro HANDLE_VARS_GET ("Boolean","Boolean","boolean")
    //! runtextmacro HANDLE_VARS_GET ("String","Str","string")
    
    //! textmacro HANDLE_VARS_GETHANDLE takes TYPE, type
    function GH$TYPE$ takes handle s, string n returns $type$
        return Load$TYPE$Handle(udg_cache,GetHandleId(s),StringHash(n))
    endfunction
    //! endtextmacro 
    //! runtextmacro HANDLE_VARS_GETHANDLE ("Unit","unit")
    //! runtextmacro HANDLE_VARS_GETHANDLE ("Effect","effect")
    //! runtextmacro HANDLE_VARS_GETHANDLE ("Lightning","lightning")
    //! runtextmacro HANDLE_VARS_GETHANDLE ("Location","location")
    //! runtextmacro HANDLE_VARS_GETHANDLE ("Trigger","trigger")
        //! runtextmacro HANDLE_VARS_GETHANDLE ("Timer","timer")
    
    function FHLocals takes handle s returns nothing
        call FlushChildHashtable(udg_cache,GetHandleId(s))
    endfunction
endlibrary
 

Silencer

New Member
Reaction score
0
Hm missing "return" again. Here is a screenshot:

n5q5n7.jpg
 

Silencer

New Member
Reaction score
0
I used your version with
Code:
function H2I takes handle h returns integer
    return GetHandleId(h)
endfunction
at the beginning, is right or?
 

Silencer

New Member
Reaction score
0
Well i used it but i get as i said the "missing return" error... and with that i cant play the map. Any suggestions?
 

Silencer

New Member
Reaction score
0
But your hashtable version not contain the full code and i dont know how to build the rest =(
If i replace it, i will get many errors about missing variables...

Now i would be happy if i can write jass, its just these small spell that ruins my hole map, but i need it -.-

Can you take a look on it please? I add the spell below
 

Attachments

  • testmap.w3x
    22.9 KB · Views: 207

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
Hashtable version :
<div class="bbCodeBlock bbCodeBlock--screenLimited bbCodeBlock--code"><div class="bbCodeBlock-title">JASS:</div><div class="bbCodeBlock-content"><pre class="bbCodeCode"><code class="jass"><span class="keyword">library</span> <span>HandleVars</span>
    <span class="keyword">globals</span>
        <span class="keyword">private</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/hashtable" class="type">hashtable</a> <span>udg_cache</span> <span class="symbol">=</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/InitHashtable" class="native">InitHashtable</a><span class="symbol">(</span><span class="symbol">)</span>
    <span class="keyword">endglobals</span>
    
    <span class="preprocessor">//! textmacro HANDLE_VARS takes NAME, FUNCTION, TYPE, NULL_VALUE</span>
    <span class="keyword">function</span> <span>SH</span>$<span>NAME</span>$ <span class="keyword">takes</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/handle" class="type">handle</a> <span>s</span><span class="symbol">,</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/string" class="type">string</a> <span>n</span><span class="symbol">,</span> $<span>TYPE</span>$ <span>v</span> <span class="keyword">returns</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/nothing" class="type">nothing</a>
        <span class="keyword">if</span> <span>v</span><span class="symbol">=</span><span class="symbol">=</span>$<span>NULL_VALUE</span>$ <span class="keyword">then</span>
            <span class="keyword">call</span> <span>RemoveSaved</span>$<span>NAME</span>$<span class="symbol">(</span><span>udg_cache</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetHandleId" class="native">GetHandleId</a><span class="symbol">(</span><span>s</span><span class="symbol">)</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/StringHash" class="native">StringHash</a><span class="symbol">(</span><span>n</span><span class="symbol">)</span><span class="symbol">)</span>
        <span class="keyword">else</span>
            <span class="keyword">call</span> <span>Save</span>$<span>FUNCTION</span>$<span class="symbol">(</span><span>udg_cache</span><span class="symbol">,</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/GetHandleId" class="native">GetHandleId</a><span class="symbol">(</span><span>s</span><span class="symbol">)</span><span class="symbol">,</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/StringHash" class="native">StringHash</a><span class="symbol">(</span><span>n</span><span class="symbol">)</span><span class="symbol">,</span> <span>v</span><span class="symbol">)</span>
        <span class="keyword">endif</span>
    <span class="keyword">endfunction</span>
    <span class="preprocessor">//! endtextmacro</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS (&amp;quot;Handle&amp;quot;, &amp;quot;AgentHandle&amp;quot;, &amp;quot;agent&amp;quot;, &amp;quot;null&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS (&amp;quot;Integer&amp;quot;, &amp;quot;Integer&amp;quot;, &amp;quot;integer&amp;quot;, &amp;quot;0&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS (&amp;quot;Real&amp;quot;, &amp;quot;Real&amp;quot;, &amp;quot;real&amp;quot;, &amp;quot;0.&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS (&amp;quot;Boolean&amp;quot;, &amp;quot;Boolean&amp;quot;, &amp;quot;boolean&amp;quot;, &amp;quot;false&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS (&amp;quot;String&amp;quot;, &amp;quot;Str&amp;quot;, &amp;quot;string&amp;quot;, &amp;quot;null&amp;quot;)</span>
    
    <span class="preprocessor">//! textmacro HANDLE_VARS_GET takes TYPE, FUNC, type</span>
    <span class="keyword">function</span> <span>GH</span>$<span>TYPE</span>$ <span class="keyword">takes</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/handle" class="type">handle</a> <span>s</span><span class="symbol">,</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/string" class="type">string</a> <span>n</span> <span class="keyword">returns</span> $<span class="keyword">type</span>$
        <span class="keyword">return</span> <span>Load</span>$<span>FUNC</span>$<span class="symbol">(</span><span>udg_cache</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetHandleId" class="native">GetHandleId</a><span class="symbol">(</span><span>s</span><span class="symbol">)</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/StringHash" class="native">StringHash</a><span class="symbol">(</span><span>n</span><span class="symbol">)</span><span class="symbol">)</span>
    <span class="keyword">endfunction</span>
    <span class="preprocessor">//! endtextmacro</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS_GET (&amp;quot;Integer&amp;quot;,&amp;quot;Integer&amp;quot;,&amp;quot;integer&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS_GET (&amp;quot;Real&amp;quot;,&amp;quot;Real&amp;quot;,&amp;quot;real&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS_GET (&amp;quot;Boolean&amp;quot;,&amp;quot;Boolean&amp;quot;,&amp;quot;boolean&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS_GET (&amp;quot;String&amp;quot;,&amp;quot;Str&amp;quot;,&amp;quot;string&amp;quot;)</span>
    
    <span class="preprocessor">//! textmacro HANDLE_VARS_GETHANDLE takes TYPE, type</span>
    <span class="keyword">function</span> <span>GH</span>$<span>TYPE</span>$ <span class="keyword">takes</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/handle" class="type">handle</a> <span>s</span><span class="symbol">,</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/string" class="type">string</a> <span>n</span> <span class="keyword">returns</span> $<span class="keyword">type</span>$
        <span class="keyword">return</span> <span>Load</span>$<span>TYPE</span>$<span>Handle</span><span class="symbol">(</span><span>udg_cache</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetHandleId" class="native">GetHandleId</a><span class="symbol">(</span><span>s</span><span class="symbol">)</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/StringHash" class="native">StringHash</a><span class="symbol">(</span><span>n</span><span class="symbol">)</span><span class="symbol">)</span>
    <span class="keyword">endfunction</span>
    <span class="preprocessor">//! endtextmacro </span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS_GETHANDLE (&amp;quot;Unit&amp;quot;,&amp;quot;unit&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS_GETHANDLE (&amp;quot;Effect&amp;quot;,&amp;quot;effect&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS_GETHANDLE (&amp;quot;Lightning&amp;quot;,&amp;quot;lightning&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS_GETHANDLE (&amp;quot;Location&amp;quot;,&amp;quot;location&amp;quot;)</span>
    <span class="preprocessor">//! runtextmacro HANDLE_VARS_GETHANDLE (&amp;quot;Trigger&amp;quot;,&amp;quot;trigger&amp;quot;)</span>
        <span class="preprocessor">//! runtextmacro HANDLE_VARS_GETHANDLE (&amp;quot;Timer&amp;quot;,&amp;quot;timer&amp;quot;)</span>
    
    <span class="keyword">function</span> <span>FHLocals</span> <span class="keyword">takes</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/handle" class="type">handle</a> <span>s</span> <span class="keyword">returns</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/nothing" class="type">nothing</a>
        <span class="keyword">call</span> <a href="http://wiki.thehelper.net/wc3/jass/common.j/FlushChildHashtable" class="native">FlushChildHashtable</a><span class="symbol">(</span><span>udg_cache</span><span class="symbol">,</span><a href="http://wiki.thehelper.net/wc3/jass/common.j/GetHandleId" class="native">GetHandleId</a><span class="symbol">(</span><span>s</span><span class="symbol">)</span><span class="symbol">)</span>
    <span class="keyword">endfunction</span>
<span class="keyword">endlibrary</span></code></pre></div></div>

Use this, sorry. Typo for the functions&#039; name.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top