Bazaar developer reference

plotDistance(int, int, int, int)

Defined in
CvGameCoreUtils.h, line 131
Not a hook point
written in a header

Code

127//// Returns the distance between plots according to the pattern above...128//129//// not anymore - We are using hexes now!130//131inline int plotDistance(int iX1, int iY1, int iX2, int iY2)132{133	int iDX;134	int iWrappedDX = dxWrap(iX2 - iX1);135	int iWrappedDY = dyWrap(iY2 - iY1);136	int iDY = abs(iWrappedDY);137138	// convert to hex-space coordinates - the coordinate system axes are E and NE (not orthogonal)139	int iHX1 = xToHexspaceX(iX1, iY1);140	int iHX2 = xToHexspaceX(iX1 + iWrappedDX, iY1 + iWrappedDY);141142	iDX = abs(dxWrap(iHX2 - iHX1));143144	if((iHX2 - iHX1 >= 0) == (iWrappedDY >= 0))  // the signs match145	{146		return iDX + iDY;147	}148	else149	{150		return (std::max(iDX, iDY));151	}152}

Calls

Called by

173 functions in 34 files