diff options
author | tron <tron@openttd.org> | 2006-01-30 17:18:45 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-01-30 17:18:45 +0000 |
commit | 5e1e90260016fc5ad7a62a824922f9766158bbf8 (patch) | |
tree | a71bfa3b7016eec2f35802faea7d5bb51c9b0130 | |
parent | c8dd64bdbc162753f55b06ad395c84d15bff6998 (diff) | |
download | openttd-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
-rw-r--r-- | clear_cmd.c | 4 | ||||
-rw-r--r-- | landscape.c | 2 | ||||
-rw-r--r-- | rail_cmd.c | 6 | ||||
-rw-r--r-- | road_cmd.c | 4 | ||||
-rw-r--r-- | tunnelbridge_cmd.c | 2 | ||||
-rw-r--r-- | water_cmd.c | 2 |
6 files changed, 10 insertions, 10 deletions
diff --git a/clear_cmd.c b/clear_cmd.c index 0f7e36577..52dd174f7 100644 --- a/clear_cmd.c +++ b/clear_cmd.c @@ -233,7 +233,7 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2) tile = TileVirtXY(x, y); /* Make an extra check for map-bounds cause we add tiles to the originating tile */ - if (tile + TileDiffXY(1, 1) > MapSize()) return CMD_ERROR; + if (tile + TileDiffXY(1, 1) >= MapSize()) return CMD_ERROR; if (p1 & 1) { if (!TerraformTileHeight(&ts, tile + TileDiffXY(1, 0), @@ -332,7 +332,7 @@ int32 CmdLevelLand(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) TileIndex tile; int32 ret, cost, money; - if (p1 > MapSize()) return CMD_ERROR; + if (p1 >= MapSize()) return CMD_ERROR; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); diff --git a/landscape.c b/landscape.c index d213fc913..839b5dbd4 100644 --- a/landscape.c +++ b/landscape.c @@ -307,7 +307,7 @@ int32 CmdClearArea(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) int x,y; bool success = false; - if (p1 > MapSize()) return CMD_ERROR; + if (p1 >= MapSize()) return CMD_ERROR; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); 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; diff --git a/road_cmd.c b/road_cmd.c index a2f6c730d..5de592401 100644 --- a/road_cmd.c +++ b/road_cmd.c @@ -518,7 +518,7 @@ int32 CmdBuildLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); - if (p1 > MapSize()) return CMD_ERROR; + if (p1 >= MapSize()) return CMD_ERROR; start_tile = p1; end_tile = TileVirtXY(x, y); @@ -573,7 +573,7 @@ int32 CmdRemoveLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); - if (p1 > MapSize()) return CMD_ERROR; + if (p1 >= MapSize()) return CMD_ERROR; start_tile = p1; end_tile = TileVirtXY(x, y); diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c index 02829af96..fe6dae18d 100644 --- a/tunnelbridge_cmd.c +++ b/tunnelbridge_cmd.c @@ -209,7 +209,7 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2) bridge_type = GB(p2, 0, 8); railtype = GB(p2, 8, 8); - if (p1 > MapSize()) return CMD_ERROR; + if (p1 >= MapSize()) return CMD_ERROR; // type of bridge if (HASBIT(railtype, 7)) { // bit 15 of original p2 param diff --git a/water_cmd.c b/water_cmd.c index dee9b2fe8..7c95061cd 100644 --- a/water_cmd.c +++ b/water_cmd.c @@ -215,7 +215,7 @@ int32 CmdBuildCanal(int x, int y, uint32 flags, uint32 p1, uint32 p2) int size_x, size_y; int sx, sy; - if (p1 > MapSize()) return CMD_ERROR; + if (p1 >= MapSize()) return CMD_ERROR; sx = TileX(p1); sy = TileY(p1); |