Loading

Revision differences

Old revision #p0yhrws4tNew revision #pqijtcywx
  1Index: docs/landscape.html  
  2===================================================================  
  3--- docs/landscape.html    (revision 27198)  
  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>  
  38Index: docs/landscape_grid.html  
  39===================================================================  
  40--- docs/landscape_grid.html    (revision 27198)  
  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>  
  107Index: src/industry_cmd.cpp  
  108===================================================================  
  109--- src/industry_cmd.cpp    (revision 27198)  
  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) {  
  123Index: src/station_cmd.cpp  
  124===================================================================  
  125--- src/station_cmd.cpp    (revision 27198)  
  126+++ src/station_cmd.cpp    (working copy)  
  127@@ -2511,7 +2511,7 @@  
  128   
  129     /* Get the water class of the water tile before it is cleared.*/  
  130     WaterClass wc = GetWaterClass(tile_cur);  
  131-  
  132+    bool river = HasBit(_me[tile_cur].m6, 0);  
  133     ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);  
  134     if (ret.Failed()) return ret;  
  135   
  136@@ -2551,7 +2551,7 @@  
  137         DirtyCompanyInfrastructureWindows(st->owner);  
  138   
  139         MakeDock(tile, st->owner, st->index, direction, wc);  
  140-  
  141+        if (river) SB(_me[tile + TileOffsByDiagDir(direction)].m6, 0, 1, 1);  
  142         st->UpdateVirtCoord();  
  143         UpdateStationAcceptance(st, false);  
  144         st->RecomputeIndustriesNear();  
1Index: src/water_cmd.cpp  145Index: src/water_cmd.cpp  
2===================================================================  146===================================================================  
3--- src/water_cmd.cpp    (revision 27196)  3--- src/water_cmd.cpp    (revision 27198)
4+++ src/water_cmd.cpp    (working copy)  148+++ src/water_cmd.cpp    (working copy)  
5@@ -123,6 +123,8 @@  149@@ -123,6 +123,8 @@  
6     CommandCost cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_DEPOT_SHIP]);  150     CommandCost cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_DEPOT_SHIP]);  
  
21         MakeShipDepot(tile,  _current_company, depot->index, DEPOT_PART_NORTH, axis, wc1);  165         MakeShipDepot(tile,  _current_company, depot->index, DEPOT_PART_NORTH, axis, wc1);  
22         MakeShipDepot(tile2, _current_company, depot->index, DEPOT_PART_SOUTH, axis, wc2);  166         MakeShipDepot(tile2, _current_company, depot->index, DEPOT_PART_SOUTH, axis, wc2);  
23         MarkTileDirtyByTile(tile);  167         MarkTileDirtyByTile(tile);  
24@@ -209,13 +212,16 @@  24@@ -192,7 +195,7 @@
25   25 
26 static CommandCost RemoveShipDepot(TileIndex tile, DoCommandFlag flags)  26         wc = WATER_CLASS_CANAL;
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     }  171     }  
52@@ -264,7 +271,7 @@  52-
53   53+    bool river = HasBit(_me[tile].m6, 0);
54     /* lower tile */  54     /* Zero map array and terminate animation */
55     WaterClass wc_lower = IsWaterTile(tile - delta) ? GetWaterClass(tile - delta) : WATER_CLASS_CANAL;  55     DoClearSquare(tile);
56-  56 
57+     57@@ -199,7 +202,9 @@
58     if (!IsWaterTile(tile - delta)) {  58     /* Maybe change to water */
59         ret = DoCommand(tile - delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR);  59     switch (wc) {
60         if (ret.Failed()) return ret;  60         case WATER_CLASS_SEA:   MakeSea(tile);                break;
61@@ -277,7 +284,7 @@  61-        case WATER_CLASS_CANAL: MakeCanal(tile, o, Random()); break;
62   62+        case WATER_CLASS_CANAL: MakeCanal(tile, o, Random());
63     /* upper tile */  63+            if (river) SB(_me[tile].m6, 0, 1, 1);
64     WaterClass wc_upper = IsWaterTile(tile + delta) ? GetWaterClass(tile + delta) : WATER_CLASS_CANAL;  64+            break;
65-  65         case WATER_CLASS_RIVER: MakeRiver(tile, Random());    break;
66+     66         default: break;
67     if (!IsWaterTile(tile + delta)) {  67     }
68         ret = DoCommand(tile + delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR);  68@@ -291,7 +296,8 @@
69         if (ret.Failed()) return ret;    
70@@ -291,7 +298,8 @@    
71     if (IsBridgeAbove(tile) || IsBridgeAbove(tile - delta) || IsBridgeAbove(tile + delta)) {  189     if (IsBridgeAbove(tile) || IsBridgeAbove(tile - delta) || IsBridgeAbove(tile + delta)) {  
72         return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);  190         return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);  
73     }  191     }  
  
