- Joined
- Sep 21, 2007
- Messages
- 517
its pretty darn simple, but i didnt see it in jass section (maybe its just me ofc), anyways the only negative thing it has about it is that u have to create an id for a handle so that it can be used later. Here is the code:
i did see one used in loops, and a hashtable one that doesnt support every type of handle, but the only limitation here is that it can only have a maximum of 8191 handles, its possible to do another, but il have to add if/then/else calls, anyways, this seems to work pretty well; should i submit in JASS functions section or is it just too dam simple? btw i will prob add a function to remove an id soon
JASS:
library HandleIds
globals
private hashtable ht = InitHashtable()
private integer maxId = -1
private handle array Handle[8191]
endglobals
function CreateId takes handle h returns integer
set maxId = maxId + 1
set Handle[maxId] = h
call SaveInteger( ht, GetHandleId(h), 0, maxId )
return maxId
endfunction
function GetId takes handle h returns integer
return LoadInteger( ht, GetHandleId(h), 0 )
endfunction
function GetHandle takes integer i returns handle
return Handle[ LoadInteger( ht, i, 0 ) ]
endfunction
endlibrary
i did see one used in loops, and a hashtable one that doesnt support every type of handle, but the only limitation here is that it can only have a maximum of 8191 handles, its possible to do another, but il have to add if/then/else calls, anyways, this seems to work pretty well; should i submit in JASS functions section or is it just too dam simple? btw i will prob add a function to remove an id soon
Last edited: