custom texttag, does this leak?

afisakov

You can change this now in User CP.
Reaction score
37
I tried my best to write this efficiently, but wanted to know
1) does it leak somewhere
2) is there a way to make it more efficient

Code:
function cconvert takes real percentage returns integer
local integer result = R2I(percentage * 2.55)
if (result < 0) then
   set result = 0
elseif (result > 255) then
   set result = 255
endif
return result
endfunction

function CreateTextunit_sec_speed takes string s, unit u, real dur,real speed,real zOffset,real size,real red,real green,real blue,real transparency returns texttag
set bj_lastCreatedTextTag=CreateTextTag()
call SetTextTagText(bj_lastCreatedTextTag,s,size*0.0023)
call SetTextTagPos(bj_lastCreatedTextTag,GetUnitX(u),GetUnitY(u),zOffset)
call SetTextTagColor(bj_lastCreatedTextTag,cconvert(red),cconvert(green),cconvert(blue),cconvert(100.0-transparency))
call SetTextTagPermanent(bj_lastCreatedTextTag,false)
call SetTextTagVelocity(bj_lastCreatedTextTag,0,speed/1803.)
call SetTextTagLifespan(bj_lastCreatedTextTag,dur)
call SetTextTagFadepoint(bj_lastCreatedTextTag,dur-.5)
return bj_lastCreatedTextTag
endfunction

function ...
if p!=Player(0) then
   set g=goldmod(g,myha[pi])
   call CreateTextunit_sec_speed("|cffFFFF00+"+I2S(g)+"|r",GetTriggerUnit(),2.5,75,0,10,0,80,80,0)
   if GetLocalPlayer()==p then
   call SetTextTagVisibility(bj_lastCreatedTextTag,true)
   else
   call SetTextTagVisibility(bj_lastCreatedTextTag,false)
   endif
   call SetPlayerState(GetOwningPlayer(myha[pi]),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(GetOwningPlayer(myha[pi]),PLAYER_STATE_RESOURCE_GOLD) + g )
endif
... endfunction
 

MyPad

Member
Reaction score
0
JASS:
function cconvert takes real percentage returns integer
    local integer result = R2I(percentage * 2.55)
    if (result &lt; 0) then
       set result = 0
    elseif (result &gt; 255) then
       set result = 255
    endif
    return result
endfunction

function CreateTextunit_sec_speed takes string s, unit u, real dur,real speed,real zOffset,real size,real red,real green,real blue,real transparency returns texttag
    set bj_lastCreatedTextTag=CreateTextTag()
    call SetTextTagText(bj_lastCreatedTextTag,s,size*0.0023)
    call SetTextTagPos(bj_lastCreatedTextTag,GetUnitX(u),GetUnitY(u),zOffset)
    call SetTextTagColor(bj_lastCreatedTextTag,cconvert(red),cconvert(green),cconvert(blue),cconvert(100.0-transparency))
    call SetTextTagPermanent(bj_lastCreatedTextTag,false)
    call SetTextTagVelocity(bj_lastCreatedTextTag,0,speed/1803.)
    call SetTextTagLifespan(bj_lastCreatedTextTag,dur)
    call SetTextTagFadepoint(bj_lastCreatedTextTag,dur-.5)
    return bj_lastCreatedTextTag
endfunction

function ...
   if p!=Player(0) then
       set g=goldmod(g,myha[pi])
       call CreateTextunit_sec_speed(&quot;|cffFFFF00+&quot;+I2S(g)+&quot;|r&quot;,GetTriggerUnit(),2.5,75,0,10,0,80,80,0)
       if GetLocalPlayer()==p then
           call SetTextTagVisibility(bj_lastCreatedTextTag,true)
       else
           call SetTextTagVisibility(bj_lastCreatedTextTag,false)
       endif
       call SetPlayerState(GetOwningPlayer(myha[pi]),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(GetOwningPlayer(myha[pi]),PLAYER_STATE_RESOURCE_GOLD) + g )
endif
... endfunction


This could be made more efficient by creating local text tags instead of global text tags and using the native
 

jonas

Ultra Cool Member
Reaction score
47
It's equally efficient. If your map lags it won't be because of this.

JASS:
function cconvert takes real percentage returns integer
    local integer result = R2I(percentage * 2.55)
    if (result &lt; 0) then
       set result = 0
    elseif (result &gt; 255) then
       set result = 255
    endif
    return result
endfunction

function CreateTextunit_sec_speed takes string s, unit u, real dur,real speed,real zOffset,real size,real red,real green,real blue,real transparency returns texttag
    set bj_lastCreatedTextTag=CreateTextTag()
    call SetTextTagText(bj_lastCreatedTextTag,s,size*0.0023)
    call SetTextTagPos(bj_lastCreatedTextTag,GetUnitX(u),GetUnitY(u),zOffset)
    call SetTextTagColor(bj_lastCreatedTextTag,cconvert(red),cconvert(green),cconvert(blue),cconvert(100.0-transparency))
    call SetTextTagPermanent(bj_lastCreatedTextTag,false)
    call SetTextTagVelocity(bj_lastCreatedTextTag,0,speed/1803.)
    call SetTextTagLifespan(bj_lastCreatedTextTag,dur)
    call SetTextTagFadepoint(bj_lastCreatedTextTag,dur-.5)
    return bj_lastCreatedTextTag
endfunction

function ...
   if p!=Player(0) then
       set g=goldmod(g,myha[pi])
       call CreateTextunit_sec_speed(&quot;|cffFFFF00+&quot;+I2S(g)+&quot;|r&quot;,GetTriggerUnit(),2.5,75,0,10,0,80,80,0)
       if GetLocalPlayer()==p then
           call SetTextTagVisibility(bj_lastCreatedTextTag,true)
       else
           call SetTextTagVisibility(bj_lastCreatedTextTag,false)
       endif
       call SetPlayerState(GetOwningPlayer(myha[pi]),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(GetOwningPlayer(myha[pi]),PLAYER_STATE_RESOURCE_GOLD) + g )
endif
... endfunction




This could be made more efficient by creating local text tags instead of global text tags and using the native
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    Happy Sunday!
    +1
  • The Helper The Helper:
    I will be out of town until Sunday evening
    +1
  • The Helper The Helper:
    I am back! Did you miss me LOL
    +1
  • jonas jonas:
    where did you go?
  • The Helper The Helper:
    Jefferson TX on a Paranormal Investigation of a haunted bed and breakfast - I got some friends that are paranormal investigators and they have an RV and do YouTubes
    +1
  • The Helper The Helper:
    It was a lot of fun. The RV was bad ass
  • jonas jonas:
    That sounds like fun!
    +1
  • The Helper The Helper:
    it was a blast!
  • The Helper The Helper:
    I am going to post the Youtube of the investigation in the forums when it is ready
    +1
  • jonas jonas:
    cool!
  • vypur85 vypur85:
    Sounds cool TH.
  • tom_mai78101 tom_mai78101:
    I was on a Legend of Zelda marathon...
  • tom_mai78101 tom_mai78101:
    Am still doing it now
    +1
  • jonas jonas:
    which one(s) are you playing?
  • jonas jonas:
    I played a little bit of the switch title two weeks ago and found it quite boring
  • The Helper The Helper:
    just got back from San Antonio this weekend had the best Buffalo Chicken Cheesesteak sandwhich in Universal City, TX - place was called Yous Guys freaking awesome! Hope everyone had a fantastic weekend!
    +1
  • The Helper The Helper:
    Happy Tuesday!
  • The Helper The Helper:
    We have been getting crazy numbers reported by the forum of people online the bots are going crazy on us I think it is AI training bots going at it at least that is what it looks like to me.
  • The Helper The Helper:
    Most legit traffic is tracked on multiple Analytics and we have Cloud Flare setup to block a ton of stuff but still there is large amount of bots that seem to escape detection and show up in the user list of the forum. I have been watching this bullshit for a year and still cannot figure it out it is drving me crazy lol.
    +1
  • Ghan Ghan:
    Beep boop
    +1
  • The Helper The Helper:
    hears robot sounds while 250 bots are on the forum lol
  • The Helper The Helper:
    Happy Saturday!
    +1

    The Helper Discord

    Members online

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top