MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / TunnelBridgeIsFree

Function TunnelBridgeIsFree

src/vehicle.cpp:551–565  ·  view source on GitHub ↗

* 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). */

Source from the content-addressed store, hash-verified

549 * @return Succeeded command (if tunnel/bridge is free) or failed command (if a vehicle is using the tunnel/bridge).
550 */
551CommandCost 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.

Callers 7

CmdConvertRailFunction · 0.85
DoClearTunnelFunction · 0.85
DoClearBridgeFunction · 0.85
ClearPathReservationFunction · 0.85
RemoveRoadFunction · 0.85
CmdBuildRoadFunction · 0.85
CmdConvertRoadFunction · 0.85

Calls 2

VehiclesOnTileClass · 0.85
CommandCostClass · 0.85

Tested by

no test coverage detected