Loading

Paste #pppfawycl

  1. @ -47,6 +47,7 @@
  2. #include "effectvehicle_base.h"
  3. #include "vehiclelist.h"
  4. #include "bridge_map.h"
  5. #include "tunnelbridge_map.h"
  6. #include "tunnel_map.h"
  7. #include "depot_map.h"
  8. #include "gamelog.h"
  9. @ -546,6 +547,24 @@ CommandCost EnsureNoVehicleOnGround(TileIndex tile)
  10.      */
  11.     Vehicle *v = VehicleFromPos(tile, &z, &EnsureNoVehicleProcZ, true);
  12.     if (v != NULL) return_cmd_error(STR_ERROR_TRAIN_IN_THE_WAY + v->type);
  13.  
  14.     TrackBits trackbits = TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0));
  15.     if ((trackbits & TRACK_BIT_ALL) != TRACK_BIT_NONE) {
  16.         Ship *s;
  17.         FOR_ALL_SHIPS(s) {
  18.             if (DistanceManhattan(tile, s->tile) != 1) continue;
  19.             /* Don't care about ships on aqueducts. Those kind of tiles don't cause problems. */
  20.             /* The same can be applied to locks and ship depots. */
  21.             if (IsTileType(s->tile, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(s->tile) == TRANSPORT_WATER ||
  22.                     IsTileType(s->tile, MP_WATER) && IsLock(s->tile) || IsShipDepotTile(s->tile)) continue;
  23.             if (s->state & DiagdirReachesTracks(DiagdirBetweenTiles(tile, s->tile))) {
  24.                 if (DiagdirReachesTracks(DiagdirBetweenTiles(s->tile, tile)) & trackbits) {
  25.                     return_cmd_error(STR_ERROR_SHIP_IN_THE_WAY);
  26.                 }
  27.             }
  28.         }
  29.     }
  30.  
  31.     return CommandCost();
  32. }

Comments