- Joined
- Apr 27, 2008
- Messages
- 2,455
After i've heard about a way to get shadow of units playing with images by Mag, i've made exhaustive tests about it :
EDIT : Read the other posts, you will lileky mess with with the internal stack if you destroy such images, but you can make them invisible.
Also i think it's good to be aware about this bug, i mean it could eventually ease a debug if you have forgotten to null an image variable and use it later.
Coz of the results i've also made other tests.
Conclusions :
The local handle id leak is still not fixed :/
But it makes sense that texttags and images are not concerned by this bug, because it seems that it can safely be used locally (created/destroyed...) within a GetLocalPlayer block.
At very least it's true with texttags, i haven't tested with images.
I've not sucesfully got the texttag displayed by abilities using the same trick as images.
I've tested it with the orc blademaster critical strike.
I suspect these texttags don't use the same stack/queue/whatever, as the ones created with triggers.
Again, that makes sense, since it's not because you've reached the hardcoded limit of 100 texttags with triggers, that these texttags are not displayed.
Also sounds don't seem to be pseudo handles according to their high handle id.
I've included a test map.
Oh, btw if you will never use images (also remove shadows of units on unit creation).
You even don't need to create/destroy image, just set your image variable default value to null, create the unit, get the shadow and destroy it : it's the "null" variable image.
But i don't recommend it, it's enough fair to create/destroy a new valid image.
EDIT : Read the other posts, you will lileky mess with with the internal stack if you destroy such images, but you can make them invisible.
Also i think it's good to be aware about this bug, i mean it could eventually ease a debug if you have forgotten to null an image variable and use it later.
JASS:
scope ShadowTest initializer init
function GetFutureNextImage takes nothing returns image
local image im = CreateImage("ReplaceableTextures\\Splats\\AuraRune9b.blp",0,0,0,0,0,0,0,0,0,1 )
call DestroyImage(im)
return im
endfunction
function CreateUnitAndGetShadow takes nothing returns image
local image i = CreateImage("ReplaceableTextures\\Splats\\AuraRune9b.blp",0,0,0,0,0,0,0,0,0,1 ) // the last argument (integer) can't be 0
// the image has to be created, else its id is -1, we have to use a valid string argument for the image
// note that textags have a lame convention, id == 0 means both the last valid texttag created and an invalid one (limit of 100 texttags reached)
call BJDebugMsg(I2S(GetHandleId(i))) // no handle id leak, woot, images are so special, or the handle id leak is fixed with locals ?!
// i'm wondering if it's the same with texttags and also with other pseudo handles (sounds ?!)
call DestroyImage(i)
// we need to create a valid image to get the next id handle, we destroy it to recycle it
call CreateUnit(Player(0), 'hpea', 0, 0, 270)
// the shadow will use the recycled id : i
return i
endfunction
private function init takes nothing returns nothing
local image shadow = CreateUnitAndGetShadow()
call DestroyImage(shadow)
set shadow = CreateUnitAndGetShadow()
call DestroyImage(shadow)
set shadow = GetFutureNextImage()
call CreateUnit(Player(0),'hfoo',0,0,0)
call DestroyImage(shadow)
endfunction
endscope
Coz of the results i've also made other tests.
JASS:
scope LocalUnitHandleIdLeak initializer init
globals
private integer I = 0
endglobals
private function Test takes nothing returns nothing
local unit u = CreateUnit(Player(0), 'hpea', 0, 0, 270)
set I = I+1
if I == 10 then
call PauseTimer(GetExpiredTimer())
endif
call BJDebugMsg("unit handle id == "+I2S(GetHandleId(u))) // local handle id leak is not fixed
call RemoveUnit(u)
endfunction
private function init takes nothing returns nothing
call TimerStart(CreateTimer(),0.1,true,function Test)
endfunction
endscope
JASS:
scope LocalTexttagHandleIdLeak initializer init
globals
private integer I = 0
endglobals
private function Test takes nothing returns nothing
local texttag x = CreateTextTag()
set I = I+1
if I == 10 then
call PauseTimer(GetExpiredTimer())
endif
call BJDebugMsg("texttag handle id == "+I2S(GetHandleId(x))) // same as image, no leak
call DestroyTextTag(x)
endfunction
private function init takes nothing returns nothing
call TimerStart(CreateTimer(),0.1,true,function Test)
endfunction
endscope
JASS:
scope TexttagTest initializer init
globals
private texttag Text = null
endglobals
private function Test takes nothing returns nothing
//call SetTextTagVisibility(Text,false)
call DestroyTextTag(Text)
call BJDebugMsg(I2S(GetHandleId(Text)))
endfunction
private function Act takes nothing returns nothing
call TimerStart(CreateTimer(),0.2,false,function Test)
endfunction
private function init takes nothing returns nothing
local trigger trig = CreateTrigger()
local integer i = 0
local unit u = CreateUnit(Player(0),'Hpal',0,0,0)
call TriggerRegisterUnitEvent(trig,u,EVENT_UNIT_DAMAGED)
call TriggerAddAction(trig,function Act)
loop
exitwhen i == 95
set i = i+1
call CreateTextTagLocBJ( I2S(i), Location(0,i*30-2000), 0, 10, 100, 100, 100, 0 ) // yeah horrible and leaks, quite a copy/paste of a GUI action :p
endloop
set Text = CreateTextTag()
call DestroyTextTag(Text)
call BJDebugMsg(I2S(GetHandleId(Text)))
endfunction
endscope
Conclusions :
The local handle id leak is still not fixed :/
But it makes sense that texttags and images are not concerned by this bug, because it seems that it can safely be used locally (created/destroyed...) within a GetLocalPlayer block.
At very least it's true with texttags, i haven't tested with images.
I've not sucesfully got the texttag displayed by abilities using the same trick as images.
I've tested it with the orc blademaster critical strike.
I suspect these texttags don't use the same stack/queue/whatever, as the ones created with triggers.
Again, that makes sense, since it's not because you've reached the hardcoded limit of 100 texttags with triggers, that these texttags are not displayed.
Also sounds don't seem to be pseudo handles according to their high handle id.
I've included a test map.
Oh, btw if you will never use images (also remove shadows of units on unit creation).
You even don't need to create/destroy image, just set your image variable default value to null, create the unit, get the shadow and destroy it : it's the "null" variable image.
But i don't recommend it, it's enough fair to create/destroy a new valid image.
Attachments
Last edited: