Peón

Barra de Salud : 
Mensajes : 41
Reputación : 9 Monedas de oro : 245 
Inventario :  
 | (#) Tema: Faux JASS y vJASS Dom Ago 11, 2013 9:15 pm | |
| Hola! no soy el autor original ni nada de eso, no es mi code, pero me parece que es algo que no puede faltar. - Versión actualizada:
-
library Faux
globals private hashtable ht = InitHashtable() endglobals function SetHandleHandle takes integer id, string name, agent value returns nothing call SaveAgentHandle(ht, id, StringHash(name), value) endfunction function SetHandleInt takes integer id, string name, integer value returns nothing call SaveInteger(ht, id, StringHash(name), value) endfunction function SetHandleBoolean takes integer id, string name, boolean value returns nothing call SaveBoolean(ht, id, StringHash(name), value) endfunction function SetHandleReal takes integer id, string name, real value returns nothing call SaveReal(ht, id, StringHash(name), value) endfunction function SetHandleString takes integer id, string name, string value returns nothing call SaveStr(ht, id, StringHash(name), value) endfunction function SetHandleLightning takes integer id, string name, lightning value returns nothing call SaveLightningHandle(ht, id, StringHash(name), value) endfunction function SetHandleTA takes integer id, string name, triggeraction value returns nothing call SaveTriggerActionHandle(ht, id, StringHash(name), value) endfunction function SetHandleTextTag takes integer id, string name, texttag value returns nothing call SaveTextTagHandle(ht, id, StringHash(name), value) endfunction
function GetHandleInt takes integer id, string name returns integer return LoadInteger(ht, id, StringHash(name)) endfunction function GetHandleBoolean takes integer id, string name returns boolean return LoadBoolean(ht, id, StringHash(name)) endfunction function GetHandleReal takes integer id, string name returns real return LoadReal(ht, id, StringHash(name)) endfunction function GetHandleString takes integer id, string name returns string return LoadStr(ht, id, StringHash(name)) endfunction function GetHandleUnit takes integer id, string name returns unit return LoadUnitHandle(ht, id, StringHash(name)) endfunction function GetHandleItem takes integer id, string name returns item return LoadItemHandle(ht, id, StringHash(name)) endfunction function GetHandleTimer takes integer id, string name returns timer return LoadTimerHandle(ht, id, StringHash(name)) endfunction function GetHandleTrigger takes integer id, string name returns trigger return LoadTriggerHandle(ht, id, StringHash(name)) endfunction function GetHandleTA takes integer id, string name returns triggeraction return LoadTriggerActionHandle(ht, id, StringHash(name)) endfunction function GetHandleEffect takes integer id, string name returns effect return LoadEffectHandle(ht, id, StringHash(name)) endfunction function GetHandleGroup takes integer id, string name returns group return LoadGroupHandle(ht, id, StringHash(name)) endfunction function GetHandleLightning takes integer id, string name returns lightning return LoadLightningHandle(ht, id, StringHash(name)) endfunction function GetHandleWidget takes integer id, string name returns widget return LoadWidgetHandle(ht, id, StringHash(name)) endfunction function GetHandleLocation takes integer id, string name returns location return LoadLocationHandle(ht, id, StringHash(name)) endfunction function GetHandlePlayer takes integer id, string name returns player return LoadPlayerHandle(ht, id, StringHash(name)) endfunction function GetHandleRegion takes integer id, string name returns region return LoadRegionHandle(ht, id, StringHash(name)) endfunction function GetHandleRect takes integer id, string name returns rect return LoadRectHandle(ht, id, StringHash(name)) endfunction function GetHandleForce takes integer id, string name returns force return LoadForceHandle(ht, id, StringHash(name)) endfunction function GetHandleFogmodifier takes integer id, string name returns fogmodifier return LoadFogModifierHandle(ht, id, StringHash(name)) endfunction function GetHandleTimerDialog takes integer id, string name returns timerdialog return LoadTimerDialogHandle(ht, id, StringHash(name)) endfunction function GetHandleTextTag takes integer id, string name returns texttag return LoadTextTagHandle(ht, id, StringHash(name)) endfunction
function HaveHandleHandle takes integer id, string name returns boolean return HaveSavedHandle(ht, id, StringHash(name)) endfunction function HaveHandleInt takes integer id, string name returns boolean return HaveSavedInteger(ht, id, StringHash(name)) endfunction function HaveHandleReal takes integer id, string name returns boolean return HaveSavedReal(ht, id, StringHash(name)) endfunction function HaveHandleString takes integer id, string name returns boolean return HaveSavedString(ht, id, StringHash(name)) endfunction function HaveHandleBoolean takes integer id, string name returns boolean return HaveSavedBoolean(ht, id, StringHash(name)) endfunction
function RemoveHandle takes integer id, string name returns nothing call SaveAgentHandle(ht,id,StringHash(name), null) call RemoveSavedHandle(ht,id,StringHash(name)) endfunction function RemoveInt takes integer id, string name returns nothing call SaveInteger(ht,id,StringHash(name), 0) call RemoveSavedInteger(ht,id,StringHash(name)) endfunction function RemoveReal takes integer id, string name returns nothing call SaveReal(ht,id,StringHash(name), 0.0) call RemoveSavedReal(ht,id,StringHash(name)) endfunction function RemoveBoolean takes integer id, string name returns nothing call SaveBoolean(ht,id,StringHash(name), false) call RemoveSavedBoolean(ht,id,StringHash(name)) endfunction function RemoveStr takes integer id, string name returns nothing call SaveStr(ht,id,StringHash(name), null) call RemoveSavedString(ht,id,StringHash(name)) endfunction
function FlushHandleLocals takes integer id returns nothing call FlushChildHashtable(ht, id ) endfunction endlibrary
- Version vJASS:
-
[jass]library Faux globals private hashtable ht = InitHashtable() endglobals function SetHandleHandle takes handle subject, string name, agent value returns nothing call SaveAgentHandle(ht, GetHandleId(subject), StringHash(name), value) endfunction function SetHandleInt takes handle subject, string name, integer value returns nothing call SaveInteger(ht, GetHandleId(subject), StringHash(name), value) endfunction function SetHandleBoolean takes handle subject, string name, boolean value returns nothing call SaveBoolean(ht, GetHandleId(subject), StringHash(name), value) endfunction function SetHandleReal takes handle subject, string name, real value returns nothing call SaveReal(ht, GetHandleId(subject), StringHash(name), value) endfunction function SetHandleString takes handle subject, string name, string value returns nothing call SaveStr(ht, GetHandleId(subject), StringHash(name), value) endfunction function SetHandleLightning takes handle subject, string name, lightning value returns nothing call SaveLightningHandle(ht, GetHandleId(subject), StringHash(name), value) endfunction function SetHandleTA takes handle subject, string name, triggeraction value returns nothing call SaveTriggerActionHandle(ht, GetHandleId(subject), StringHash(name), value) endfunction function SetHandleTextTag takes handle subject, string name, texttag value returns nothing call SaveTextTagHandle(ht, GetHandleId(subject), StringHash(name), value) endfunction
function GetHandleInt takes handle subject, string name returns integer return LoadInteger(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleBoolean takes handle subject, string name returns boolean return LoadBoolean(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleReal takes handle subject, string name returns real return LoadReal(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleString takes handle subject, string name returns string return LoadStr(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleUnit takes handle subject, string name returns unit return LoadUnitHandle(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleItem takes handle subject, string name returns item return LoadItemHandle(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleTimer takes handle subject, string name returns timer return LoadTimerHandle(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleTrigger takes handle subject, string name returns trigger return LoadTriggerHandle(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleTA takes handle subject, string name returns triggeraction return LoadTriggerActionHandle(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleEffect takes handle subject, string name returns effect return LoadEffectHandle(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleGroup takes handle subject, string name returns group return LoadGroupHandle(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleLightning takes handle subject, string name returns lightning return LoadLightningHandle(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleWidget takes handle subject, string name returns widget return LoadWidgetHandle(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleLocation takes handle subject, string name returns location return LoadLocationHandle(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandlePlayer takes handle subject, string name returns player return LoadPlayerHandle(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleRegion takes handle subject, string name returns region return LoadRegionHandle(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleRect takes handle subject, string name returns rect return LoadRectHandle(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleForce takes handle subject, string name returns force return LoadForceHandle(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleFogmodifier takes handle subject, string name returns fogmodifier return LoadFogModifierHandle(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleTimerDialog takes handle subject, string name returns timerdialog return LoadTimerDialogHandle(ht, GetHandleId(subject), StringHash(name)) endfunction function GetHandleTextTag takes handle subject, string name returns texttag return LoadTextTagHandle(ht, GetHandleId(subject), StringHash(name)) endfunction
function HaveHandleHandle takes handle subject, string name returns boolean return HaveSavedHandle(ht, GetHandleId(subject), StringHash(name)) endfunction function HaveHandleInt takes handle subject, string name returns boolean return HaveSavedInteger(ht, GetHandleId(subject), StringHash(name)) endfunction function HaveHandleReal takes handle subject, string name returns boolean return HaveSavedReal(ht, GetHandleId(subject), StringHash(name)) endfunction function HaveHandleString takes handle subject, string name returns boolean return HaveSavedString(ht, GetHandleId(subject), StringHash(name)) endfunction function HaveHandleBoolean takes handle subject, string name returns boolean return HaveSavedBoolean(ht, GetHandleId(subject), StringHash(name)) endfunction
function RemoveHandle takes handle subject, string name returns nothing call SaveAgentHandle(ht,GetHandleId(subject),StringHash(name), null) call RemoveSavedHandle(ht,GetHandleId(subject),StringHash(name)) endfunction function RemoveInt takes handle subject, string name returns nothing call SaveInteger(ht,GetHandleId(subject),StringHash(name), 0) call RemoveSavedInteger(ht,GetHandleId(subject),StringHash(name)) endfunction function RemoveReal takes handle subject, string name returns nothing call SaveReal(ht,GetHandleId(subject),StringHash(name), 0.0) call RemoveSavedReal(ht,GetHandleId(subject),StringHash(name)) endfunction function RemoveBoolean takes handle subject, string name returns nothing call SaveBoolean(ht,GetHandleId(subject),StringHash(name), false) call RemoveSavedBoolean(ht,GetHandleId(subject),StringHash(name)) endfunction function RemoveStr takes handle subject, string name returns nothing call SaveStr(ht,GetHandleId(subject),StringHash(name), null) call RemoveSavedString(ht,GetHandleId(subject),StringHash(name)) endfunction
function FlushHandleLocals takes handle subject returns nothing call FlushChildHashtable(ht, GetHandleId(subject) ) endfunction endlibrary [/jass]
- Version JASS:
-
[jass]function SetHandleHandle takes handle subject, string name, agent value returns nothing call SaveAgentHandle(udg_HashTable, GetHandleId(subject), StringHash(name), value) endfunction function SetHandleInt takes handle subject, string name, integer value returns nothing call SaveInteger(udg_HashTable, GetHandleId(subject), StringHash(name), value) endfunction function SetHandleBoolean takes handle subject, string name, boolean value returns nothing call SaveBoolean(udg_HashTable, GetHandleId(subject), StringHash(name), value) endfunction function SetHandleReal takes handle subject, string name, real value returns nothing call SaveReal(udg_HashTable, GetHandleId(subject), StringHash(name), value) endfunction function SetHandleString takes handle subject, string name, string value returns nothing call SaveStr(udg_HashTable, GetHandleId(subject), StringHash(name), value) endfunction function SetHandleLightning takes handle subject, string name, lightning value returns nothing call SaveLightningHandle(udg_HashTable, GetHandleId(subject), StringHash(name), value) endfunction function SetHandleTA takes handle subject, string name, triggeraction value returns nothing call SaveTriggerActionHandle(udg_HashTable, GetHandleId(subject), StringHash(name), value) endfunction function SetHandleTextTag takes handle subject, string name, texttag value returns nothing call SaveTextTagHandle(udg_HashTable, GetHandleId(subject), StringHash(name), value) endfunction
function GetHandleInt takes handle subject, string name returns integer return LoadInteger(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleBoolean takes handle subject, string name returns boolean return LoadBoolean(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleReal takes handle subject, string name returns real return LoadReal(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleString takes handle subject, string name returns string return LoadStr(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleUnit takes handle subject, string name returns unit return LoadUnitHandle(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleItem takes handle subject, string name returns item return LoadItemHandle(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleTimer takes handle subject, string name returns timer return LoadTimerHandle(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleTrigger takes handle subject, string name returns trigger return LoadTriggerHandle(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleTA takes handle subject, string name returns triggeraction return LoadTriggerActionHandle(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleEffect takes handle subject, string name returns effect return LoadEffectHandle(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleGroup takes handle subject, string name returns group return LoadGroupHandle(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleLightning takes handle subject, string name returns lightning return LoadLightningHandle(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleWidget takes handle subject, string name returns widget return LoadWidgetHandle(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleLocation takes handle subject, string name returns location return LoadLocationHandle(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandlePlayer takes handle subject, string name returns player return LoadPlayerHandle(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleRegion takes handle subject, string name returns region return LoadRegionHandle(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleRect takes handle subject, string name returns rect return LoadRectHandle(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleForce takes handle subject, string name returns force return LoadForceHandle(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleFogmodifier takes handle subject, string name returns fogmodifier return LoadFogModifierHandle(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleTimerDialog takes handle subject, string name returns timerdialog return LoadTimerDialogHandle(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function GetHandleTextTag takes handle subject, string name returns texttag return LoadTextTagHandle(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction
function HaveHandleHandle takes handle subject, string name returns boolean return HaveSavedHandle(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function HaveHandleInt takes handle subject, string name returns boolean return HaveSavedInteger(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function HaveHandleReal takes handle subject, string name returns boolean return HaveSavedReal(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function HaveHandleString takes handle subject, string name returns boolean return HaveSavedString(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction function HaveHandleBoolean takes handle subject, string name returns boolean return HaveSavedBoolean(udg_HashTable, GetHandleId(subject), StringHash(name)) endfunction
function RemoveHandle takes handle subject, string name returns nothing call SaveAgentHandle(udg_HashTable,GetHandleId(subject),StringHash(name), null) call RemoveSavedHandle(udg_HashTable,GetHandleId(subject),StringHash(name)) endfunction function RemoveInt takes handle subject, string name returns nothing call SaveInteger(udg_HashTable,GetHandleId(subject),StringHash(name), 0) call RemoveSavedInteger(udg_HashTable,GetHandleId(subject),StringHash(name)) endfunction function RemoveReal takes handle subject, string name returns nothing call SaveReal(udg_HashTable,GetHandleId(subject),StringHash(name), 0.0) call RemoveSavedReal(udg_HashTable,GetHandleId(subject),StringHash(name)) endfunction function RemoveBoolean takes handle subject, string name returns nothing call SaveBoolean(udg_HashTable,GetHandleId(subject),StringHash(name), false) call RemoveSavedBoolean(udg_HashTable,GetHandleId(subject),StringHash(name)) endfunction function RemoveStr takes handle subject, string name returns nothing call SaveStr(udg_HashTable,GetHandleId(subject),StringHash(name), null) call RemoveSavedString(udg_HashTable,GetHandleId(subject),StringHash(name)) endfunction
function FlushHandleLocals takes handle subject returns nothing call FlushChildHashtable(udg_HashTable, GetHandleId(subject) ) endfunction[/jass]
Es para utilizar hashtables de manera más amigable. Brinda la capacidad de hacer attach de handles con algún otro tipo de variable. Tiene una buena API, hace que tu código sea más entendible, para los speed freaks, no se preocupen que la opción para optimizar del NewGen hace inline de funciones. Agradecimientos al creador del código Muzk.. |
|