* Finds vehicle in tunnel / bridge * @param tile first end * @param endtile second end * @param ignore Ignore this vehicle when searching * @return Succeeded command (if tunnel/bridge is free) or failed command (if a vehicle is using the tunnel/bridge). */
| 549 | * @return Succeeded command (if tunnel/bridge is free) or failed command (if a vehicle is using the tunnel/bridge). |
| 550 | */ |
| 551 | CommandCost TunnelBridgeIsFree(TileIndex tile, TileIndex endtile, const Vehicle *ignore) |
| 552 | { |
| 553 | for (TileIndex t : {tile, endtile}) { |
| 554 | /* Value v is not safe in MP games, however, it is used to generate a local |
| 555 | * error message only (which may be different for different machines). |
| 556 | * Such a message does not affect MP synchronisation. |
| 557 | */ |
| 558 | for (const Vehicle *v : VehiclesOnTile(t)) { |
| 559 | if (v->type != VEH_TRAIN && v->type != VEH_ROAD && v->type != VEH_SHIP) continue; |
| 560 | if (v == ignore) continue; |
| 561 | return CommandCost(STR_ERROR_TRAIN_IN_THE_WAY + v->type); |
| 562 | } |
| 563 | } |
| 564 | return CommandCost(); |
| 565 | } |
| 566 | |
| 567 | /** |
| 568 | * Tests if a vehicle interacts with the specified track bits. |
no test coverage detected