summaryrefslogtreecommitdiff
path: root/rail_cmd.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-01-30 17:18:45 +0000
committertron <tron@openttd.org>2006-01-30 17:18:45 +0000
commit5e1e90260016fc5ad7a62a824922f9766158bbf8 (patch)
treea71bfa3b7016eec2f35802faea7d5bb51c9b0130 /rail_cmd.c
parentc8dd64bdbc162753f55b06ad395c84d15bff6998 (diff)
downloadopenttd-5e1e90260016fc5ad7a62a824922f9766158bbf8.tar.xz
(svn r3490) -Fix: A bunch (10) of off-by-one errors when checking if a TileIndex points to a tile on the map
Diffstat (limited to 'rail_cmd.c')
-rw-r--r--rail_cmd.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/rail_cmd.c b/rail_cmd.c
index bc2ee557e..842ace82d 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -566,7 +566,7 @@ static int32 CmdRailTrackHelper(int x, int y, uint32 flags, uint32 p1, uint32 p2
RailType railtype = (RailType)GB(p2, 0, 4);
if (!ValParamRailtype(railtype) || !ValParamTrackOrientation(track)) return CMD_ERROR;
- if (p1 > MapSize()) return CMD_ERROR;
+ if (p1 >= MapSize()) return CMD_ERROR;
trackdir = TrackToTrackdir(track);
/* unpack end point */
@@ -829,7 +829,7 @@ static int32 CmdSignalTrackHelper(int x, int y, uint32 flags, uint32 p1, uint32
byte semaphores = (HASBIT(p2, 3)) ? 8 : 0;
byte signal_density = (p2 >> 24);
- if (p1 > MapSize()) return CMD_ERROR;
+ if (p1 >= MapSize()) return CMD_ERROR;
if (signal_density == 0 || signal_density > 20) return CMD_ERROR;
if (!IsTileType(tile, MP_RAILWAY)) return CMD_ERROR;
@@ -988,7 +988,7 @@ int32 CmdConvertRail(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
if (!ValParamRailtype(p2)) return CMD_ERROR;
- if (p1 > MapSize()) return CMD_ERROR;
+ if (p1 >= MapSize()) return CMD_ERROR;
// make sure sx,sy are smaller than ex,ey
sx = TileX(p1) * TILE_SIZE;