Why should you use this?
You should use this because it's safe and because it's really as fast as you can get it but still safe.
This is safe because it works until your (handle amount - Your handles at start > 400 000) which is pretty extremely high.
Changelog
You should use this because it's safe and because it's really as fast as you can get it but still safe.
This is safe because it works until your (handle amount - Your handles at start > 400 000) which is pretty extremely high.
JASS:
//*******************************************************
//* *
//* Textmacro Abusing Attachment System *
//* TMAAS v1.2 *
//* By: Gwypaaas *
//*_____________________________________________________*
//* About *
//* This system uses H2I to store the value into an *
//* array. This system is very fast if the ID the *
//* system uses is less then 8191, otherwise it stores *
//* your struct into a premade array with 409550 size. *
//*_____________________________________________________*
//* *
//* Usage *
//* *
//* Create a new trigger named "TMAAS" and paste all *
//* this code into it. When you use this system remember*
//* that you cannot use associations to the attached *
//* struct until after the textmacro. Also, you cannot *
//* use the textmacro before the locals since that *
//* will cause a syntax error. *
//* *
//* The usage of the Textmacros is explained below. *
//* ____________________________________________________*
//*
//*
//*
//* This system contains these macros:
//*
//* //! runtextmacro TMAAS_Attach ("<Name of Handle variable>", "<Name of struct variable>")
//* //! runtextmacro TMAAS_Get ("<Name of Handle variable>", "<To which variable the attachment should be set>")
//*
//*
//*
//* Pros:
//* Really fast because it is inlined
//* Pretty handle safe since it decreases the handle amount that is in the map at time 0.0
//* Cons:
//* Can't get the variable without the use of a textmacro,
//* therefore you can't use the struct in the local declaration.
//*
//*******************************************************
library_once TMAAS initializer init
globals
public integer DECREASE = 0x100000
public integer array DATAZ
public integer array DATAZBIG[409550]
public integer Temp
endglobals
public function H2I takes handle h returns integer
return h
return 0
endfunction
//! textmacro TMAAS_Attach takes HANDLE, STRUCT
set TMAAS_Temp = TMAAS_H2I($HANDLE$) - TMAAS_DECREASE
if TMAAS_Temp < 8191 then
set TMAAS_DATAZ[TMAAS_Temp] = $STRUCT$
else
set TMAAS_DATAZBIG[TMAAS_Temp] = $STRUCT$
endif
//! endtextmacro
//! textmacro TMAAS_Get takes HANDLE, STRUCT
set TMAAS_Temp = TMAAS_H2I($HANDLE$) - TMAAS_DECREASE
if TMAAS_Temp < 8191 then
set $STRUCT$ = TMAAS_DATAZ[TMAAS_Temp]
else
set $STRUCT$ = TMAAS_DATAZBIG[TMAAS_Temp]
endif
//! endtextmacro
private function SetDecrease takes nothing returns nothing
set TMAAS_DECREASE = TMAAS_H2I(CreateTrigger())
endfunction
private function init takes nothing returns nothing
call TimerStart(CreateTimer(), 0.00, false, function SetDecrease)
endfunction
endlibrary
Changelog
v 1.2 - Rewrote the init function so it didn't need to create any trigger. Improved documentation.
v 1.1 - Made everything public so it won't collide with something else and made it use library_once so you can't import 2 systems.
v 1.0 - Initial Release
v 1.1 - Made everything public so it won't collide with something else and made it use library_once so you can't import 2 systems.
v 1.0 - Initial Release