diff options
author | yexo <yexo@openttd.org> | 2010-08-05 12:03:06 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2010-08-05 12:03:06 +0000 |
commit | 7e4bdbbc9dd9c7a4bb8f6c0af569aafece9d1443 (patch) | |
tree | 586a636c068b978b7ad38a6a2bf2b9f846214906 /src/airport.cpp | |
parent | c421b6fef59027a222340f2647d2f370f165f809 (diff) | |
download | openttd-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.cpp | 36 |
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_, |