Loading

Paste #p0yhrws4t

  1. Index: src/water_cmd.cpp
  2. ===================================================================
  3. --- src/water_cmd.cpp   (revision 27196)
  4. +++ src/water_cmd.cpp   (working copy)
  5. @@ -123,6 +123,8 @@
  6.     CommandCost cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_DEPOT_SHIP]);
  7.  
  8.     bool add_cost = !IsWaterTile(tile);
  9. +   bool river1 = HasBit(_me[tile].m6, 0);
  10. +   bool river2 = HasBit(_me[tile2].m6, 0);
  11.     CommandCost ret = DoCommand(tile, 0, 0, flags | DC_AUTO, CMD_LANDSCAPE_CLEAR);
  12.     if (ret.Failed()) return ret;
  13.     if (add_cost) {
  14. @@ -145,7 +147,8 @@
  15.         }
  16.         Company::Get(_current_company)->infrastructure.water += 2 * LOCK_DEPOT_TILE_FACTOR;
  17.         DirtyCompanyInfrastructureWindows(_current_company);
  18. -
  19. +       if (river1) SB(_me[tile].m6, 0, 1, 1);
  20. +       if (river2) SB(_me[tile2].m6, 0, 1, 1);
  21.         MakeShipDepot(tile,  _current_company, depot->index, DEPOT_PART_NORTH, axis, wc1);
  22.         MakeShipDepot(tile2, _current_company, depot->index, DEPOT_PART_SOUTH, axis, wc2);
  23.         MarkTileDirtyByTile(tile);
  24. @@ -209,13 +212,16 @@
  25.  
  26.  static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlag flags)
  27.  {
  28. +   TileIndex tile2 = GetOtherShipDepotTile(tile);
  29. +   bool river1 = HasBit(_me[tile].m6, 0);
  30. +   bool river2 = HasBit(_me[tile2].m6, 0);
  31.     if (!IsShipDepot(tile)) return CMD_ERROR;
  32.  
  33.     CommandCost ret = CheckTileOwnership(tile);
  34.     if (ret.Failed()) return ret;
  35.  
  36. -   TileIndex tile2 = GetOtherShipDepotTile(tile);
  37.  
  38. +
  39.     /* do not check for ship on tile when company goes bankrupt */
  40.     if (!(flags & DC_BANKRUPT)) {
  41.         CommandCost ret = EnsureNoVehicleOnGround(tile);
  42. @@ -231,7 +237,8 @@
  43.             c->infrastructure.water -= 2 * LOCK_DEPOT_TILE_FACTOR;
  44.             DirtyCompanyInfrastructureWindows(c->index);
  45.         }
  46. -
  47. +       if (river1) SB(_me[tile].m6, 0, 1, 1);
  48. +       if (river2) SB(_me[tile2].m6, 0, 1, 1);
  49.         MakeWaterKeepingClass(tile,  GetTileOwner(tile));
  50.         MakeWaterKeepingClass(tile2, GetTileOwner(tile2));
  51.     }
  52. @@ -264,7 +271,7 @@
  53.  
  54.     /* lower tile */
  55.     WaterClass wc_lower = IsWaterTile(tile - delta) ? GetWaterClass(tile - delta) : WATER_CLASS_CANAL;
  56. -
  57. +  
  58.     if (!IsWaterTile(tile - delta)) {
  59.         ret = DoCommand(tile - delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
  60.         if (ret.Failed()) return ret;
  61. @@ -277,7 +284,7 @@
  62.  
  63.     /* upper tile */
  64.     WaterClass wc_upper = IsWaterTile(tile + delta) ? GetWaterClass(tile + delta) : WATER_CLASS_CANAL;
  65. -
  66. +  
  67.     if (!IsWaterTile(tile + delta)) {
  68.         ret = DoCommand(tile + delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
  69.         if (ret.Failed()) return ret;
  70. @@ -291,7 +298,8 @@
  71.     if (IsBridgeAbove(tile) || IsBridgeAbove(tile - delta) || IsBridgeAbove(tile + delta)) {
  72.         return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
  73.     }
  74. -
  75. +   bool river_lower = HasBit(_me[tile - delta].m6, 0);
  76. +   bool river_upper = HasBit(_me[tile + delta].m6, 0);
  77.     if (flags & DC_EXEC) {
  78.         /* Update company infrastructure counts. */
  79.         Company *c = Company::GetIfValid(_current_company);
  80. @@ -303,7 +311,8 @@
  81.             c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock is three tiles.
  82.             DirtyCompanyInfrastructureWindows(_current_company);
  83.         }
  84. -
  85. +       if (river_lower) SB(_me[tile - delta].m6, 0, 1, 1);
  86. +       if (river_upper) SB(_me[tile + delta].m6, 0, 1, 1);
  87.         MakeLock(tile, _current_company, dir, wc_lower, wc_upper, wc_middle);
  88.         MarkTileDirtyByTile(tile);
  89.         MarkTileDirtyByTile(tile - delta);
  90. @@ -336,7 +345,8 @@
  91.     if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile + delta);
  92.     if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile - delta);
  93.     if (ret.Failed()) return ret;
  94. -
  95. +   bool river_lower = HasBit(_me[tile - delta].m6, 0);
  96. +   bool river_upper = HasBit(_me[tile + delta].m6, 0);
  97.     if (flags & DC_EXEC) {
  98.         /* Remove middle part from company infrastructure count. */
  99.         Company *c = Company::GetIfValid(GetTileOwner(tile));
  100. @@ -352,6 +362,8 @@
  101.         }
  102.         MakeWaterKeepingClass(tile + delta, GetTileOwner(tile + delta));
  103.         MakeWaterKeepingClass(tile - delta, GetTileOwner(tile - delta));
  104. +       if (river_lower) SB(_me[tile - delta].m6, 0, 1, 1);
  105. +       if (river_upper) SB(_me[tile + delta].m6, 0, 1, 1);
  106.         MarkCanalsAndRiversAroundDirty(tile);
  107.         MarkCanalsAndRiversAroundDirty(tile - delta);
  108.         MarkCanalsAndRiversAroundDirty(tile + delta);
  109. @@ -419,6 +431,7 @@
  110.         if (IsTileType(tile, MP_WATER) && (!IsTileOwner(tile, OWNER_WATER) || wc == WATER_CLASS_SEA)) continue;
  111.  
  112.         bool water = IsWaterTile(tile);
  113. +       bool river = HasTileWaterClass(tile) && GetWaterClass(tile) == WATER_CLASS_RIVER;
  114.         ret = DoCommand(tile, 0, 0, flags | DC_FORCE_CLEAR_TILE, CMD_LANDSCAPE_CLEAR);
  115.         if (ret.Failed()) return ret;
  116.  
  117. @@ -442,6 +455,7 @@
  118.                     /* FALL THROUGH */
  119.  
  120.                 default:
  121. +                   if (river) SB(_me[tile].m6, 0, 1, 1);
  122.                     MakeCanal(tile, _current_company, Random());
  123.                     if (Company::IsValidID(_current_company)) {
  124.                         Company::Get(_current_company)->infrastructure.water++;
  125. @@ -465,6 +479,7 @@
  126.  
  127.  static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags)
  128.  {
  129. +   bool river = HasBit(_me[tile].m6, 0);
  130.     switch (GetWaterTileType(tile)) {
  131.         case WATER_TILE_CLEAR: {
  132.             if (flags & DC_NO_WATER) return_cmd_error(STR_ERROR_CAN_T_BUILD_ON_WATER);
  133. @@ -485,7 +500,6 @@
  134.                 CommandCost ret = CheckTileOwnership(tile);
  135.                 if (ret.Failed()) return ret;
  136.             }
  137. -
  138.             if (flags & DC_EXEC) {
  139.                 if (IsCanal(tile) && Company::IsValidID(owner)) {
  140.                     Company::Get(owner)->infrastructure.water--;
  141. @@ -492,9 +506,9 @@
  142.                     DirtyCompanyInfrastructureWindows(owner);
  143.                 }
  144.                 DoClearSquare(tile);
  145. +               if (river) MakeRiver(tile, Random());
  146.                 MarkCanalsAndRiversAroundDirty(tile);
  147.             }
  148. -
  149.             return CommandCost(EXPENSES_CONSTRUCTION, base_cost);
  150.         }

Version history

Revision # Author Created at
pqeuk1r9b Anonymous 18 Mar 2015, 21:39:39 UTC Diff
pg4tog6je Anonymous 18 Mar 2015, 19:06:18 UTC Diff

Comments