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

You can change this now in User CP.
Reaction score
58
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.
  • Varine Varine:
    I have a bunch of community service I have to do, and I have a feeling there will be a lot of snow shoveling involved now
  • The Helper The Helper:
    don't know why people choose to live in that kind of weather :)
  • Varine Varine:
    Well
  • Varine Varine:
    My job is here
  • Varine Varine:
    I was born here man I didn't choose shit
  • Varine Varine:
    And also, I keep moving away and it doesn't get any better. I moved to San Antonio and shit froze there AND we had blackouts
  • tom_mai78101 tom_mai78101:
    I'm back, suffering from severe jet lag.
  • The Helper The Helper:
    Cold is following your ass around Varine - I just dont think I could handle a snowy winter.
  • The Helper The Helper:
    Welcome Back Tom!
  • The Helper The Helper:
    I hear that taking a Melatonin around your normal bedtime can really fix jet lag
  • tom_mai78101 tom_mai78101:
    Yeah, I also heard about that as well. I think I'm good. I'm just lucky it's the weekend so I have some time to readjust.
    +1
  • Varine Varine:
    It was a fucking blizzard today, shoveling was an effort in futility.
  • Varine Varine:
    Melatonin gives me nightmares
  • Varine Varine:
    They had me shoveling out the parking lot for the jail. Fucking pointless, they need a blow.
  • Varine Varine:
    Well they gave me a snow blower but it was too wet to do much with with other than compact everything. Oh well, the cop cars can get into there now when they arrest people I guess
    +1
  • The Helper The Helper:
    I shit you not we are Number one on Google for Banana Bread Recipe
  • jonas jonas:
    xD
    +1
  • The Helper The Helper:
    Need Web Design Contractor that knows Word Press, Woocommerce and Elementor to help with the company that sponsors this site
  • The Helper The Helper:
  • The Helper The Helper:
    I am going to be AFK most of this weekend has I have a friend coming into town for his company christmas party and I am going to be busy with that this weekend.
    +1
  • The Helper The Helper:
    541 Active Users and this number has been pretty steady give or take some. The bots are hammering us.
  • The Helper The Helper:
    I have been posting a bunch of recipes and Google is loving them. I mean OK my shit is good but how does google know LOL!

    The Helper Discord

    Members online

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top