(svn r13233) -Fix: Replace some (incorrect) evaluations of TileOwner by RoadOwner.

-Fix: Before evaluating RoadOwner, check if the roadtype is present.
-Fix: Some places assumed that MP_ROAD means normal street.
This commit is contained in:
frosch
2008-05-24 19:36:20 +00:00
parent c34b458ace
commit 6e7a7412cd
6 changed files with 34 additions and 28 deletions

View File

@@ -1212,14 +1212,14 @@ static int GrowTownAtRoad(Town *t, TileIndex tile)
do target_dir = RandomDiagDir(); while (!(cur_rb & DiagDirToRoadBits(target_dir)));
tile = TileAddByDiagDir(tile, target_dir);
if (IsTileType(tile, MP_ROAD)) {
if (IsTileType(tile, MP_ROAD) && !IsRoadDepot(tile) && HasTileRoadType(tile, ROADTYPE_ROAD)) {
/* Don't allow building over roads of other cities */
if (IsTileOwner(tile, OWNER_TOWN) && GetTownByTile(tile) != t) {
if (IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_TOWN) && GetTownByTile(tile) != t) {
_grow_town_result = GROWTH_SUCCEED;
} else if (IsTileOwner(tile, OWNER_NONE) && _game_mode == GM_EDITOR) {
} else if (IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_NONE) && _game_mode == GM_EDITOR) {
/* If we are in the SE, and this road-piece has no town owner yet, it just found an
* owner :) (happy happy happy road now) */
SetTileOwner(tile, OWNER_TOWN);
SetRoadOwner(tile, ROADTYPE_ROAD, OWNER_TOWN);
SetTownIndex(tile, t->index);
}
}
@@ -2438,8 +2438,8 @@ Town *CalcClosestTownFromTile(TileIndex tile, uint threshold)
Town *ClosestTownFromTile(TileIndex tile, uint threshold)
{
if (IsTileType(tile, MP_HOUSE) || (
IsTileType(tile, MP_ROAD) &&
GetRoadOwner(tile, ROADTYPE_ROAD) == OWNER_TOWN
IsTileType(tile, MP_ROAD) && HasTileRoadType(tile, ROADTYPE_ROAD) &&
IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_TOWN)
)) {
return GetTownByTile(tile);
} else {