Changeset - r2934:94158a76ebcf
[Not reviewed]
master
0 6 0
tron - 19 years ago 2006-01-30 17:18:45
tron@openttd.org
(svn r3490) -Fix: A bunch (10) of off-by-one errors when checking if a TileIndex points to a tile on the map
6 files changed with 10 insertions and 10 deletions:
0 comments (0 inline, 0 general)
clear_cmd.c
Show inline comments
 
@@ -233,7 +233,7 @@ int32 CmdTerraformLand(int x, int y, uin
 
	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, uint3
 
	TileIndex tile;
 
	int32 ret, cost, money;
 

	
 
	if (p1 > MapSize()) return CMD_ERROR;
 
	if (p1 >= MapSize()) return CMD_ERROR;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 

	
landscape.c
Show inline comments
 
@@ -307,7 +307,7 @@ int32 CmdClearArea(int ex, int ey, uint3
 
	int x,y;
 
	bool success = false;
 

	
 
	if (p1 > MapSize()) return CMD_ERROR;
 
	if (p1 >= MapSize()) return CMD_ERROR;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 

	
rail_cmd.c
Show inline comments
 
@@ -566,7 +566,7 @@ static int32 CmdRailTrackHelper(int x, i
 
	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,
 
	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, uin
 
	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;
road_cmd.c
Show inline comments
 
@@ -518,7 +518,7 @@ int32 CmdBuildLongRoad(int x, int y, uin
 

	
 
	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, ui
 

	
 
	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);
tunnelbridge_cmd.c
Show inline comments
 
@@ -209,7 +209,7 @@ int32 CmdBuildBridge(int x, int y, uint3
 
	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
water_cmd.c
Show inline comments
 
@@ -215,7 +215,7 @@ int32 CmdBuildCanal(int x, int y, uint32
 
	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);
0 comments (0 inline, 0 general)