Loading

Paste #pogzmtclz

  1. Index: src/saveload/company_sl.cpp
  2. ===================================================================
  3. --- src/saveload/company_sl.cpp (revision 27153)
  4. +++ src/saveload/company_sl.cpp (working copy)
  5. @@ -179,8 +179,12 @@
  6.                         if (IsShipDepot(tile)) c->infrastructure.water += LOCK_DEPOT_TILE_FACTOR;
  7.                         if (IsLock(tile) && GetLockPart(tile) == LOCK_PART_MIDDLE) {
  8.                             /* The middle tile specifies the owner of the lock. */
  9. -                           c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // the middle tile specifies the owner of the
  10. -                           break; // do not count the middle tile as canal
  11. +                           c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR;
  12. +                           /* Only count the middle tile as canal if the tile is not river. */
  13. +                           if (GetWaterClass(tile) != WATER_CLASS_RIVER) {
  14. +                               c->infrastructure.water++;
  15. +                           }
  16. +                           break;
  17.                         }
  18.                     }
  19.                 }
  20. Index: src/water_cmd.cpp
  21. ===================================================================
  22. --- src/water_cmd.cpp   (revision 27153)
  23. +++ src/water_cmd.cpp   (working copy)
  24. @@ -258,9 +258,14 @@
  25.  
  26.     /* middle tile */
  27.     WaterClass wc_middle = IsWaterTile(tile) ? GetWaterClass(tile) : WATER_CLASS_CANAL;
  28. -   ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
  29. -   if (ret.Failed()) return ret;
  30. -   cost.AddCost(ret);
  31. +  
  32. +   /* Add the cost of building a canal when the middle tile isn't a river. */
  33. +   if (!IsWaterTile(tile)) {
  34. +       ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
  35. +       if (ret.Failed()) return ret;
  36. +       cost.AddCost(ret);
  37. +       cost.AddCost(_price[PR_BUILD_CANAL]); // extra cost.
  38. +   }
  39.  
  40.     /* lower tile */
  41.     WaterClass wc_lower = IsWaterTile(tile - delta) ? GetWaterClass(tile - delta) : WATER_CLASS_CANAL;
  42. @@ -298,6 +303,7 @@
  43.         if (c != NULL) {
  44.             /* Counts for the water. */
  45.             if (!IsWaterTile(tile - delta)) c->infrastructure.water++;
  46. +           if (!IsWaterTile(tile)) c->infrastructure.water++; // extra count.
  47.             if (!IsWaterTile(tile + delta)) c->infrastructure.water++;
  48.             /* Count for the lock itself. */
  49.             c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock is three tiles.
  50. @@ -324,6 +330,8 @@
  51.   */
  52.  static CommandCost RemoveLock(TileIndex tile, DoCommandFlag flags)
  53.  {
  54. +   CommandCost cost(EXPENSES_CONSTRUCTION); // dependable variable needed to adjust cost for this command.
  55. +  
  56.     if (GetTileOwner(tile) != OWNER_NONE) {
  57.         CommandCost ret = CheckTileOwnership(tile);
  58.         if (ret.Failed()) return ret;
  59. @@ -337,6 +345,9 @@
  60.     if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile - delta);
  61.     if (ret.Failed()) return ret;
  62.  
  63. +   /* Add the cost for removing a canal tile when the middle tile isn't a river. */
  64. +   if (GetWaterClass(tile) != WATER_CLASS_RIVER) cost.AddCost(_price[PR_CLEAR_CANAL]); // extra cost only if it was not built on a river
  65. +
  66.     if (flags & DC_EXEC) {
  67.         /* Remove middle part from company infrastructure count. */
  68.         Company *c = Company::GetIfValid(GetTileOwner(tile));
  69. @@ -348,6 +359,9 @@
  70.         if (GetWaterClass(tile) == WATER_CLASS_RIVER) {
  71.             MakeRiver(tile, Random());
  72.         } else {
  73. +           if (c != NULL) { // make sure it's not a leftover or neutral lock.
  74. +               c->infrastructure.water--; // extra count.
  75. +           }
  76.             DoClearSquare(tile);
  77.         }
  78.         MakeWaterKeepingClass(tile + delta, GetTileOwner(tile + delta));
  79. @@ -357,7 +371,9 @@
  80.         MarkCanalsAndRiversAroundDirty(tile + delta);
  81.     }
  82.  
  83. -   return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_LOCK]);
  84. +   cost.AddCost(_price[PR_CLEAR_LOCK]); // add the base cost of clearing a lock
  85. +   return cost; // final cost for this command
  86. +
  87.  }
  88.  
  89.  /**
  90. @@ -1275,9 +1291,15 @@
  91.     bool is_lock_middle = IsLock(tile) && GetLockPart(tile) == LOCK_PART_MIDDLE;
  92.  
  93.     /* No need to dirty company windows here, we'll redraw the whole screen anyway. */
  94. -   if (is_lock_middle) Company::Get(old_owner)->infrastructure.water -= 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.
  95. +   if (is_lock_middle) {
  96. +       Company::Get(old_owner)->infrastructure.water -= 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.
  97. +       if (GetWaterClass(tile) == WATER_CLASS_CANAL) Company::Get(old_owner)->infrastructure.water--; // extra count.
  98. +   }
  99.     if (new_owner != INVALID_OWNER) {
  100. -       if (is_lock_middle) Company::Get(new_owner)->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.
  101. +       if (is_lock_middle) {
  102. +           Company::Get(new_owner)->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.
  103. +           if (GetWaterClass(tile) == WATER_CLASS_CANAL) Company::Get(new_owner)->infrastructure.water++; // extra count.
  104. +       }
  105.         /* Only subtract from the old owner here if the new owner is valid,
  106.          * otherwise we clear ship depots and canal water below. */
  107.         if (GetWaterClass(tile) == WATER_CLASS_CANAL && !is_lock_middle) {

Version history

Revision # Author Created at
pagzyrmdn Anonymous 18 Feb 2015, 14:47:07 UTC Diff
pun0ehlix Anonymous 17 Feb 2015, 20:29:45 UTC Diff
pft3rt0m2 Anonymous 17 Feb 2015, 01:53:06 UTC Diff
pv8ckd8ru Anonymous 16 Feb 2015, 23:53:20 UTC Diff
pslxvnpmw Anonymous 16 Feb 2015, 23:50:25 UTC Diff

Comments