mirror of https://github.com/OpenTTD/OpenTTD
Towns currently don't build disallowed roadtypes, however they should also not extend disallowed roadtypes as well. If the roadtype that cannot be extended happens to be the roadtype that the town was going to build then this restriction is ignored.pull/10610/head
parent
5f99c8c4aa
commit
ff55bfb787
|
@ -1362,6 +1362,20 @@ static inline bool RoadTypesAllowHouseHere(TileIndex t)
|
||||||
return !allow;
|
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(town) == rt;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grows the given town.
|
* Grows the given town.
|
||||||
* There are at the moment 3 possible way's for
|
* There are at the moment 3 possible way's for
|
||||||
|
@ -1438,6 +1452,8 @@ static void GrowTownInTile(TileIndex *tile_ptr, RoadBits cur_rb, DiagDirection t
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (target_dir < DIAGDIR_END && !(cur_rb & DiagDirToRoadBits(ReverseDiagDir(target_dir)))) {
|
} else if (target_dir < DIAGDIR_END && !(cur_rb & DiagDirToRoadBits(ReverseDiagDir(target_dir)))) {
|
||||||
|
if (!TownCanGrowRoad(t1, tile)) return;
|
||||||
|
|
||||||
/* Continue building on a partial road.
|
/* Continue building on a partial road.
|
||||||
* Should be always OK, so we only generate
|
* Should be always OK, so we only generate
|
||||||
* the fitting RoadBits */
|
* the fitting RoadBits */
|
||||||
|
@ -1557,6 +1573,8 @@ static void GrowTownInTile(TileIndex *tile_ptr, RoadBits cur_rb, DiagDirection t
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!TownCanGrowRoad(t1, tile)) return;
|
||||||
|
|
||||||
_grow_town_result = GROWTH_SEARCH_STOPPED;
|
_grow_town_result = GROWTH_SEARCH_STOPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue