equal
deleted
inserted
replaced
6 #include "openttd.h" |
6 #include "openttd.h" |
7 #include "tile_cmd.h" |
7 #include "tile_cmd.h" |
8 #include "debug.h" |
8 #include "debug.h" |
9 #include "road_map.h" |
9 #include "road_map.h" |
10 #include "road_internal.h" /* Cleaning up road bits */ |
10 #include "road_internal.h" /* Cleaning up road bits */ |
|
11 #include "road_cmd.h" |
11 #include "landscape.h" |
12 #include "landscape.h" |
12 #include "town_map.h" |
13 #include "town_map.h" |
13 #include "tunnel_map.h" |
14 #include "tunnel_map.h" |
14 #include "viewport_func.h" |
15 #include "viewport_func.h" |
15 #include "town.h" |
16 #include "town.h" |
91 case MP_HOUSE: |
92 case MP_HOUSE: |
92 if (GetTownByTile(tile) == this) DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); |
93 if (GetTownByTile(tile) == this) DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); |
93 break; |
94 break; |
94 |
95 |
95 case MP_ROAD: |
96 case MP_ROAD: |
|
97 if (!IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_TOWN) && GetTownIndex(tile) == this->index) { |
|
98 /* Town-owned roads get cleared soon, anyway */ |
|
99 SetTownIndex(tile, (TownID)INVALID_TOWN); |
|
100 break; |
|
101 } |
|
102 /* Fall-through */ |
96 case MP_TUNNELBRIDGE: |
103 case MP_TUNNELBRIDGE: |
97 if (IsTileOwner(tile, OWNER_TOWN) && |
104 if (IsTileOwner(tile, OWNER_TOWN) && |
98 ClosestTownFromTile(tile, UINT_MAX) == this) |
105 ClosestTownFromTile(tile, UINT_MAX) == this) |
99 DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); |
106 DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); |
100 break; |
107 break; |
1556 /* Create the town */ |
1563 /* Create the town */ |
1557 if (flags & DC_EXEC) { |
1564 if (flags & DC_EXEC) { |
1558 Town *t = new Town(tile); |
1565 Town *t = new Town(tile); |
1559 _generating_world = true; |
1566 _generating_world = true; |
1560 DoCreateTown(t, tile, townnameparts, (TownSizeMode)p2, p1); |
1567 DoCreateTown(t, tile, townnameparts, (TownSizeMode)p2, p1); |
|
1568 InvalidateTownForRoadTile(); |
1561 _generating_world = false; |
1569 _generating_world = false; |
1562 } |
1570 } |
1563 return CommandCost(); |
1571 return CommandCost(); |
1564 } |
1572 } |
1565 |
1573 |
2466 if (IsTileType(tile, MP_HOUSE) || ( |
2474 if (IsTileType(tile, MP_HOUSE) || ( |
2467 IsTileType(tile, MP_ROAD) && HasTileRoadType(tile, ROADTYPE_ROAD) && |
2475 IsTileType(tile, MP_ROAD) && HasTileRoadType(tile, ROADTYPE_ROAD) && |
2468 IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_TOWN) |
2476 IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_TOWN) |
2469 )) { |
2477 )) { |
2470 return GetTownByTile(tile); |
2478 return GetTownByTile(tile); |
|
2479 } else if (IsTileType(tile, MP_ROAD)) { |
|
2480 TownID town_id = GetTownIndex(tile); |
|
2481 Town *town; |
|
2482 |
|
2483 if (town_id == INVALID_TOWN) { |
|
2484 town = CalcClosestTownFromTile(tile, UINT_MAX); |
|
2485 if (town != NULL) SetTownIndex(tile, town->index); |
|
2486 } else { |
|
2487 town = GetTown(town_id); |
|
2488 } |
|
2489 |
|
2490 if (town != NULL && town->IsValid() && DistanceManhattan(tile, town->xy) < threshold) return town; |
|
2491 return NULL; |
2471 } else { |
2492 } else { |
2472 return CalcClosestTownFromTile(tile, threshold); |
2493 return CalcClosestTownFromTile(tile, threshold); |
2473 } |
2494 } |
2474 } |
2495 } |
2475 |
2496 |