summaryrefslogtreecommitdiff
path: root/src/airport.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2010-08-05 12:03:06 +0000
committeryexo <yexo@openttd.org>2010-08-05 12:03:06 +0000
commit7e4bdbbc9dd9c7a4bb8f6c0af569aafece9d1443 (patch)
tree586a636c068b978b7ad38a6a2bf2b9f846214906 /src/airport.cpp
parentc421b6fef59027a222340f2647d2f370f165f809 (diff)
downloadopenttd-7e4bdbbc9dd9c7a4bb8f6c0af569aafece9d1443.tar.xz
(svn r20368) -Codechange: automatically rotate all nodes for airport movement if the airport is rotated
Diffstat (limited to 'src/airport.cpp')
-rw-r--r--src/airport.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/airport.cpp b/src/airport.cpp
index 24b1bad11..6be9c0039 100644
--- a/src/airport.cpp
+++ b/src/airport.cpp
@@ -151,6 +151,42 @@ static byte AirportTestFTA(uint nofelements, const AirportFTA *layout, const byt
static void AirportPrintOut(uint nofelements, const AirportFTA *layout, bool full_report);
#endif
+/**
+ * Rotate the airport moving data to another rotation.
+ * @param orig Pointer to the moving data to rotate.
+ * @param rotation How to rotate the moving data.
+ * @return The rotated moving data.
+ */
+AirportMovingData RotateAirportMovingData(const AirportMovingData *orig, Direction rotation, uint num_tiles_x, uint num_tiles_y)
+{
+ AirportMovingData amd;
+ amd.flag = orig->flag;
+ amd.direction = ChangeDir(orig->direction, (DirDiff)rotation);
+ switch (rotation) {
+ case DIR_N:
+ amd.x = orig->x;
+ amd.y = orig->y;
+ break;
+
+ case DIR_E:
+ amd.x = orig->y;
+ amd.y = num_tiles_y * TILE_SIZE - orig->x - 1;
+ break;
+
+ case DIR_S:
+ amd.x = num_tiles_x * TILE_SIZE - orig->x - 1;
+ amd.y = num_tiles_y * TILE_SIZE - orig->y - 1;
+ break;
+
+ case DIR_W:
+ amd.x = num_tiles_x * TILE_SIZE - orig->y - 1;
+ amd.y = orig->x;
+ break;
+
+ default: NOT_REACHED();
+ }
+ return amd;
+}
AirportFTAClass::AirportFTAClass(
const AirportMovingData *moving_data_,