• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Destroy Texttag @ another Generic JASS Question

Status
Not open for further replies.
Level 2
Joined
Oct 3, 2009
Messages
20
Moinmoin!

Started with JASS like 1 Hour ago and im having fun so far.

Currently replacing my GUI function that shows up floating Text with Damage Done.

Question #1:
Do non-Destroyed Texttags Leak?

If so, how can i have a Texttag destroyed after x Seconds?



Question #2:
For Each own written Trigger, i create a Trigger in GUI.
Tried to paste my triggers in the "Custom Script Area", but the triggers arent initialized when doing so. Tried to call the Initializing function, but it returns me a "Awaiting end of line"-Error.
Any Ideas?


Thanks in Advance!
 
Level 12
Joined
Jul 27, 2008
Messages
1,181
1) I think they do... and I was right: type texttag extends handle. Anything that extends handle (and I think agent too) leaks if not destroyed.

2) The trigger init functions cannot be inside the header. You can put them all in 1 trigger though, (only JASS) and merge the init functions to one.
 
Level 2
Joined
Oct 3, 2009
Messages
20
1) I think they do... and I was right: type texttag extends handle. Anything that extends handle (and I think agent too) leaks if not destroyed.

2) The trigger init functions cannot be inside the header. You can put them all in 1 trigger though, (only JASS) and merge the init functions to one.


@2: Thanks :)

@1: Any Idea how to destroy them, but still have em displayed for x seconds?
 
Level 12
Joined
Jul 27, 2008
Messages
1,181
Bind them to a timer. Use a hashtable to do the job. Hold on, gonna post the code in a sec.

EDIT: Here goes:
JASS:
function TimedText_Timer takes nothing returns nothing
    call DestroyTextTag(LoadTextTagHandle(udg_TextTagTable, GetHandleId(GetExpiredTimer()), 0))
    call FlushChildHashtable(udg_TextTagTable, GetHandleId(GetExpiredTimer()))
    call DestroyTimer(GetExpiredTimer())
endfunction

function TimedText takes string text, real duration returns nothing
    local texttag textTag = CreateTextTag()
    local timer textTimer = CreateTimer()
    call TimerStart(textTimer, duration, false, function TimedText_Timer)

    //  TextTag Actions

    call SaveTextTagHandle(udg_TextTagTable, GetHandleId(textTimer), 0, textTag)

    set textTag = null
    set textTimer = null
endfunction

Add the actions for the texttag yourself.
 
Level 2
Joined
Oct 3, 2009
Messages
20
i guess u want me finding out how to do that on my own to learn stuff

even if that is not the case, thanks for answering! :3


edit::
Well, if u dont mind posting it, ill appreciate it.



edit²::

awesome, thanks!
 
Level 11
Joined
Apr 29, 2007
Messages
826
1) I think they do... and I was right: type texttag extends handle. Anything that extends handle (and I think agent too) leaks if not destroyed.

NO. TextTags do NOT leak(they're not even real handles), however they have a limit of 100 texttags. So if you don't destroy them, you're going to hit the limit somewhen.
And every other thing except groups and locations do negligible leaks. Units and effects do also leak. Effects can be destroyed, but they still leave some restover leak.
 
Level 12
Joined
Jul 27, 2008
Messages
1,181
handle is a pseudo-pointer, which means that the variable is not the texttag itself, it points to it. So if you don't destroy it leaks.

And every handle leaks once, so leaking a group = leaking a unit, doodad, texttag, effect, or anything.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Undestroyed texttags leak, texttags have a dedicated internal memory allocation. You can have 100 active texttags at a time so leaking 1 would mean that you would have 99 left if one leaked. This is still considered a leak, even though its not using the public stack for agent type handles.

2: Triggers need to have an initializer function, InitTrig_<triggerName>, so if you name the trigger "Test Trigger" you'll have to write an initializer function:
JASS:
function InitTrig_Test_Trigger takes nothing returns nothing
endfunction
*Test Trigger must be written in jass as Test_Trigger, just replace the spaces with underscore.
*Also remember that Initializer functions must not have parameters and must not return any value.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
So? It's still a handle. It'll ocupy those 4 bytes if not destroyed, so it's a leak. The issue with the 100 is a side effect, propably happens with units and everything too.

But waaayyyy bigger limit.

Yes, because texttags use a dedicated stack, and agent type handles use a public stack for identification\instantiation.
 
Level 2
Joined
Oct 3, 2009
Messages
20
A Question regarding to Reapers solution came up.

I cannot load the values out iof the hash table, and i cant figure out why :/



edit:: i had to create a hashtable and set the global variable to the last created hastable first. wtf.
 
Last edited:
Status
Not open for further replies.
Top