Avoid Memories leak

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

initialD
Some Honorary Title
Posts: 1713
Joined: June 8th, 2007, 5:08 am
Title: Angry Bird

Avoid Memories leak

Post by initialD »

I have tried making this -tele command a few times but I failed. I think I missed something on my script. Could anyone just show me how to make a -tele (set patrol to teleport) command in JASS, please?
Last edited by initialD on January 24th, 2008, 4:57 am, edited 2 times in total.
User avatar
Xantan
Honorary wc3edit.net Traitor
Posts: 2507
Joined: February 1st, 2007, 4:11 pm
Location: NEVADA

Re: set patrol to teleport.

Post by Xantan »

event: unit issues an order

condition: order equal to patrol

action: move unit instantly to target point of issued order
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: set patrol to teleport.

Post by Aero »

That leaks a location Xantan... X.X
User avatar
Xantan
Honorary wc3edit.net Traitor
Posts: 2507
Joined: February 1st, 2007, 4:11 pm
Location: NEVADA

Re: set patrol to teleport.

Post by Xantan »

it still gives correct functions and if anyone really cares, they can fix it...

lol
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: set patrol to teleport.

Post by Aero »

I know..but seeing GUI leaks in the JASS section makes my cringe.
User avatar
Xantan
Honorary wc3edit.net Traitor
Posts: 2507
Joined: February 1st, 2007, 4:11 pm
Location: NEVADA

Re: set patrol to teleport.

Post by Xantan »

I'm sorry you feel that way, feel free to tell us how to fix it, asap!

otherwise we got a crisis on our hands.
initialD
Some Honorary Title
Posts: 1713
Joined: June 8th, 2007, 5:08 am
Title: Angry Bird

Re: set patrol to teleport.

Post by initialD »

Thanks xantan. I made it.
About the leaks.I have no idea what it is. Could Aero explain a bit?
Here is the function I made, if that does matter.

Code: Select all

function Tp takes nothing returns nothing
local unit u=GetTriggerUnit()
local location k=GetOrderPointLoc()
if GetIssuedOrderId()==851990then
call SetUnitPosition(u,GetLocationX(k),GetLocationY(k))
endif
set u=null
set k=null
endfunction
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: set patrol to teleport.

Post by Aero »

That still leaks a location and can be done cleaner.

Attach a condition to your trigger first of all.

Code: Select all

function SomeCond takes nothing returns boolean
return GetIssuedOrderId()==851990
endfunction
And actions should look like this:

Code: Select all

function Tp takes nothing returns nothing
local unit u=GetTriggerUnit()
local location l=GetOrderPointLoc()
call SetUnitX(u,GetLocationX(l))
call SetUnitY(u,GetLocationY(l))
call RemoveLocation(l)
set u=null
set l=null
endfunction
SetUnitX / SetUnitY is faster than SetUnitPosition as SetUnitPosition checks pathing, map bounds ect.
SetUnitX/Y completely ignores pathing, map bounds and other limitations.

It's imperative you have "RemoveLocation(l)" to clean that location from memory. Otherwise, this floating location doesn't get removed and leeches RAM.
initialD
Some Honorary Title
Posts: 1713
Joined: June 8th, 2007, 5:08 am
Title: Angry Bird

Re: set patrol to teleport.

Post by initialD »

Thanks Aero. Moderator please don't delete this thread first. I will need some time to learn all that JASS. :) thanks.
User avatar
Bartimaeus
Tyrannical Drama Queen
Posts: 4442
Joined: November 19th, 2007, 5:05 am
Been thanked: 2 times

Re: set patrol to teleport.

Post by Bartimaeus »

initiald wrote:Thanks Aero. Moderator please don't delete this thread first. I will need some time to learn all that JASS. :) thanks.
If you or someone can learn from this topic, it's not going to be deleted. (and you can learn something from this topic, so...)