how to fix these return bugss

INCINERATE

New Member
Reaction score
12
JASS:
//Return Bug

function H2I takes handle h returns integer
    return h
    return 0
endfunction
function I2H takes integer i returns handle
    return i
    return null
endfunction
function I2U takes integer i returns unit
    return i
    return null
endfunction
function I2G takes integer i returns group
    return i
    return null
endfunction
function I2E takes integer i returns effect
    return i
    return null
endfunction
function I2T takes integer i returns timer
    return i
    return null
endfunction
function I2TD takes integer i returns terraindeformation
    return i
    return null
endfunction


//End Return Bug



i know how to fix the first one (H2I) but how about the rest of them? what to dewwwwwww :confused:
 

overload119

New Member
Reaction score
5
Well GetHandleId is the root for H2I.

Unfortunately, you can only convert the integer to different types using the LoadLightningHashtable (something like that), so you cant create a function to convert it to what you want unfortunately.

You'll just either have to use structs, or hashtables.
 

INCINERATE

New Member
Reaction score
12
thanks overload for insight +rep,

also kingking , whats an example fix for lets say

function I2U takes integer i returns unit
return i
return null

how would i fix this using your library? i just need to example :p
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
JASS:
function I2U takes integer i returns unit
   return Int2Unit(i)
endfunction


Do that for all return bugs, and then you can continue to use theses functions without edit the rest of your code.
It's the easiest evil way.
The best is learning to use structs, and in general basic of vJass.

EDIT : And basically agent == handle, that's not really true but you don't really need more informations.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
function H2I takes handle h returns integer
    return GetHandleId(h)
endfunction
function I2H takes integer i returns handle
    debug call BJDebugMsg("Error, don't use I2H from now.")
    return null
endfunction
function I2U takes integer i returns unit
    return Int2Unit(i)
endfunction
function I2G takes integer i returns group
    return Int2Group(i)
endfunction
function I2E takes integer i returns effect
    return Int2Effect(i)
endfunction
function I2T takes integer i returns timer
    return Int2Timer(i)
endfunction


Here is a quick fix for terrain deformation, but you need to use TD2I instead of H2I for it. After you using it, please use FlushTD.
JASS:
library TerrainDeformation2Int
    
    globals
        private hashtable ht = InitHashtable()
    endglobals
    
    private struct Wrapper
        terraindeformation td
    endstruct
    
    function TD2I takes terraindeformation td returns integer
        local Wrapper d = LoadInteger(ht,GetHandleId(td),0)
        if d == 0 then
            set d = Wrapper.create()
            set d.td = td
            call SaveInteger(ht,GetHandleId(td),0,d)
        endif
        return d
    endfunction
    
    function I2TD takes integer i returns terraindeformation
        return Wrapper(i).td
    endfunction
    
    function FlushTD takes terraindeformation td returns nothing
        local Wrapper d = LoadInteger(ht,GetHandleId(td),0)
        if d > 0 then
            call d.destroy()
        endif
    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