HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

CreateTextTagUnitBJ

08-12-2006, 10:25 AM#1
Sharingan
Collapse JASS:
function CreateTextTagUnitBJ takes string s, unit whichUnit, real zOffset, real size, real red, real green, real blue, real transparency returns texttag
    set bj_lastCreatedTextTag = CreateTextTag()
    call SetTextTagTextBJ(bj_lastCreatedTextTag, s, size)
    call SetTextTagPosUnitBJ(bj_lastCreatedTextTag, whichUnit, zOffset)
    call SetTextTagColorBJ(bj_lastCreatedTextTag, red, green, blue, transparency)

    return bj_lastCreatedTextTag
endfunction
Does this function leak?
I don't really know what they mean by "bj_lastcreatedtexttag"...
Is that a "global" or something?
08-12-2006, 10:49 AM#2
Captain Griffen
bj_lastCreatedTextTag is a global defined in the blizzard.j file.

It doesn't leak (though remember to destroy the text tag).
08-12-2006, 11:17 AM#3
iNfraNe
destroy or set fadepoint/lifespan. It'll be destroyed after its lifespan.
08-12-2006, 06:04 PM#4
Sharingan
If a tag's Fadepoints/Lifespan is expired, it's gets automaticly destroyed?
08-12-2006, 06:28 PM#5
DioD
Yes, if texttag not permanen it will destroy itself and all vars to it.
Soo no need to set texttag vars to null.
08-12-2006, 07:27 PM#6
Captain Griffen
Quote:
Originally Posted by DioD
Yes, if texttag not permanen it will destroy itself and all vars to it.
Soo no need to set texttag vars to null.

Wrong. Local variable pointers will still leak.
08-12-2006, 09:06 PM#7
DioD
null cant leak...

You can test it self, make tag destroy it and get var's value.
08-12-2006, 11:08 PM#8
The)TideHunter(
Quote:
Originally Posted by DioD
null cant leak...

You can test it self, make tag destroy it and get var's value.

DioD, you are wrong.
If you see what the vars value is, after you destroy it, it will obviously be nothing.
BUT, it still has a pointer, every variable pointing to that source dosent get auto-removed, you need to null all variable pointers once you have destroyed the souce.
Jass dosent have a garbage collector.

EDIT: Just to show you a example, i wrote this.
Collapse JASS:
function Mkay takes nothing returns nothing
    local unit TheUnit = CreateUnit(...)
    call RemoveUnit(TheUnit)
endfunction

That will leak a pointer.
YES you destroyed the handle, put TheUnit is still pointing somewhere.
You need to null handles (not timers for some reason) after you have used them.
The correct solution is:

Collapse JASS:
function Mkay takes nothing returns nothing
    local unit TheUnit = CreateUnit(...)
    call RemoveUnit(TheUnit) // Destroy Unit
    set TheUnit = null // Destroy pointer
endfunction
08-12-2006, 11:59 PM#9
Captain Griffen
Timers still have to be nulled. However, nulling a timer may have adverse consequences.

However, I think that it only bugs if you destroy it, and then it finishes again, so as long as you pause the timer before you destroy it, it will be fine.
08-13-2006, 12:22 AM#10
DioD

I am not a noob...

Check this with text tag here function for it.

Collapse JASS:
function FadeTextTag takes string Text , real X , real Y returns nothing
    local texttag FTT     = CreateTextTag()
    call SetTextTagText     (FTT,Text,.024)
    call SetTextTagPos      (FTT,X,Y,0    )
    call SetTextTagColor    (FTT,255,220,0,255)
    call SetTextTagVelocity (FTT,0,.03    )
    call SetTextTagFadepoint(FTT,2        )
    call SetTextTagLifespan (FTT,3        )
    call SetTextTagPermanent(FTT,false    )
    call SetTextTagVisibility(FTT , true)
endfunction


Tag have 100 ID only, run it 100 time for a test.
0.01 timer will help you.

And then call ONE MORE TIME.
08-13-2006, 02:54 AM#11
Alevice
If my rudimentary experiments are correct, Destroy functions get the car out of the parking zone, but don't free the "slot" for another car to park there.
08-13-2006, 02:59 AM#12
Vexorian
Since texttags use another memory space different to the "real" handles they probably don't have the issue that makes the "real" handles require you to null them.
08-13-2006, 03:18 AM#13
DioD
They uses real handles, but handles multi demension type.

Same ID can be used by different object types.
08-13-2006, 04:49 AM#14
Vexorian
Don't know what the heck you meant by that.

But oh well "handles" as a group is something kind of virtual, by hacking the engine Pipedream found out that handle is just a disguise for the integer type, but some handles behave in a very proper way. And those are units/items/doodads/triggers/regions/... And they all have the indexes in the same group of indexes. And their variables seem to behave the same way (as in requiring nulling without leaks, they seem to hold smart pointers and not just a reference to a handle.) Probably texttags that belong to another kind of handle subgroup don't have bugged local variables.