| 11-17-2009, 06:08 AM | #1 |
How do I do it? Syntax-checker (PJASS) friendly, please. I need to be able to use vJASS and what not, wthout any errors. |
| 11-17-2009, 06:28 AM | #2 |
http://www.wc3c.net/showthread.php?t=108152 You really shouldn't do it, though, if it is at all avoidable for your map. Let us move forward and use hashtables in this day and age. |
| 11-17-2009, 06:33 AM | #3 |
I don't understand that method... |
| 11-17-2009, 06:47 AM | #4 |
Read this. Using that framework, I2H would be like this and it should work; JASS:library Typecast globals private hashtable HASH = InitHashtable() endglobals //! textmacro TYPECAST_MACRO takes NAME, HANDLE, RETURN, HASHFUNC, NOT_HANDLE function $NAME$ takes $HANDLE$ var returns $RETURN$ static if ($NOT_HANDLE$) then call SaveFogStateHandle(HASH, 0,0, ConvertFogState(var)) return $HASHFUNC$(HASH, 0, 0) else call SaveFogStateHandle(HASH, 0, 0, ConvertFogState(GetHandleId(var))) return $HASHFUNC$(HASH, 0, 0) endif endfunction //! endtextmacro //! runtextmacro TYPECAST_MACRO("I2H", "integer", "handle", "LoadAgentHandle", "true") endlibrary |
| 11-17-2009, 06:51 AM | #5 |
Thanks. |
| 11-17-2009, 06:54 AM | #6 |
I wrote a more understandable example 'framework' for AotZ. I also provided some examples of the I2H textmacros. JASS:library Typecaster //* BY: Rising_Dusk //* Credits to Weaaddar for discovering this implementation //* //* Based on the following example: //* //* local hashtable ht = InitHashtable(); //* local unit u = CreateUnit(Player(0),'hfoo',0,0,0) //* local integer handleID = GetHandleId(u); //* local fogstate h = ConvertFogState(handleID); //* local agent a; //* call SaveFogStateHandle(ht, 0,0,h); //* set a = LoadUnitHandle(ht, 0, 0); //* call BJDebugMsg(I2S(GetHandleId(a))); //* globals private hashtable ht = InitHashtable() endglobals function H2I takes handle h returns integer local integer i = GetHandleId(h) call SaveFogStateHandle(ht, 0, i, ConvertFogState(i)) return i endfunction //! textmacro I2H takes NAME, RETURNTYPE, HASHFUNC function $NAME$ takes integer i returns $RETURNTYPE$ return $HASHFUNC$(ht, 0, i) endfunction //! endtextmacro //! runtextmacro I2H("I2U", "unit", "LoadUnitHandle") //! runtextmacro I2H("I2Timer", "timer", "LoadTimerHandle") //! runtextmacro I2H("I2Trigger", "trigger", "LoadTriggerHandle") //! runtextmacro I2H("I2TriggerAct", "triggeraction", "LoadTriggerActionHandle") //! runtextmacro I2H("I2TriggerCond", "triggercondition", "LoadTriggerConditionHandle") //! runtextmacro I2H("I2E", "effect", "LoadEffectHandle") //! runtextmacro I2H("I2G", "group", "LoadGroupHandle") endlibrary |
| 11-17-2009, 06:56 AM | #7 | |
Quote:
It was in weaaddar's thread, and it's not like I am submitting it. |
| 11-17-2009, 06:56 AM | #8 |
Nor am I, but honestly, it's the right thing to do. (Even in an example) |
