Loading

Global Patch

  1. Index: docs/landscape.html
  2. ===================================================================
  3. --- docs/landscape.html (revision 27200)
  4. +++ docs/landscape.html (working copy)
  5. @@ -975,7 +975,7 @@
  6.       </li>
  7.       <li>m6 bits 5..3: the station type (rail, airport, truck, bus, oilrig, dock, buoy, waypoint)</li>
  8.       <li>m6 bit 2: pbs reservation state for railway stations/waypoints</li>
  9. -
  10. +     <li>m6 bit 0: river restoration flag for whenever a canal is removed</li>
  11.       <li>m7 bits 4..0: <a href="#OwnershipInfo">owner</a> of road (road stops)</li>
  12.       <li>m7 bits 7..6: present road types (road stops)</li>
  13.       <li>m7: animation frame (railway stations/waypoints, airports)</li>
  14. @@ -1088,6 +1088,7 @@
  15.         </tr>
  16.        </table>
  17.       </li>
  18. +    <li>m6 bit 0: river restoration flag for whenever a canal is removed</li>
  19.      </ul>
  20.     </td>
  21.    </tr>
  22. @@ -1429,6 +1430,7 @@
  23.       </li>
  24.       <li>m6 bits 5..3: random triggers (NewGRF)</li>
  25.       <li>m6 bit 2: bit 8 of type (see m5)</li>
  26. +    <li>m6 bit 0: river restoration flag for whenever a canal is removed</li>
  27.       <li>m7: animation frame</li>
  28.      </ul>
  29.     </td>
  30. @@ -1599,6 +1601,7 @@
  31.       <li>m2: index into the array of objects, bits 0 to 15 (upper bits in m5)</li>
  32.       <li>m3: random bits</li>
  33.       <li>m5: index into the array of objects, bits 16 to 23 (lower bits in m2)</li>
  34. +    <li>m6 bit 0: river restoration flag for whenever a canal is removed</li>
  35.       <li>m7: animation counter</li>
  36.      </ul>
  37.     </td>
  38. Index: docs/landscape_grid.html
  39. ===================================================================
  40. --- docs/landscape_grid.html    (revision 27200)
  41. +++ docs/landscape_grid.html    (working copy)
  42. @@ -236,7 +236,7 @@
  43.        <td class="bits"><span class="free">OOOO OOOO</span></td>
  44.        <td class="bits"><span class="free">OOOO OOOO</span></td>
  45.        <td class="bits"><span class="option">~~~~ ~</span>XXX</td>
  46. -      <td class="bits"><span class="free">OO</span>XX X<span class="free">OOO</span></td>
  47. +      <td class="bits"><span class="free">OO</span>XX X<span class="free">OO</span>X</td>
  48.        <td class="bits"><span class="free">OOOO OOOO</span></td>
  49.      </tr>
  50.      <tr>
  51. @@ -260,7 +260,7 @@
  52.        <td class="bits"><span class="free">OOOO OOOO</span></td>
  53.        <td class="bits"><span class="free">OOOO OOOO</span></td>
  54.        <td class="bits"><span class="option">~~~~ ~~~~</span></td>
  55. -      <td class="bits"><span class="free">OO</span>XX X<span class="free">OOO</span></td>
  56. +      <td class="bits"><span class="free">OO</span>XX X<span class="free">OO</span>X</td>
  57.        <td class="bits"><span class="free">OOOO OOOO</span></td>
  58.      </tr>
  59.      <tr>
  60. @@ -272,7 +272,7 @@
  61.        <td class="bits"><span class="free">OOOO OOOO</span></td>
  62.        <td class="bits"><span class="free">OOOO OOOO</span></td>
  63.        <td class="bits"><span class="option">~~~~ ~~~~</span></td>
  64. -      <td class="bits"><span class="free">OO</span>XX X<span class="free">OOO</span></td>
  65. +      <td class="bits"><span class="free">OO</span>XX X<span class="free">OO</span>X</td>
  66.        <td class="bits"><span class="free">OOOO OOOO</span></td>
  67.      </tr>
  68.      <tr>
  69. @@ -297,8 +297,8 @@
  70.        <td class="bits"><span class="free">OOOO OOOO</span></td>
  71.        <td class="bits">XXXX XXXX</td>
  72.        <td class="bits">-inherit-</td>
  73. +      <td class="bits"><span class="free">OOOO OOO</span>X</td>
  74.        <td class="bits"><span class="free">OOOO OOOO</span></td>
  75. -      <td class="bits"><span class="free">OOOO OOOO</span></td>
  76.      </tr>
  77.      <tr>
  78.        <td class="caption">shipdepot</td>
  79. @@ -309,8 +309,8 @@
  80.        <td class="bits"><span class="free">OOOO OOOO</span></td>
  81.        <td class="bits"><span class="free">OOOO OOOO</span></td>
  82.        <td class="bits">-inherit-</td>
  83. +      <td class="bits"><span class="free">OOOO OOO</span>X</td>
  84.        <td class="bits"><span class="free">OOOO OOOO</span></td>
  85. -      <td class="bits"><span class="free">OOOO OOOO</span></td>
  86.      </tr>
  87.      <tr>
  88.        <td>8</td>
  89. @@ -322,7 +322,7 @@
  90.        <td class="bits">XXXX XXXX</td>
  91.        <td class="bits">XXXX XXXX</td>
  92.        <td class="bits">XXXX XXXX</td>
  93. -      <td class="bits"><span class="free">OO</span>XX XX<span class="free">OO</span></td>
  94. +      <td class="bits"><span class="free">OO</span>XX XX<span class="free">O</span>X</td>
  95.        <td class="bits">XXXX XXXX</td>
  96.      </tr>
  97.      <tr>
  98. @@ -360,7 +360,7 @@
  99.        <td class="bits">XXXX XXXX</td>
  100.        <td class="bits"><span class="free">OOOO OOOO</span></td>
  101.        <td class="bits">XXXX XXXX</td>
  102. -      <td class="bits"><span class="free">OOOO OOOO</span></td>
  103. +      <td class="bits"><span class="free">OOOO OOO</span>X</td>
  104.        <td class="bits">XXXX XXXX</td>
  105.      </tr>
  106.    </tbody>
  107. Index: src/industry_cmd.cpp
  108. ===================================================================
  109. --- src/industry_cmd.cpp    (revision 27200)
  110. +++ src/industry_cmd.cpp    (working copy)
  111. @@ -1755,9 +1755,9 @@
  112.             i->location.Add(cur_tile);
  113.  
  114.             WaterClass wc = (IsWaterTile(cur_tile) ? GetWaterClass(cur_tile) : WATER_CLASS_INVALID);
  115. -
  116. +           bool river = HasBit(_me[cur_tile].m6, 0);
  117.             DoCommand(cur_tile, 0, 0, DC_EXEC | DC_NO_TEST_TOWN_RATING | DC_NO_MODIFY_TOWN_RATING, CMD_LANDSCAPE_CLEAR);
  118. -
  119. +           if (river) SB(_me[cur_tile].m6, 0, 1, 1);
  120.             MakeIndustry(cur_tile, i->index, it->gfx, Random(), wc);
  121.  
  122.             if (_generating_world) {
  123. Index: src/saveload/company_sl.cpp
  124. ===================================================================
  125. --- src/saveload/company_sl.cpp (revision 27200)
  126. +++ src/saveload/company_sl.cpp (working copy)
  127. @@ -179,8 +179,11 @@
  128.                         if (IsShipDepot(tile)) c->infrastructure.water += LOCK_DEPOT_TILE_FACTOR;
  129.                         if (IsLock(tile) && GetLockPart(tile) == LOCK_PART_MIDDLE) {
  130.                             /* The middle tile specifies the owner of the lock. */
  131. -                           c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // the middle tile specifies the owner of the
  132. -                           break; // do not count the middle tile as canal
  133. +                           c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR;
  134. +
  135. +                           /* Only count the middle tile as canal if the tile is not river. */
  136. +                           if (GetWaterClass(tile) != WATER_CLASS_RIVER) c->infrastructure.water++;
  137. +                           break;
  138.                         }
  139.                     }
  140.                 }
  141. Index: src/station_cmd.cpp
  142. ===================================================================
  143. --- src/station_cmd.cpp (revision 27200)
  144. +++ src/station_cmd.cpp (working copy)
  145. @@ -2511,7 +2511,7 @@
  146.  
  147.     /* Get the water class of the water tile before it is cleared.*/
  148.     WaterClass wc = GetWaterClass(tile_cur);
  149. -
  150. +   bool river = HasBit(_me[tile_cur].m6, 0);
  151.     ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
  152.     if (ret.Failed()) return ret;
  153.  
  154. @@ -2551,7 +2551,7 @@
  155.         DirtyCompanyInfrastructureWindows(st->owner);
  156.  
  157.         MakeDock(tile, st->owner, st->index, direction, wc);
  158. -
  159. +       if (river) SB(_me[tile + TileOffsByDiagDir(direction)].m6, 0, 1, 1);
  160.         st->UpdateVirtCoord();
  161.         UpdateStationAcceptance(st, false);
  162.         st->RecomputeIndustriesNear();
  163. Index: src/table/build_industry.h
  164. ===================================================================
  165. --- src/table/build_industry.h  (revision 27200)
  166. +++ src/table/build_industry.h  (working copy)
  167. @@ -293,6 +293,19 @@
  168.     MK(-2, -4, 255),
  169.     MK(-3, -4, 255),
  170.     MK(2, 0, 255),
  171. +   MK(2, -1, 255),
  172. +   MK(1, -1, 255),
  173. +   MK(0, -1, 255),
  174. +   MK(-1, -1, 255),
  175. +   MK(-1, 0, 255),
  176. +   MK(-1, 1, 255),
  177. +   MK(-1, 2, 255),
  178. +   MK(-1, 3, 255),
  179. +   MK(0, 3, 255),
  180. +   MK(1, 3, 255),
  181. +   MK(2, 3, 255),
  182. +   MK(2, 2, 255),
  183. +   MK(2, 1, 255),
  184.     MKEND
  185.  };
  186.  
  187. Index: src/water_cmd.cpp
  188. ===================================================================
  189. --- src/water_cmd.cpp   (revision 27200)
  190. +++ src/water_cmd.cpp   (working copy)
  191. @@ -39,7 +39,7 @@
  192.  #include "company_base.h"
  193.  #include "company_gui.h"
  194.  #include "newgrf_generic.h"
  195. -
  196. +#include "cheat_type.h"
  197.  #include "table/strings.h"
  198.  
  199.  #include "safeguards.h"
  200. @@ -123,6 +123,8 @@
  201.     CommandCost cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_DEPOT_SHIP]);
  202.  
  203.     bool add_cost = !IsWaterTile(tile);
  204. +   bool river1 = HasBit(_me[tile].m6, 0);
  205. +   bool river2 = HasBit(_me[tile2].m6, 0);
  206.     CommandCost ret = DoCommand(tile, 0, 0, flags | DC_AUTO, CMD_LANDSCAPE_CLEAR);
  207.     if (ret.Failed()) return ret;
  208.     if (add_cost) {
  209. @@ -145,7 +147,8 @@
  210.         }
  211.         Company::Get(_current_company)->infrastructure.water += 2 * LOCK_DEPOT_TILE_FACTOR;
  212.         DirtyCompanyInfrastructureWindows(_current_company);
  213. -
  214. +       if (river1) SB(_me[tile].m6, 0, 1, 1);
  215. +       if (river2) SB(_me[tile2].m6, 0, 1, 1);
  216.         MakeShipDepot(tile,  _current_company, depot->index, DEPOT_PART_NORTH, axis, wc1);
  217.         MakeShipDepot(tile2, _current_company, depot->index, DEPOT_PART_SOUTH, axis, wc2);
  218.         MarkTileDirtyByTile(tile);
  219. @@ -192,7 +195,7 @@
  220.  
  221.         wc = WATER_CLASS_CANAL;
  222.     }
  223. -
  224. +   bool river = HasBit(_me[tile].m6, 0);
  225.     /* Zero map array and terminate animation */
  226.     DoClearSquare(tile);
  227.  
  228. @@ -199,7 +202,9 @@
  229.     /* Maybe change to water */
  230.     switch (wc) {
  231.         case WATER_CLASS_SEA:   MakeSea(tile);                break;
  232. -       case WATER_CLASS_CANAL: MakeCanal(tile, o, Random()); break;
  233. +       case WATER_CLASS_CANAL: MakeCanal(tile, o, Random());
  234. +           if (river) SB(_me[tile].m6, 0, 1, 1);
  235. +           break;
  236.         case WATER_CLASS_RIVER: MakeRiver(tile, Random());    break;
  237.         default: break;
  238.     }
  239. @@ -258,9 +263,14 @@
  240.  
  241.     /* middle tile */
  242.     WaterClass wc_middle = IsWaterTile(tile) ? GetWaterClass(tile) : WATER_CLASS_CANAL;
  243. -   ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
  244. -   if (ret.Failed()) return ret;
  245. -   cost.AddCost(ret);
  246. +      
  247. +   if (!IsWaterTile(tile)) {
  248. +       ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
  249. +       if (ret.Failed()) return ret;
  250. +       cost.AddCost(ret);
  251. +       /* Add an extra cost only if not building on a river. */
  252. +       cost.AddCost(_price[PR_BUILD_CANAL]);
  253. +   }
  254.  
  255.     /* lower tile */
  256.     WaterClass wc_lower = IsWaterTile(tile - delta) ? GetWaterClass(tile - delta) : WATER_CLASS_CANAL;
  257. @@ -291,7 +301,8 @@
  258.     if (IsBridgeAbove(tile) || IsBridgeAbove(tile - delta) || IsBridgeAbove(tile + delta)) {
  259.         return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
  260.     }
  261. -
  262. +   bool river_lower = HasBit(_me[tile - delta].m6, 0);
  263. +   bool river_upper = HasBit(_me[tile + delta].m6, 0);
  264.     if (flags & DC_EXEC) {
  265.         /* Update company infrastructure counts. */
  266.         Company *c = Company::GetIfValid(_current_company);
  267. @@ -298,12 +309,14 @@
  268.         if (c != NULL) {
  269.             /* Counts for the water. */
  270.             if (!IsWaterTile(tile - delta)) c->infrastructure.water++;
  271. +           if (!IsWaterTile(tile)) c->infrastructure.water++;
  272.             if (!IsWaterTile(tile + delta)) c->infrastructure.water++;
  273.             /* Count for the lock itself. */
  274.             c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock is three tiles.
  275.             DirtyCompanyInfrastructureWindows(_current_company);
  276.         }
  277. -
  278. +       if (river_lower) SB(_me[tile - delta].m6, 0, 1, 1);
  279. +       if (river_upper) SB(_me[tile + delta].m6, 0, 1, 1);
  280.         MakeLock(tile, _current_company, dir, wc_lower, wc_upper, wc_middle);
  281.         MarkTileDirtyByTile(tile);
  282.         MarkTileDirtyByTile(tile - delta);
  283. @@ -324,6 +337,8 @@
  284.   */
  285.  static CommandCost RemoveLock(TileIndex tile, DoCommandFlag flags)
  286.  {
  287. +   CommandCost cost(EXPENSES_CONSTRUCTION);
  288. +  
  289.     if (GetTileOwner(tile) != OWNER_NONE) {
  290.         CommandCost ret = CheckTileOwnership(tile);
  291.         if (ret.Failed()) return ret;
  292. @@ -337,6 +352,9 @@
  293.     if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile - delta);
  294.     if (ret.Failed()) return ret;
  295.  
  296. +   /* Add an extra cost only if it was not built on a river. */
  297. +   if (GetWaterClass(tile) != WATER_CLASS_RIVER) cost.AddCost(_price[PR_CLEAR_CANAL]);
  298. +
  299.     if (flags & DC_EXEC) {
  300.         /* Remove middle part from company infrastructure count. */
  301.         Company *c = Company::GetIfValid(GetTileOwner(tile));
  302. @@ -348,6 +366,7 @@
  303.         if (GetWaterClass(tile) == WATER_CLASS_RIVER) {
  304.             MakeRiver(tile, Random());
  305.         } else {
  306. +           if (c != NULL) c->infrastructure.water--; // Make sure it's not a leftover or neutral lock.
  307.             DoClearSquare(tile);
  308.         }
  309.         MakeWaterKeepingClass(tile + delta, GetTileOwner(tile + delta));
  310. @@ -357,7 +376,9 @@
  311.         MarkCanalsAndRiversAroundDirty(tile + delta);
  312.     }
  313.  
  314. -   return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_LOCK]);
  315. +   cost.AddCost(_price[PR_CLEAR_LOCK]);
  316. +   return cost;
  317. +
  318.  }
  319.  
  320.  /**
  321. @@ -419,6 +440,7 @@
  322.         if (IsTileType(tile, MP_WATER) && (!IsTileOwner(tile, OWNER_WATER) || wc == WATER_CLASS_SEA)) continue;
  323.  
  324.         bool water = IsWaterTile(tile);
  325. +       bool river = HasTileWaterClass(tile) && GetWaterClass(tile) == WATER_CLASS_RIVER;
  326.         ret = DoCommand(tile, 0, 0, flags | DC_FORCE_CLEAR_TILE, CMD_LANDSCAPE_CLEAR);
  327.         if (ret.Failed()) return ret;
  328.  
  329. @@ -442,6 +464,7 @@
  330.                     /* FALL THROUGH */
  331.  
  332.                 default:
  333. +                   if (river) SB(_me[tile].m6, 0, 1, 1);
  334.                     MakeCanal(tile, _current_company, Random());
  335.                     if (Company::IsValidID(_current_company)) {
  336.                         Company::Get(_current_company)->infrastructure.water++;
  337. @@ -465,6 +488,7 @@
  338.  
  339.  static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags)
  340.  {
  341. +   bool canal_on_river = HasBit(_me[tile].m6, 0);
  342.     switch (GetWaterTileType(tile)) {
  343.         case WATER_TILE_CLEAR: {
  344.             if (flags & DC_NO_WATER) return_cmd_error(STR_ERROR_CAN_T_BUILD_ON_WATER);
  345. @@ -486,12 +510,16 @@
  346.                 if (ret.Failed()) return ret;
  347.             }
  348.  
  349. +           if (IsRiver(tile) && _game_mode == GM_NORMAL && !_cheats.magic_bulldozer.value) base_cost = 0;
  350. +
  351.             if (flags & DC_EXEC) {
  352.                 if (IsCanal(tile) && Company::IsValidID(owner)) {
  353.                     Company::Get(owner)->infrastructure.water--;
  354.                     DirtyCompanyInfrastructureWindows(owner);
  355.                 }
  356. +               bool river = HasTileWaterClass(tile) && GetWaterClass(tile) == WATER_CLASS_RIVER;
  357.                 DoClearSquare(tile);
  358. +               if ((canal_on_river || river) && _game_mode == GM_NORMAL && !_cheats.magic_bulldozer.value) MakeRiver(tile, Random());
  359.                 MarkCanalsAndRiversAroundDirty(tile);
  360.             }
  361.  
  362. @@ -1275,9 +1303,15 @@
  363.     bool is_lock_middle = IsLock(tile) && GetLockPart(tile) == LOCK_PART_MIDDLE;
  364.  
  365.     /* No need to dirty company windows here, we'll redraw the whole screen anyway. */
  366. -   if (is_lock_middle) Company::Get(old_owner)->infrastructure.water -= 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.
  367. +   if (is_lock_middle) {
  368. +       Company::Get(old_owner)->infrastructure.water -= 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.
  369. +       if (GetWaterClass(tile) == WATER_CLASS_CANAL) Company::Get(old_owner)->infrastructure.water--;
  370. +   }
  371.     if (new_owner != INVALID_OWNER) {
  372. -       if (is_lock_middle) Company::Get(new_owner)->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.
  373. +       if (is_lock_middle) {
  374. +           Company::Get(new_owner)->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.
  375. +           if (GetWaterClass(tile) == WATER_CLASS_CANAL) Company::Get(new_owner)->infrastructure.water++;
  376. +       }
  377.         /* Only subtract from the old owner here if the new owner is valid,
  378.          * otherwise we clear ship depots and canal water below. */
  379.         if (GetWaterClass(tile) == WATER_CLASS_CANAL && !is_lock_middle) {
  380. @@ -1313,6 +1347,7 @@
  381.  {
  382.     /* Canals can't be terraformed */
  383.     if (IsWaterTile(tile) && IsCanal(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_CANAL_FIRST);
  384. +   if (IsWaterTile(tile) && IsRiver(tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
  385.  
  386.     return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
  387.  }

Comments