Mercurial > hg > openttd
changeset 2934:137d6aa34f0e draft
(svn r3490) -Fix: A bunch (10) of off-by-one errors when checking if a TileIndex points to a tile on the map
author | tron <tron@openttd.org> |
---|---|
date | Mon, 30 Jan 2006 17:18:45 +0000 |
parents | 52de2ad82de2 |
children | b70e245e872f |
files | clear_cmd.c landscape.c rail_cmd.c road_cmd.c tunnelbridge_cmd.c water_cmd.c |
diffstat | 6 files changed, 10 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/clear_cmd.c +++ b/clear_cmd.c @@ -233,7 +233,7 @@ 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 @@ TileIndex tile; int32 ret, cost, money; - if (p1 > MapSize()) return CMD_ERROR; + if (p1 >= MapSize()) return CMD_ERROR; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
--- a/landscape.c +++ b/landscape.c @@ -307,7 +307,7 @@ int x,y; bool success = false; - if (p1 > MapSize()) return CMD_ERROR; + if (p1 >= MapSize()) return CMD_ERROR; SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
--- a/rail_cmd.c +++ b/rail_cmd.c @@ -566,7 +566,7 @@ 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 @@ 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 @@ 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;
--- a/road_cmd.c +++ b/road_cmd.c @@ -518,7 +518,7 @@ 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 @@ 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);