Loading

Revision differences

Old revision #pv8ckd8ruNew revision #pagzyrmdn
6                         if (IsLock(tile) && GetLockPart(tile) == LOCK_PART_MIDDLE) {  6                         if (IsLock(tile) && GetLockPart(tile) == LOCK_PART_MIDDLE) {  
7                             /* The middle tile specifies the owner of the lock. */  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  8                             c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // the middle tile specifies the owner of the  
9+                            if (GetWaterClass(tile) != WATER_CLASS_CANAL) {  9+                            if (GetWaterClass(tile) != WATER_CLASS_RIVER) {
10+                                c->infrastructure.water++;  10+                                c->infrastructure.water++;  
11+                            }  11+                            }  
12                             break; // do not count the middle tile as canal  12                             break; // do not count the middle tile as canal  
  
42             if (!IsWaterTile(tile + delta)) c->infrastructure.water++;  42             if (!IsWaterTile(tile + delta)) c->infrastructure.water++;  
43             /* Count for the lock itself. */  43             /* Count for the lock itself. */  
44             c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock is three tiles.  44             c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock is three tiles.  
45@@ -348,6 +353,9 @@  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 @@
46         if (GetWaterClass(tile) == WATER_CLASS_RIVER) {  64         if (GetWaterClass(tile) == WATER_CLASS_RIVER) {  
47             MakeRiver(tile, Random());  65             MakeRiver(tile, Random());  
48         } else {  66         } else {  
  
52             DoClearSquare(tile);  70             DoClearSquare(tile);  
53         }  71         }  
54         MakeWaterKeepingClass(tile + delta, GetTileOwner(tile + delta));  72         MakeWaterKeepingClass(tile + delta, GetTileOwner(tile + delta));  
55@@ -1276,8 +1284,14 @@  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;
56   86   
57     /* No need to dirty company windows here, we'll redraw the whole screen anyway. */  87     /* No need to dirty company windows here, we'll redraw the whole screen anyway. */  
58     if (is_lock_middle) Company::Get(old_owner)->infrastructure.water -= 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.  88-    if (is_lock_middle) Company::Get(old_owner)->infrastructure.water -= 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.
59+    if (GetWaterClass(tile) == WATER_CLASS_CANAL && is_lock_middle) {  89+    if (is_lock_middle) {
60+        Company::Get(old_owner)->infrastructure.water--;  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--;
61+    }  92+    }  
62     if (new_owner != INVALID_OWNER) {  93     if (new_owner != INVALID_OWNER) {  
63         if (is_lock_middle) Company::Get(new_owner)->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.  94-        if (is_lock_middle) Company::Get(new_owner)->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts.
64+        if (GetWaterClass(tile) == WATER_CLASS_CANAL && is_lock_middle) {  95+        if (is_lock_middle) {
65+            Company::Get(new_owner)->infrastructure.water++;  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++;
66+        }  98+        }  
67         /* Only subtract from the old owner here if the new owner is valid,  99         /* Only subtract from the old owner here if the new owner is valid,  
68          * otherwise we clear ship depots and canal water below. */  100          * otherwise we clear ship depots and canal water below. */