I am creating a summoning spell which summons units that deal damage based on the caster's intelligence upon attacking. I've done it by attaching the caster's handle id to the summoned units and saved the caster in a hashtable in the key his own handle id. It looks something like this:
Once the summoned unit attacks I retrieve its attached id, load the unit handle of that key and make the caster deal his damage.
It currently works fine, but Im uncertain of a few things -
1) Using the method which I displayed above; Does it create a leak if I overwrite the existing unit handle before flushing the hashtable?
2) Is it possible to store a unit's handle id and then at a later point convert the handle id to an actual unit handle without using a hashtable? It was the only option I could think of.
JASS:
local unit u = GetTriggerUnit()
local integer id = GetHandleId(u)
call SaveUnitHandle(hashtable, id, 0, u)
set u = null
It currently works fine, but Im uncertain of a few things -
1) Using the method which I displayed above; Does it create a leak if I overwrite the existing unit handle before flushing the hashtable?
2) Is it possible to store a unit's handle id and then at a later point convert the handle id to an actual unit handle without using a hashtable? It was the only option I could think of.