Loading

Paste #phckb7exn

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

Version history

Revision # Author Created at
pogzmtclz Anonymous 18 Feb 2015, 16:36:18 UTC Diff
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