summaryrefslogtreecommitdiff
path: root/src/water_cmd.cpp
diff options
context:
space:
mode:
authorplanetmaker <planetmaker@openttd.org>2011-12-13 23:01:36 +0000
committerplanetmaker <planetmaker@openttd.org>2011-12-13 23:01:36 +0000
commit8c48fd1fe57e9caa33fb9ab955e139627d7d4e03 (patch)
treeac8a9847f98295d3bb08aa4832ceae039270095b /src/water_cmd.cpp
parent86c19475799bd3857414903668a5daa4c54d0569 (diff)
downloadopenttd-8c48fd1fe57e9caa33fb9ab955e139627d7d4e03.tar.xz
(svn r23512) -Change [FS#4872]: Allow to place locks also on river rapids and restore rivers, if locks are deleted
Diffstat (limited to 'src/water_cmd.cpp')
-rw-r--r--src/water_cmd.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 5e18908a1..a62ae7040 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -246,6 +246,7 @@ static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlag
if (ret.Failed()) return ret;
/* middle tile */
+ WaterClass wc_middle = IsWaterTile(tile) ? GetWaterClass(tile) : WATER_CLASS_CANAL;
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (ret.Failed()) return ret;
cost.AddCost(ret);
@@ -295,7 +296,7 @@ static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlag
DirtyCompanyInfrastructureWindows(_current_company);
}
- MakeLock(tile, _current_company, dir, wc_lower, wc_upper);
+ MakeLock(tile, _current_company, dir, wc_lower, wc_upper, wc_middle);
MarkTileDirtyByTile(tile);
MarkTileDirtyByTile(tile - delta);
MarkTileDirtyByTile(tile + delta);
@@ -336,9 +337,14 @@ static CommandCost RemoveLock(TileIndex tile, DoCommandFlag flags)
DirtyCompanyInfrastructureWindows(c->index);
}
- DoClearSquare(tile);
+ if (GetWaterClass(tile) == WATER_CLASS_RIVER) {
+ MakeRiver(tile, Random());
+ } else {
+ DoClearSquare(tile);
+ }
MakeWaterKeepingClass(tile + delta, GetTileOwner(tile + delta));
MakeWaterKeepingClass(tile - delta, GetTileOwner(tile - delta));
+ MarkCanalsAndRiversAroundDirty(tile);
MarkCanalsAndRiversAroundDirty(tile - delta);
MarkCanalsAndRiversAroundDirty(tile + delta);
}
@@ -360,9 +366,6 @@ CommandCost CmdBuildLock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile));
if (dir == INVALID_DIAGDIR) return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
- /* Disallow building of locks on river rapids */
- if (IsWaterTile(tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
-
return DoBuildLock(tile, dir, flags);
}