equal
deleted
inserted
replaced
128 */ |
128 */ |
129 static bool EnsureNoTrainOnTrack(TileIndex tile, Track track) |
129 static bool EnsureNoTrainOnTrack(TileIndex tile, Track track) |
130 { |
130 { |
131 TrackBits rail_bits = TrackToTrackBits(track); |
131 TrackBits rail_bits = TrackToTrackBits(track); |
132 |
132 |
133 return VehicleFromPos(tile, &rail_bits, &EnsureNoTrainOnTrackProc) == NULL; |
133 return !HasVehicleOnPos(tile, &rail_bits, &EnsureNoTrainOnTrackProc); |
134 } |
134 } |
135 |
135 |
136 static bool CheckTrackCombination(TileIndex tile, TrackBits to_build, uint flags) |
136 static bool CheckTrackCombination(TileIndex tile, TrackBits to_build, uint flags) |
137 { |
137 { |
138 TrackBits current; // The current track layout |
138 TrackBits current; // The current track layout |
1332 } |
1332 } |
1333 |
1333 |
1334 SetRailType(tile, totype); |
1334 SetRailType(tile, totype); |
1335 MarkTileDirtyByTile(tile); |
1335 MarkTileDirtyByTile(tile); |
1336 /* update power of train engines on this tile */ |
1336 /* update power of train engines on this tile */ |
1337 VehicleFromPos(tile, NULL, &UpdateTrainPowerProc); |
1337 FindVehicleOnPos(tile, NULL, &UpdateTrainPowerProc); |
1338 } |
1338 } |
1339 } |
1339 } |
1340 |
1340 |
1341 switch (tt) { |
1341 switch (tt) { |
1342 case MP_RAILWAY: |
1342 case MP_RAILWAY: |
1382 if (endtile < tile && TileX(endtile) >= sx && TileX(endtile) <= ex && |
1382 if (endtile < tile && TileX(endtile) >= sx && TileX(endtile) <= ex && |
1383 TileY(endtile) >= sy && TileY(endtile) <= ey) continue; |
1383 TileY(endtile) >= sy && TileY(endtile) <= ey) continue; |
1384 |
1384 |
1385 /* When not coverting rail <-> el. rail, any vehicle cannot be in tunnel/bridge */ |
1385 /* When not coverting rail <-> el. rail, any vehicle cannot be in tunnel/bridge */ |
1386 if (!IsCompatibleRail(GetRailType(tile), totype) && |
1386 if (!IsCompatibleRail(GetRailType(tile), totype) && |
1387 GetVehicleTunnelBridge(tile, endtile) != NULL) continue; |
1387 !HasVehicleOnTunnelBridge(tile, endtile)) continue; |
1388 |
1388 |
1389 if (flags & DC_EXEC) { |
1389 if (flags & DC_EXEC) { |
1390 Track track = DiagDirToDiagTrack(GetTunnelBridgeDirection(tile)); |
1390 Track track = DiagDirToDiagTrack(GetTunnelBridgeDirection(tile)); |
1391 if (GetTunnelBridgeReservation(tile)) { |
1391 if (GetTunnelBridgeReservation(tile)) { |
1392 Vehicle *v = GetTrainForReservation(tile, track); |
1392 Vehicle *v = GetTrainForReservation(tile, track); |
1396 } |
1396 } |
1397 } |
1397 } |
1398 SetRailType(tile, totype); |
1398 SetRailType(tile, totype); |
1399 SetRailType(endtile, totype); |
1399 SetRailType(endtile, totype); |
1400 |
1400 |
1401 VehicleFromPos(tile, NULL, &UpdateTrainPowerProc); |
1401 FindVehicleOnPos(tile, NULL, &UpdateTrainPowerProc); |
1402 VehicleFromPos(endtile, NULL, &UpdateTrainPowerProc); |
1402 FindVehicleOnPos(endtile, NULL, &UpdateTrainPowerProc); |
1403 |
1403 |
1404 YapfNotifyTrackLayoutChange(tile, track); |
1404 YapfNotifyTrackLayoutChange(tile, track); |
1405 YapfNotifyTrackLayoutChange(endtile, track); |
1405 YapfNotifyTrackLayoutChange(endtile, track); |
1406 |
1406 |
1407 MarkTileDirtyByTile(tile); |
1407 MarkTileDirtyByTile(tile); |