* Check if a town 'owns' a bridge. * Bridges do not directly have an owner, so we check the tiles adjacent to the bridge ends. * If either adjacent tile belongs to the town then it will be assumed that the town built * the bridge. * @param tile The bridge tile to test * @param t The town we are interested in * @return true If town 'owns' a bridge. */
| 97 | * @return true If town 'owns' a bridge. |
| 98 | */ |
| 99 | static bool TestTownOwnsBridge(TileIndex tile, const Town *t) |
| 100 | { |
| 101 | if (!IsTileOwner(tile, OWNER_TOWN)) return false; |
| 102 | |
| 103 | TileIndex adjacent = tile + TileOffsByDiagDir(ReverseDiagDir(GetTunnelBridgeDirection(tile))); |
| 104 | bool town_owned = IsTileType(adjacent, MP_ROAD) && IsTileOwner(adjacent, OWNER_TOWN) && GetTownIndex(adjacent) == t->index; |
| 105 | |
| 106 | if (!town_owned) { |
| 107 | /* Or other adjacent road */ |
| 108 | adjacent = tile + TileOffsByDiagDir(ReverseDiagDir(GetTunnelBridgeDirection(GetOtherTunnelBridgeEnd(tile)))); |
| 109 | town_owned = IsTileType(adjacent, MP_ROAD) && IsTileOwner(adjacent, OWNER_TOWN) && GetTownIndex(adjacent) == t->index; |
| 110 | } |
| 111 | |
| 112 | return town_owned; |
| 113 | } |
| 114 | |
| 115 | Town::~Town() |
| 116 | { |
no test coverage detected