diff options
author | truelight <truelight@openttd.org> | 2005-02-04 13:56:51 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2005-02-04 13:56:51 +0000 |
commit | 40323bbce21cf9b481c117cdc513abf2bf1148bd (patch) | |
tree | 33a6dff73b5aaed4318fba08028a08afcb64f1af /road_cmd.c | |
parent | f183ca5cc298ae220f377d83f7da43379cdf1bdb (diff) | |
download | openttd-40323bbce21cf9b481c117cdc513abf2bf1148bd.tar.xz |
(svn r1784) -Fix: removed ClosestTownFromTile where possible, or replaced it
with _map2-data if possible (Celestar / TrueLight)
Diffstat (limited to 'road_cmd.c')
-rw-r--r-- | road_cmd.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/road_cmd.c b/road_cmd.c index b195bc63d..4655b45f2 100644 --- a/road_cmd.c +++ b/road_cmd.c @@ -107,7 +107,7 @@ static bool CheckAllowRemoveRoad(uint tile, uint br, bool *edge_road) if (_patches.extra_dynamite) return true; - t = ClosestTownFromTile(tile, (uint)-1); + t = GetTown(_map2[tile]); SetDParam(0, t->index); _error_message = STR_2009_LOCAL_AUTHORITY_REFUSES; return false; @@ -149,7 +149,10 @@ int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) FindLandscapeHeight(&ti, x, y); tile = ti.tile; - t = ClosestTownFromTile(tile, (uint)-1); // needed for town rating penalty + if(_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR) + t = GetTown(_map2[tile]); // needed for town rating penalty + else + t = NULL; // allow deleting road under bridge if (ti.type != MP_TUNNELBRIDGE && !EnsureNoVehicle(tile)) @@ -964,12 +967,18 @@ static void TileLoop_Road(uint tile) return; if (((_map3_hi[tile] & 0x70) >> 4) < 6) { - t = ClosestTownFromTile(tile, (uint)-1); + if(_map_owner[tile] == OWNER_TOWN) + t = GetTown(_map2[tile]); + else + t = ClosestTownFromTile(tile, (uint)-1); + grp = 0; if (t != NULL) { - // If in the scenario editor, set the owner to a town. - if (_game_mode == GM_EDITOR) { + /* In SE, set the owner to OWNER_TOWN */ + if (_game_mode == GM_EDITOR && _map_owner[tile] != OWNER_TOWN) { _map_owner[tile] = OWNER_TOWN; + /* XXX - This line is not perfect, any suggestions? */ + _map2[tile] = ClosestTownFromTile(tile, (uint)-1)->index; } grp = GetTownRadiusGroup(t, tile); |