• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[JASS] I2H is back, could someone need it?

Status
Not open for further replies.
Level 13
Joined
Mar 16, 2008
Messages
941
Yes I know that I2H was unsave, but that doesn't matter because it got removed in the last patch (half, the rest will come).

I just thought about this, didn't test it (spelling mistakes) but it should work, could someone need it?
JASS:
library Integer2Handle initializer Init

    globals
        private hashtable hash = InitHashtable()
    endglobals

    function Integer2Handle takes integer i returns handle
        return LoadUnitHandle(hash, i, 0)
    endfunction
    
    
    private function SaveUnit takes nothing returns nothing
        call SaveUnitHandle(hash, GetHandleId(GetTriggerUnit()), 0, GetTriggerUnit())
    endfunction
    
    private function ReturnTrue takes nothing returns boolean
        return true
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local region r = CreateReagion()
        
        call RegionAddRect(r, bj_mapInitialPlayableArea)
        call TriggerRegisterEnterRegion(t, r, Condition(function ReturnTrue))         
        
        call TriggerAddCondition(t, Condition(SaveUnit))
    endfunction
endlibrary
I don't know, since hashtables allow to store units directly, I2H seems to be unimportant, but I was bored :)

Ideas?

EDIT: Maybe usefull with TimerUtils, since they only allow to store integers... who knows^^
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
I created such a thing that supports any type of handle, 2 versions actually,,
Here is the link: http://www.hiveworkshop.com/forums/submissions-414/i2h-without-typecasting-138267/
You can enable different types with one line of textmacro.. e.g:
JASS:
//! runtextmacro HANDLEID("Unit", "unit")
// this enables GetUnitIdEx and GetIdUnitEx
//! runtextmacro HANDLEID("Item , "item") 
// this enables GetItemIdEx and GetIdItemEx
 
Level 13
Joined
Mar 16, 2008
Messages
941
Oh well, but that's not the same thing.
Yours is a complete new index. It's not typecasting but creating a new HandleId outside of the wc3 core. Mine works with the index from GetHandleId :p
Don't say mine is usefull ,just think it's fun D: in theory this could be done with every handle that gets created dynamicly, going to work on this for fun :D
 
Level 13
Joined
Mar 16, 2008
Messages
941
Ah ok, see it now, didn't take an exact look after reading your description. But isn't this basicly the same idea then mine while you loop through structs instead of the hashtable lookup? To say it correctly, mine is the same idea then yours since yours was the first one, but I didn't know it :D
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
It actually is, only i took all warcraft types and made them in one system, where yours only supports units. I created 2 versions,,
1. Struct-version: supports all warcraft-types, and custom types,, usefull for maps with many custom types, but has an 8192 limit-count per type.
2. Hashtable-version: supports all types that hashtable supports, usefull for maps that use standard types, has no limit.
 
Status
Not open for further replies.
Top