Merge branch 'master' into jgrpp

# Conflicts:
#	src/widgets/dropdown.cpp
#	src/widgets/dropdown_type.h
This commit is contained in:
Jonathan G Rennison
2023-04-17 20:51:54 +01:00
19 changed files with 125 additions and 102 deletions

View File

@@ -1529,6 +1529,20 @@ static inline bool RoadTypesAllowHouseHere(TileIndex t)
return !allow;
}
/** Test if town can grow road onto a specific tile.
* @param town Town that is building.
* @param tile Tile to build upon.
* @return true iff the tile's road type don't prevent extending the road.
*/
static bool TownCanGrowRoad(const Town *town, TileIndex tile)
{
if (!IsTileType(tile, MP_ROAD)) return true;
/* Allow extending on roadtypes which can be built by town, or if the road type matches the type the town will build. */
RoadType rt = GetRoadTypeRoad(tile);
return HasBit(GetRoadTypeInfo(rt)->flags, ROTF_TOWN_BUILD) || GetTownRoadType() == rt;
}
/**
* Grows the given town.
* There are at the moment 3 possible way's for
@@ -1636,6 +1650,8 @@ static void GrowTownInTile(TileIndex *tile_ptr, RoadBits cur_rb, DiagDirection t
}
} else if (target_dir < DIAGDIR_END && !(cur_rb & DiagDirToRoadBits(ReverseDiagDir(target_dir)))) {
if (!TownCanGrowRoad(t1, tile)) return;
/* Continue building on a partial road.
* Should be always OK, so we only generate
* the fitting RoadBits */
@@ -1777,6 +1793,8 @@ static void GrowTownInTile(TileIndex *tile_ptr, RoadBits cur_rb, DiagDirection t
return;
}
if (!TownCanGrowRoad(t1, tile)) return;
_grow_town_result = GROWTH_SEARCH_STOPPED;
}