Changeset - r7482:9fc80ebce275
[Not reviewed]
master
0 1 0
belugas - 17 years ago 2007-08-27 23:50:56
belugas@openttd.org
(svn r10993) -Codechange: A few less magical numbers (skidd13)
1 file changed with 6 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/town_cmd.cpp
Show inline comments
 
@@ -669,13 +669,13 @@ static bool IsRoadAllowedHere(TileIndex 
 
	for (;;) {
 
		/* Check if there already is a road at this point? */
 
		if (GetAnyRoadTrackBits(tile, ROADTYPE_ROAD) == 0) {
 
			/* No, try to build one in the direction.
 
			 * if that fails clear the land, and if that fails exit.
 
			 * This is to make sure that we can build a road here later. */
 
			if (CmdFailed(DoCommand(tile, (dir & 1 ? ROAD_X : ROAD_Y), 0, DC_AUTO, CMD_BUILD_ROAD)) &&
 
			if (CmdFailed(DoCommand(tile, (dir & ROAD_NW ? ROAD_X : ROAD_Y), 0, DC_AUTO, CMD_BUILD_ROAD)) &&
 
					CmdFailed(DoCommand(tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR)))
 
				return false;
 
		}
 

	
 
		slope = GetTileSlope(tile, NULL);
 
		if (slope == SLOPE_FLAT) {
 
@@ -692,13 +692,13 @@ no_slope:
 
							NeighborIsRoadTile(tile, dir, RB_TILE_DIST2));
 
			}
 
		}
 

	
 
		/* If the tile is not a slope in the right direction, then
 
		 * maybe terraform some. */
 
		k = (dir & 1) ? SLOPE_NE : SLOPE_NW;
 
		k = (dir & ROAD_NW) ? SLOPE_NE : SLOPE_NW;
 
		if (k != slope && ComplementSlope(k) != slope) {
 
			uint32 r = Random();
 

	
 
			if (CHANCE16I(1, 8, r) && !_generating_world) {
 
				CommandCost res;
 

	
 
@@ -936,13 +936,13 @@ static void GrowTownInTile(TileIndex* ti
 
					}
 

	
 
					/* That means that the road is only allowed if there is a house
 
					 *  at any side of the new road. */
 
				}
 

	
 
				rcmd = (RoadBits)((1 << a) + (1 << b));
 
				rcmd = (RoadBits)((ROAD_NW << a) + (ROAD_NW << b));
 
				break;
 
		}
 

	
 
	} else if (block < 5 && !HASBIT(mask, block ^ 2)) {
 
		/* Continue building on a partial road.
 
		 * Always OK. */
 
@@ -958,13 +958,13 @@ static void GrowTownInTile(TileIndex* ti
 
			case TL_2X2_GRID:
 
			 	rcmd = GetTownRoadGridElement(t1, tile);
 
				break;
 

	
 
			case TL_BETTER_ROADS:
 
			case TL_ORIGINAL:
 
				rcmd = (RoadBits)(1 << (block ^ 2));
 
				rcmd = (RoadBits)(ROAD_NW << (block ^ 2));
 
				break;
 
		}
 
	} else {
 
		int i;
 
		bool allow_house = false;
 
		TileIndex tmptile2;
 
@@ -1037,13 +1037,13 @@ static void GrowTownInTile(TileIndex* ti
 
				}
 
			}
 
			return;
 
		}
 

	
 
		_grow_town_result = 0;
 
		rcmd = (RoadBits)(1 << i);
 
		rcmd = (RoadBits)(ROAD_NW << i);
 
	}
 

	
 
	/* Return if a water tile */
 
	if (IsClearWaterTile(tile)) return;
 

	
 
	/* Determine direction of slope,
 
@@ -1135,13 +1135,13 @@ static int GrowTownAtRoad(Town *t, TileI
 
		/* Try to grow the town from this point */
 
		GrowTownInTile(&tile, mask, block, t);
 

	
 
		/* Exclude the source position from the bitmask
 
		 * and return if no more road blocks available */
 
		ClrBitT(mask, (block ^ 2));
 
		if (mask == 0)
 
		if (mask == ROAD_NONE)
 
			return _grow_town_result;
 

	
 
		/* Select a random bit from the blockmask, walk a step
 
		 * and continue the search from there. */
 
		do block = Random() & 3; while (!HASBIT(mask, block));
 
		tile += ToTileIndexDiff(_roadblock_tileadd[block]);
0 comments (0 inline, 0 general)