77     if (flags & DC_EXEC) {  195     if (flags & DC_EXEC) {  
78         /* Update company infrastructure counts. */  196         /* Update company infrastructure counts. */  
79         Company *c = Company::GetIfValid(_current_company);  197         Company *c = Company::GetIfValid(_current_company);  
80@@ -303,7 +311,8 @@  80@@ -303,7 +309,8 @@
81             c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock is three tiles.  199             c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock is three tiles.  
82             DirtyCompanyInfrastructureWindows(_current_company);  200             DirtyCompanyInfrastructureWindows(_current_company);  
83         }  201         }  
  
87         MakeLock(tile, _current_company, dir, wc_lower, wc_upper, wc_middle);  205         MakeLock(tile, _current_company, dir, wc_lower, wc_upper, wc_middle);  
88         MarkTileDirtyByTile(tile);  206         MarkTileDirtyByTile(tile);  
89         MarkTileDirtyByTile(tile - delta);  207         MarkTileDirtyByTile(tile - delta);  
90@@ -336,7 +345,8 @@  90@@ -419,6 +426,7 @@
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;  209         if (IsTileType(tile, MP_WATER) && (!IsTileOwner(tile, OWNER_WATER) || wc == WATER_CLASS_SEA)) continue;  
111   210   
112         bool water = IsWaterTile(tile);  211         bool water = IsWaterTile(tile);  
  
114         ret = DoCommand(tile, 0, 0, flags | DC_FORCE_CLEAR_TILE, CMD_LANDSCAPE_CLEAR);  213         ret = DoCommand(tile, 0, 0, flags | DC_FORCE_CLEAR_TILE, CMD_LANDSCAPE_CLEAR);  
115         if (ret.Failed()) return ret;  214         if (ret.Failed()) return ret;  
116   215   
117@@ -442,6 +455,7 @@  117@@ -442,6 +450,7 @@
118                     /* FALL THROUGH */  217                     /* FALL THROUGH */  
119   218   
120                 default:  219                 default:  
  
122                     MakeCanal(tile, _current_company, Random());  221                     MakeCanal(tile, _current_company, Random());  
123                     if (Company::IsValidID(_current_company)) {  222                     if (Company::IsValidID(_current_company)) {  
124                         Company::Get(_current_company)->infrastructure.water++;  223                         Company::Get(_current_company)->infrastructure.water++;  
125@@ -465,6 +479,7 @@  125@@ -465,6 +474,7 @@
126   225   
127 static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags)  226 static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags)  
128 {  227 {  
  
130     switch (GetWaterTileType(tile)) {  229     switch (GetWaterTileType(tile)) {  
131         case WATER_TILE_CLEAR: {  230         case WATER_TILE_CLEAR: {  
132             if (flags & DC_NO_WATER) return_cmd_error(STR_ERROR_CAN_T_BUILD_ON_WATER);  231             if (flags & DC_NO_WATER) return_cmd_error(STR_ERROR_CAN_T_BUILD_ON_WATER);  
133@@ -485,7 +500,6 @@  133@@ -492,6 +502,7 @@
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);  233                     DirtyCompanyInfrastructureWindows(owner);  
143                 }  234                 }  
144                 DoClearSquare(tile);  235                 DoClearSquare(tile);  
145+                if (river) MakeRiver(tile, Random());  236+                if (river) MakeRiver(tile, Random());  
146                 MarkCanalsAndRiversAroundDirty(tile);  237                 MarkCanalsAndRiversAroundDirty(tile);  
147             }  147             }
148-    
149             return CommandCost(EXPENSES_CONSTRUCTION, base_cost);    
150         }