Ardenian
A
Ardenian
Can I somehow avoid having to different functions that differ only in one line here ?
I have a function GridCenter that takes an integer ( let it be 1) and returns a location. However, I want the X and Y location be seperatly be call-able, so I could call them to receive the real and not the location, if needed.
But, besides these lines:
the two functions are completely the same. Do you have any suggestion how I could cut away some code ?
Requirements:
JASS:
function GridCenterX takes integer i returns real
local integer i2 = R2I((udg_SUG_GridLength[i]*udg_SUG_GridBreadth[i])*0.5 +0.5)
local location p
local real x
set p = LoadLocationHandle( udg_SUG_Hashtable, i, i2)
set x = GetLocationX( p)
call RemoveLocation( p)
set p = null
return x
endfunction
function GridCenterY takes integer i returns real
local integer i2 = R2I((udg_SUG_GridLength[i]*udg_SUG_GridBreadth[i])*0.5 +0.5)
local location p
local real y
set p = LoadLocationHandle( udg_SUG_Hashtable, i, i2)
set y = GetLocationY( p)
call RemoveLocation( p)
set p = null
return y
endfunction
function GridCenter takes integer i returns location
return Location( GridCenterX(i), GridCenterY(i))
endfunction
I have a function GridCenter that takes an integer ( let it be 1) and returns a location. However, I want the X and Y location be seperatly be call-able, so I could call them to receive the real and not the location, if needed.
But, besides these lines:
JASS:
set x = GetLocationX( p)
//and
set y = GetLocationY( p)
Requirements:
- GridCenter has to take an integer and return a location
- The coordinates of the location returned by GridCenter should be able to be called in another way, so you can call them as reals.
JASS:
local real x = GridCenterX(1)