Loading

Paste #pfrpc7gor

  1. Index: src/station_cmd.cpp
  2. ===================================================================
  3. --- src/station_cmd.cpp (revision 27632)
  4. +++ src/station_cmd.cpp (working copy)
  5. @@ -2504,6 +2504,9 @@
  6.         return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
  7.     }
  8.  
  9. +   ret = EnsureNoShipOnDiagDir(tile_cur, ReverseDiagDir(direction));
  10. +   if (ret.Failed()) return ret;
  11. +
  12.     TileArea dock_area = TileArea(tile + ToTileIndexDiff(_dock_tileoffs_chkaround[direction]),
  13.             _dock_w_chk[direction], _dock_h_chk[direction]);
  14.  
  15. Index: src/vehicle.cpp
  16. ===================================================================
  17. --- src/vehicle.cpp (revision 27632)
  18. +++ src/vehicle.cpp (working copy)
  19. @@ -484,6 +484,24 @@
  20.     return CommandCost();
  21.  }
  22.  
  23. +/**
  24. +* Ensure there is no ship on the water at the given diagonal direction.
  25. +* @param tile Position to examine.
  26. +* @param diag_dir Diagonal direction
  27. +* @return Succeeded command (water is free) or failed command (a ship is found).
  28. +*/
  29. +CommandCost EnsureNoShipOnDiagDir(TileIndex tile, DiagDirection diag_dir)
  30. +{
  31. +   if (HasTileWaterClass(tile)) {
  32. +       TrackBits tb = TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0));
  33. +       if (((diag_dir == DIAGDIR_NE && (tb & TRACK_BIT_3WAY_NE) != 0) || (diag_dir == DIAGDIR_SE && (tb & TRACK_BIT_3WAY_SE) != 0) || (diag_dir == DIAGDIR_NW && (tb & TRACK_BIT_3WAY_NW) != 0) || (diag_dir == DIAGDIR_SW && (tb & TRACK_BIT_3WAY_SW) != 0) && !IsShipDepotTile(tile) && IsTileType(tile, MP_WATER) && !IsLock(tile))) {
  34. +           CommandCost ret = EnsureNoVehicleOnGround(tile);
  35. +           if (ret.Failed()) return ret;
  36. +       }
  37. +   }
  38. +   return CommandCost();
  39. +}
  40. +
  41.  /** Procedure called for every vehicle found in tunnel/bridge in the hash map */
  42.  static Vehicle *GetVehicleTunnelBridgeProc(Vehicle *v, void *data)
  43.  {
  44. Index: src/vehicle_func.h
  45. ===================================================================
  46. --- src/vehicle_func.h  (revision 27632)
  47. +++ src/vehicle_func.h  (working copy)
  48. @@ -165,6 +165,7 @@
  49.  
  50.  CommandCost EnsureNoVehicleOnGround(TileIndex tile);
  51.  CommandCost EnsureNoTrainOnTrackBits(TileIndex tile, TrackBits track_bits);
  52. +CommandCost EnsureNoShipOnDiagDir(TileIndex tile, DiagDirection diag_dir);
  53.  
  54.  extern VehicleID _new_vehicle_id;
  55.  extern uint16 _returned_refit_capacity;
  56. Index: src/water_cmd.cpp
  57. ===================================================================
  58. --- src/water_cmd.cpp   (revision 27632)
  59. +++ src/water_cmd.cpp   (working copy)
  60. @@ -135,6 +135,24 @@
  61.         cost.AddCost(ret);
  62.     }
  63.  
  64. +   DiagDirection dir_rotate = axis == AXIS_X ? DIAGDIR_SE : DIAGDIR_NE;
  65. +   TileIndex tc = tile + (axis == AXIS_X ? TileDiffXY(0, -1) : TileDiffXY(1, 0));
  66. +   ret = EnsureNoShipOnDiagDir(tc, dir_rotate);
  67. +   if (ret.Failed()) return ret;
  68. +
  69. +   tc = tile2 + (axis == AXIS_X ? TileDiffXY(0, -1) : TileDiffXY(1, 0));
  70. +   ret = EnsureNoShipOnDiagDir(tc, dir_rotate);
  71. +   if (ret.Failed()) return ret;
  72. +
  73. +   dir_rotate = ReverseDiagDir(dir_rotate);
  74. +   tc = tile + (axis == AXIS_X ? TileDiffXY(0, 1) : TileDiffXY(-1, 0));
  75. +   ret = EnsureNoShipOnDiagDir(tc, dir_rotate);
  76. +   if (ret.Failed()) return ret;
  77. +
  78. +   tc = tile2 + (axis == AXIS_X ? TileDiffXY(0, 1) : TileDiffXY(-1, 0));
  79. +   ret = EnsureNoShipOnDiagDir(tc, dir_rotate);
  80. +   if (ret.Failed()) return ret;
  81. +
  82.     if (flags & DC_EXEC) {
  83.         Depot *depot = new Depot(tile);
  84.         depot->build_date = _date;
  85. @@ -372,6 +390,25 @@
  86.     DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile));
  87.     if (dir == INVALID_DIAGDIR) return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
  88.  
  89. +   Axis axis = DiagDirToAxis(dir);
  90. +   DiagDirection dir_rotate = (dir == DIAGDIR_NE || dir == DIAGDIR_NW) ? ChangeDiagDir(dir, DIAGDIRDIFF_90RIGHT) : ChangeDiagDir(dir, DIAGDIRDIFF_90LEFT);
  91. +   TileIndex tc = tile + (axis == AXIS_X ? TileDiffXY(-1, -1) : TileDiffXY(1, -1));
  92. +   CommandCost ret = EnsureNoShipOnDiagDir(tc, dir_rotate);
  93. +   if (ret.Failed()) return ret;
  94. +
  95. +   tc = tile + (axis == AXIS_X ? TileDiffXY(1, -1) : TileDiffXY(1, 1));
  96. +   ret = EnsureNoShipOnDiagDir(tc, dir_rotate);
  97. +   if (ret.Failed()) return ret;
  98. +
  99. +   dir_rotate = ReverseDiagDir(dir_rotate);
  100. +   tc = tile + (axis == AXIS_X ? TileDiffXY(-1, 1) : TileDiffXY(-1, -1));
  101. +   ret = EnsureNoShipOnDiagDir(tc, dir_rotate);
  102. +   if (ret.Failed()) return ret;
  103. +
  104. +   tc = tile + (axis == AXIS_X ? TileDiffXY(1, 1) : TileDiffXY(-1, 1));
  105. +   ret = EnsureNoShipOnDiagDir(tc, dir_rotate);
  106. +   if (ret.Failed()) return ret;
  107. +
  108.     return DoBuildLock(tile, dir, flags);
  109.  }

Version history

Revision # Author Created at
pxgtxqlwk Anonymous 26 Aug 2016, 13:19:20 UTC Diff
pwaldxdg9 Anonymous 26 Aug 2016, 11:43:35 UTC Diff

Comments