• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Vote for the theme of Hive's HD Modeling Contest #7! Click here to vote! - Please only vote if you plan on participating❗️

[JASS] GetZ without Locations

Status
Not open for further replies.
Level 16
Joined
Oct 12, 2008
Messages
1,570
Nope,
GetLocationZ(loc) is the only way i know,,
But maybe there is a way to check for it with some fancy function xD
But those are not known to me,,

But there is a way WITHOUT using a local location,,
JASS:
globals
    location TempLoc = Location(0,0)
endglobals
 
function Func takes nothing returns nothing
    local real x = YourX
    local real y = YourY
    local real z
    call MoveLocation(TempLoc,x,y)
    set z = GetLocationZ(TempLoc)
    .....
endfunction

You do not have to destroy it since you MOVE it, instead of SET it,, ;)
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
How do you know he wants GUI?
If he also is ok with JASS using that global location is easier
And it does not require JNGP, because you can also declare ith "through GUI",, (so it uses the 'udg_' prefix)
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
@ RMX: Uh, no
What if Dreadnought[dA] has another question?
And you are no mod, stop thinking you know better because we are not here to discuss that,,
We are here to help Dreadnought[dA], not your EGO,,

No there is no way, but you CAN avoid using a local location by using a global and using MoveLocation()

@ Reaper2008: Yes, you are right, but using a location is inevitable, but MoveLocation() uses coordinates, which makes it easier for you,,
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Yes Reaper2008, that is right, but using that globals saves you the time of removing the leaks, (location leak AND reference leak),, because you dont need to remove it,,
you dont set it, only move,,
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Ok, let's try,,
Create a location, do something (create a unit or what)
Remove the Location,
use MoveLocation() on the location
and try to create a unit again or so,,

It probably wont work,,

I like to compare the WC3 memory with my room,,
Whenever i do something, a new clothing will be left on the ground,,
When put hte clothing back in my closet it will be cleaned (removed, killed),,
But i can also move it somewhere else (MoveLocation()), then the amount of clothings is still the same,, it is not duplicated or so,,

But lets try the above,, see if it indeed needs to be removed,,
 
Level 8
Joined
Aug 4, 2006
Messages
357
i'd bet my ass MoveLocation does something equivalent to this: (and i have a mighty fine ass)
JASS:
function MoveLocation takes location whichLocation, real newX, real newY returns nothing
    call RemoveLocation ( whichLocation )
    set whichLocation = Location ( newX, newY )
endfunction

so, you're still clearing a location leak whether you use MoveLocation on a global location or using local locations. i think Yixx's global method is better, however, for 3 reasons:
1. you don't have to declare a new variable
2. you don't have to remove a reference leak
3. natives are fast
 

Rmx

Rmx

Level 19
Joined
Aug 27, 2007
Messages
1,164
i'd bet my ass MoveLocation does something equivalent to this: (and i have a mighty fine ass)

function MoveLocation takes location whichLocation, real newX, real newY returns nothing call RemoveLocation ( whichLocation ) set whichLocation = Location ( newX, newY )endfunction

so, you're still clearing a location leak whether you use MoveLocation on a global location or using local locations. i think Yixx's global method is better, however, for 3 reasons:
1. you don't have to declare a new variable
2. you don't have to remove a reference leak
3. natives are fast

100% right, natives are much faster, and this is kinda very easy to use.
 
Level 12
Joined
Feb 23, 2007
Messages
1,030
Thanks guys for the help, I'll test for leaks since Locations leak harder than anything else :D

EDIT: I'm pretty sure MoveLocation doesn't leak. I tested my physics system with 100 units that should leak 5 locations each every 0.02 seconds and I got no reduction in performance over 10 minutes.
 
Level 11
Joined
Apr 6, 2008
Messages
760
JASS:
native MoveLocation takes location whichLocation, real newX, real newY returns nothing

no leakage

As Yixx said do like this (no it wont leak at all, since we move the location. WE DO NOT CREATE A NEW ONE)

JASS:
library GetZ

globals
    private location Loc = Location(0,0) //Here we create the location
endglobals

function GetLocZ takes real x,real y returns real
    call MoveLocation(Loc,x,y) //Here we move it (NO LEAK!)
    return GetLocationZ(Loc)
endfunction

endlibrary

necroposting?
 
Level 8
Joined
Feb 15, 2009
Messages
463
you could also include that custom script (if not using JNGP) in the header and go for it with custom script in GUI or just call it in Jass
JASS:
function GetZ takes real x , real y returns real
    local location loc = Location( x , y )
    local real z = GetLocationZ( loc )
    call RemoveLocation( loc )
    set loc  = null
    return z
endfunction
 
Status
Not open for further replies.
Top