changeset 19630:57afa40539a9 draft

(svn r24539) -Codechange [FS#5260]: make code simpler by using IsValidTile instead of manually checking the bounds (juanjo)
author yexo <yexo@openttd.org>
date Fri, 21 Sep 2012 20:28:23 +0000
parents f182cbbedc2f
children 0badfcb4cc4d
files src/ship_cmd.cpp
diffstat 1 files changed, 2 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -570,15 +570,12 @@
 				}
 			}
 		} else {
-			DiagDirection diagdir;
 			/* New tile */
-			if (TileX(gp.new_tile) >= MapMaxX() || TileY(gp.new_tile) >= MapMaxY()) {
-				goto reverse_direction;
-			}
+			if (!IsValidTile(gp.new_tile)) goto reverse_direction;
 
 			dir = ShipGetNewDirectionFromTiles(gp.new_tile, gp.old_tile);
 			assert(dir == DIR_NE || dir == DIR_SE || dir == DIR_SW || dir == DIR_NW);
-			diagdir = DirToDiagDir(dir);
+			DiagDirection diagdir = DirToDiagDir(dir);
 			tracks = GetAvailShipTracks(gp.new_tile, diagdir);
 			if (tracks == TRACK_BIT_NONE) goto reverse_direction;