Avoid Memories leak
Moderator: Cheaters
-
- Senior Member
- Posts: 101
- Joined: June 1st, 2007, 9:05 pm
Re: set patrol to teleport.
Ahem... Aero, why aren't you using GetOrderPointX/Y instead of locations? o.O
-
- Forum Staff
- Posts: 829
- Joined: January 28th, 2007, 8:10 pm
- Title: JASS Programmer
- Location: Canada
Re: set patrol to teleport.
I got it mixed up with GetSpellTargetLoc() (As there is no GetSpellTargetX/Y)
That aside, it was to show initiald how to deal with locations.
That aside, it was to show initiald how to deal with locations.
-
- Some Honorary Title
- Posts: 1713
- Joined: June 8th, 2007, 5:08 am
- Title: Angry Bird
Re: Advoid Memories leak
Thanks Aero. Here are two more function. I will aprreciate it if you could just tell me if they are leaking or not.
If those two function leaks, how to solve it? Thanks
about the fucntion TP, so if I use getorderpointx/y, it will not leak, right?
lastly, if it possible to make -armor XX and -damage XX commmands (to set hero's dmg and armor) with only pure JASS? If possible how to do it?
Sorry for bothering. I am a noob though. Is there any website I can learn all the functions for JASS? or should I don't click me a book for learning JASS?
If those two function leaks, how to solve it? Thanks
Spoiler:
Code: Select all
function Tp takes nothing returns nothing
local unit u=GetTriggerUnit()
local location l=GetOrderPointLoc()
call SetUnitX(u,GetOrderPointX(l))
call SetUnitY(u,GetOrderPointY(l))
set u=null
set l=null
endfunction
lastly, if it possible to make -armor XX and -damage XX commmands (to set hero's dmg and armor) with only pure JASS? If possible how to do it?
Sorry for bothering. I am a noob though. Is there any website I can learn all the functions for JASS? or should I don't click me a book for learning JASS?
-
- Forum Staff
- Posts: 926
- Joined: June 3rd, 2007, 8:03 pm
Re: Advoid Memories leak
Well in my cheatpack their are two commands called deca and inca, I think, that do this though you wont actually see the attack go up or anything it just adds dmg to your atks and makes enemys do less dmg. As for learning jass best advise is experimenting, though also theirs something like a guide in the map pack in my sig.
-
- Forum Staff
- Posts: 829
- Joined: January 28th, 2007, 8:10 pm
- Title: JASS Programmer
- Location: Canada
Re: Advoid Memories leak
Code: Select all
function ControlOff takes nothing returns nothing
local integer playerId = S2I(SubString(GetEventPlayerChatString(),5,7))
if (playerId < 1) or (playerId > 12) then
return
endif
if Player(playerId-1)==GetLocalPlayer() then
call EnableUserControl(false)
endif
endfunction
------------If only 1 player at a time will have control disabled, use this instead---------------
function ControlOff takes nothing returns nothing
local integer playerId = S2I(SubString(GetEventPlayerChatString(),5,7))
if (playerId < 1) or (playerId > 12) then
return
endif
call EnableUserControl(GetLocalPlayer()!=Player(playerId-1))
endfunction
--------------------------------------------------------------------------------------------------
function ModSP takes nothing returns nothing
local unit whichUnit = GetEnumUnit()
local integer howManySkillPoints = S2I(SubString(GetEventPlayerChatString(),3,10))
call UnitModifySkillPoints(whichUnit,howManySkillPoints-GetHeroSkillPoints(whichUnit))
set u=null
endfunction
function Tp takes nothing returns nothing
local unit u=GetTriggerUnit()
call SetUnitX(u,GetOrderPointX())
call SetUnitY(u,GetOrderPointY())
set u=null
endfunction
1 = Player(0) Red
2 = Player(1) Blue
...
12 = Player(11) Brown
It's better to keep it this way so if the user uses '-1' or something similar as input, it won't crash, and in case the user inputs non-numeric strings (Which S2I returns as 0... Player(0) = red)
-------------------------------------------------------
The only leaks were...
GetForceOfPlayer(Player(-1+(udg_integerfai)))
Code: Select all
function GetForceOfPlayer takes player whichPlayer returns force
local force f = CreateForce()
call ForceAddPlayer(f, whichPlayer)
return f
endfunction
and this leaks...
local location l=GetOrderPointLoc()
because there is no "RemoveLocation(l)" call in the code block.
-
- Some Honorary Title
- Posts: 1713
- Joined: June 8th, 2007, 5:08 am
- Title: Angry Bird
Re: Advoid Memories leak
thanks aero and weirdone.
Why syntax checker say " cannot convert player to boolean" What I did wrong?
Aero, could explain a bit why is this better then the previous code? For learning purpose. Thanks
Code: Select all
call EnableUserControl(whichPlayer)
Code: Select all
function ModSP takes nothing returns nothing
local unit whichUnit = GetEnumUnit()
local integer howManySkillPoints = S2I(SubString(GetEventPlayerChatString(),3,10))
call UnitModifySkillPoints(whichUnit,howManySkillPoints-GetHeroSkillPoints(whichUnit))
set u=null
endfunction
-
- Forum Drunk
- Posts: 2918
- Joined: January 17th, 2007, 4:22 pm
- Has thanked: 1 time
- Been thanked: 1 time
Re: Advoid Memories leak
maybe EnableUserControl takes boolean?initiald wrote:thanks aero and weirdone.
Why syntax checker say " cannot convert player to boolean" What I did wrong?Code: Select all
call EnableUserControl(whichPlayer)
Don't pm me with Warcraft questions, this is a forum so just make a post!
In the world of thinking we are all immigrants. -Robert Nozick
-
- Forum Staff
- Posts: 829
- Joined: January 28th, 2007, 8:10 pm
- Title: JASS Programmer
- Location: Canada
Re: Advoid Memories leak
call EnableUserControl(whichPlayer)initiald wrote:thanks aero and weirdone.
Why syntax checker say " cannot convert player to boolean" What I did wrong?Code: Select all
call EnableUserControl(whichPlayer)
Aero, could explain a bit why is this better then the previous code? For learning purpose. ThanksCode: Select all
function ModSP takes nothing returns nothing local unit whichUnit = GetEnumUnit() local integer howManySkillPoints = S2I(SubString(GetEventPlayerChatString(),3,10)) call UnitModifySkillPoints(whichUnit,howManySkillPoints-GetHeroSkillPoints(whichUnit)) set u=null endfunction
That was just a typo. I originally had call EnableUserControl(GetLocalPlayer()!=Player(playerId-1)) and from the copy pasting it got screwed up.
Anyways, I optimized that piece of code a bit and fixed the syntax error.
As for "function ModSP". You used a BJ function ...
Code: Select all
function ModifyHeroSkillPoints takes unit whichHero, integer modifyMethod, integer value returns boolean
if (modifyMethod == bj_MODIFYMETHOD_ADD) then
return UnitModifySkillPoints(whichHero, value)
elseif (modifyMethod == bj_MODIFYMETHOD_SUB) then
return UnitModifySkillPoints(whichHero, -value)
elseif (modifyMethod == bj_MODIFYMETHOD_SET) then
return UnitModifySkillPoints(whichHero, value - GetHeroSkillPoints(whichHero))
else
// Unrecognized modification method - ignore the request and return failure.
return false
endif
endfunction
Also, I could of simply subbed in "S2I(SubStringBJ(GetEventPlayerChatString(),4,20))" for "howManySkillPoints" but I chose to put it in a variable first. The reason? Well, the code executes equally fast and it has better readability.
-
- Some Honorary Title
- Posts: 1713
- Joined: June 8th, 2007, 5:08 am
- Title: Angry Bird
Re: Avoid Memories leak
Thanks Aero for all the helps.
You are awesome.
If you have time would you please take a look at this cheat comand? I guess there are memory leaks somewhere here and there, just not sure of it, becasue it obviously make some stupid 56k PC laggy. lol Would it make less laggy if I remove those Globals and put them as locals?
And...... If there any possible to make it shorter and cleaner? This command (similar to -hear in JJ's CP, or -echo in Xantan's CP or "Hear enemy chat" in Cheat Menu) seems like taking a lot of spaces.....haha
Take your time.

If you have time would you please take a look at this cheat comand? I guess there are memory leaks somewhere here and there, just not sure of it, becasue it obviously make some stupid 56k PC laggy. lol Would it make less laggy if I remove those Globals and put them as locals?
And...... If there any possible to make it shorter and cleaner? This command (similar to -hear in JJ's CP, or -echo in Xantan's CP or "Hear enemy chat" in Cheat Menu) seems like taking a lot of spaces.....haha
Take your time.
Spoiler:
-
- Forum Staff
- Posts: 829
- Joined: January 28th, 2007, 8:10 pm
- Title: JASS Programmer
- Location: Canada
Re: Avoid Memories leak
That is extremely leaky.
It doesn't leak handles but strings are where it leaks.
When you display text to a player, it sucks up a little bit of memory permanently.
If that same string is re-displayed, no additional memory is sucked up.
If it's a different string, it sucks up even more memory.
Text on leaderboards leak (and maybe) multiboards seem to leak the same way (Titles only I think from what I tested).
The above is just a guess but the string leaks are for real.
The code could also be optimized a lot (I would do it but don't have any of my wc tools with me as I'm on vacation).
Now, when I get back, I'll show you an awesome texttag system with trackable I have in mind.
It doesn't leak handles but strings are where it leaks.
When you display text to a player, it sucks up a little bit of memory permanently.
If that same string is re-displayed, no additional memory is sucked up.
If it's a different string, it sucks up even more memory.
Text on leaderboards leak (and maybe) multiboards seem to leak the same way (Titles only I think from what I tested).
The above is just a guess but the string leaks are for real.
The code could also be optimized a lot (I would do it but don't have any of my wc tools with me as I'm on vacation).
Now, when I get back, I'll show you an awesome texttag system with trackable I have in mind.