HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Why am I should use point x, y than location

05-12-2008, 10:41 AM#1
Dark_Runner
Why am I should use point x, y than location
05-12-2008, 10:47 AM#2
Alexander244
  • Most natives take real values as their arguments, and return reals.
  • Locations have the extra overhead of needing to be created and destroyed.
  • When using real x/y values instead of locations you don't have the extra overhead of GetX/Y and MoveLocation; this leads to both easier to read and more efficient code.

There are times when locations are needed; such as getting terrain height etc. So it's not "don't use locations", but rather only use them where they are appropriate.
05-12-2008, 11:07 AM#3
abriko
It's different ! :p
Location is x AND y. You can't apply mathematic and dynamic transformation with the location or that is always proportional.
05-12-2008, 11:39 AM#4
Tide-Arc Ephemera
Locations are easier to let leak. Coords don't leak at all.

Also, things which require locations often interrupt unit orders, making them a bit odd when making unit abilities.
05-12-2008, 11:49 AM#5
zen87
locations are objects, they eats ram memory by leaking
x and y are reals, they don't leaks
05-12-2008, 01:02 PM#6
ADOLF
so... use location when:
you need to find coordinates where was cast spell (GetSpellTargetLoc()) or you need Z coordinate of terrain
Collapse JASS:
globals
 location l_temp=Location(0., 0.)
endglobals
//...
 call MoveLocation(l_temp, x, y)
 set z=GetLocationZ(l_temp)

in the rest it is faster and more convenient than coordinate
05-13-2008, 02:14 PM#7
Dark_Runner
Hmm
05-13-2008, 03:02 PM#8
Rising_Dusk
I only use locations under the case where I need a Z-coordinate, since that's impossible with just X/Y. Otherwise, I avoid locations like the plague; senseless handle declarations are silly.
05-13-2008, 08:31 PM#9
Themerion
Using X/Y is a little bit (a very tiny bit) faster than using Locations.

Also, Locations create small (very small) memory leaks if they are not removed with:

call RemoveLocation(myLocationVariable)

If you are going to post something at wc3campaigns (a system, a spell, etc), then you should probably use the X/Y.
Otherwise, it doesn't really matter much.