Loading

Paste #prgjo8rdm

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

Version history

Revision # Author Created at
pntsd7s9a Anonymous 26 Aug 2016, 17:16:05 UTC Diff
pfrpc7gor Anonymous 26 Aug 2016, 16:00:05 UTC Diff
pxgtxqlwk Anonymous 26 Aug 2016, 13:19:20 UTC Diff
pwaldxdg9 Anonymous 26 Aug 2016, 11:43:35 UTC Diff

Comments