Loading

Paste #pagzyrmdn

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

Version history

Revision # Author Created at
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