Changeset - r12360:c8293eb81374
[Not reviewed]
master
0 3 0
rubidium - 15 years ago 2009-07-12 09:39:30
rubidium@openttd.org
(svn r16795) -Fix [FS#3025]: houses wouldn't get build on the map edge.
3 files changed with 18 insertions and 37 deletions:
0 comments (0 inline, 0 general)
src/road_map.cpp
Show inline comments
 
@@ -34,14 +34,3 @@ RoadBits GetAnyRoadBits(TileIndex tile, 
 
		default: return ROAD_NONE;
 
	}
 
}
 

	
 

	
 
TrackBits GetAnyRoadTrackBits(TileIndex tile, RoadType rt)
 
{
 
	/* Don't allow local authorities to build roads through road depots or road stops. */
 
	if (IsRoadDepotTile(tile) || (IsTileType(tile, MP_STATION) && !IsDriveThroughStopTile(tile)) || !HasTileRoadType(tile, rt)) {
 
		return TRACK_BIT_NONE;
 
	}
 

	
 
	return TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(rt)));
 
}
src/road_map.h
Show inline comments
 
@@ -362,16 +362,6 @@ static inline DiagDirection GetRoadDepot
 
RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt, bool straight_tunnel_bridge_entrance = false);
 

	
 
/**
 
 * Get the accessible track bits for the given tile.
 
 * Special behaviour:
 
 *  - road depots: no track bits
 
 *  - non-drive-through stations: no track bits
 
 * @param tile the tile to get the track bits for
 
 * @return the track bits for the given tile
 
 */
 
TrackBits GetAnyRoadTrackBits(TileIndex tile, RoadType rt);
 

	
 
/**
 
 * Return if the tile is a valid tile for a crossing.
 
 *
 
 * @note function is overloaded
src/town_cmd.cpp
Show inline comments
 
@@ -698,17 +698,9 @@ void OnTick_Town()
 
 */
 
static RoadBits GetTownRoadBits(TileIndex tile)
 
{
 
	TrackBits b = GetAnyRoadTrackBits(tile, ROADTYPE_ROAD);
 
	RoadBits r = ROAD_NONE;
 

	
 
	if (b == TRACK_BIT_NONE) return r;
 
	if (b & TRACK_BIT_X)     r |= ROAD_X;
 
	if (b & TRACK_BIT_Y)     r |= ROAD_Y;
 
	if (b & TRACK_BIT_UPPER) r |= ROAD_NE | ROAD_NW;
 
	if (b & TRACK_BIT_LOWER) r |= ROAD_SE | ROAD_SW;
 
	if (b & TRACK_BIT_LEFT)  r |= ROAD_NW | ROAD_SW;
 
	if (b & TRACK_BIT_RIGHT) r |= ROAD_NE | ROAD_SE;
 
	return r;
 
	if (IsRoadDepotTile(tile) || IsStandardRoadStopTile(tile)) return ROAD_NONE;
 

	
 
	return GetAnyRoadBits(tile, ROADTYPE_ROAD, true);
 
}
 

	
 
/**
 
@@ -757,7 +749,7 @@ static bool IsNeighborRoadTile(TileIndex
 
 */
 
static bool IsRoadAllowedHere(Town *t, TileIndex tile, DiagDirection dir)
 
{
 
	if (TileX(tile) < 2 || TileX(tile) >= MapMaxX() || TileY(tile) < 2 || TileY(tile) >= MapMaxY()) return false;
 
	if (DistanceFromEdge(tile) == 0) return false;
 

	
 
	Slope cur_slope, desired_slope;
 

	
 
@@ -905,14 +897,24 @@ static RoadBits GetTownRoadGridElement(T
 
static bool GrowTownWithExtraHouse(Town *t, TileIndex tile)
 
{
 
	/* We can't look further than that. */
 
	if (TileX(tile) < 2 || TileY(tile) < 2 || MapMaxX() <= TileX(tile) || MapMaxY() <= TileY(tile)) return false;
 
	if (DistanceFromEdge(tile) == 0) return false;
 

	
 
	uint counter = 0; // counts the house neighbor tiles
 

	
 
	/* Check the tiles E,N,W and S of the current tile for houses */
 
	for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) {
 

	
 
		if (IsTileType(TileAddByDiagDir(tile, dir), MP_HOUSE)) counter++;
 
		/* Count both void and house tiles for checking whether there
 
		 * are enough houses in the area. This to make it likely that
 
		 * houses get build up to the edge of the map. */
 
		switch (GetTileType(TileAddByDiagDir(tile, dir))) {
 
			case MP_HOUSE:
 
			case MP_VOID:
 
				counter++;
 
				break;
 

	
 
			default:
 
				break;
 
		}
 

	
 
		/* If there are enough neighbors stop here */
 
		if (counter >= 3) {
 
@@ -1115,7 +1117,7 @@ static void GrowTownInTile(TileIndex *ti
 
		/* Don't walk into water. */
 
		if (IsWaterTile(house_tile)) return;
 

	
 
		if (!IsValidTile(house_tile) || !IsValidTile(house_tile + TileOffsByDiagDir(target_dir))) return;
 
		if (!IsValidTile(house_tile)) return;
 

	
 
		if (_settings_game.economy.allow_town_roads || _generating_world) {
 
			switch (t1->layout) {
0 comments (0 inline, 0 general)