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