summaryrefslogtreecommitdiff
path: root/src/landscape.h
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-02-06 13:14:40 +0000
committeralberth <alberth@openttd.org>2010-02-06 13:14:40 +0000
commit21589daea9d55878d029b641374caff10561fff3 (patch)
treec2a224b0c02116ad990b8256b84a001f3c6ca068 /src/landscape.h
parentdb6e077c8af7ffa2e224628811ff1e1af23cd049 (diff)
downloadopenttd-21589daea9d55878d029b641374caff10561fff3.tar.xz
(svn r19040) -Codechange: Introduce inverse function of RemapCoords.
Diffstat (limited to 'src/landscape.h')
-rw-r--r--src/landscape.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/landscape.h b/src/landscape.h
index d439f9171..d505d6834 100644
--- a/src/landscape.h
+++ b/src/landscape.h
@@ -70,6 +70,20 @@ static inline Point RemapCoords2(int x, int y)
return RemapCoords(x, y, GetSlopeZ(x, y));
}
+/**
+ * Map 2D viewport or smallmap coordinate to 3D world or tile coordinate.
+ * Function assumes <tt>z == 0</tt>. For other values of \p z, add \p z to \a y before the call.
+ * @param x X coordinate of the 2D coordinate.
+ * @param y Y coordinate of the 2D coordinate.
+ * @return X and Y components of equivalent world or tile coordinate.
+ * @note Inverse of #RemapCoords function. Smaller values may get rounded.
+ */
+static inline Point InverseRemapCoords(int x, int y)
+{
+ Point pt = {(y * 2 - x) >> 2, (y * 2 + x) >> 2};
+ return pt;
+}
+
uint ApplyFoundationToSlope(Foundation f, Slope *s);
void DrawFoundation(TileInfo *ti, Foundation f);
bool HasFoundationNW(TileIndex tile, Slope slope_here, uint z_here);