summaryrefslogtreecommitdiff
path: root/src/water_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-12-07 18:41:38 +0000
committerfrosch <frosch@openttd.org>2011-12-07 18:41:38 +0000
commit85ba182fde84b95351880206d21562623365e29d (patch)
treee0deb8526ba31730ea90354e83b34d834a9e20a0 /src/water_cmd.cpp
parent390bc7aea3c2d357a5fd6f577e92ad0335517513 (diff)
downloadopenttd-85ba182fde84b95351880206d21562623365e29d.tar.xz
(svn r23443) -Fix (r23413): Building of locks in SE failed.
Diffstat (limited to 'src/water_cmd.cpp')
-rw-r--r--src/water_cmd.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index b7e7b3af4..5e18908a1 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -284,14 +284,16 @@ static CommandCost DoBuildLock(TileIndex tile, DiagDirection dir, DoCommandFlag
if (flags & DC_EXEC) {
/* Update company infrastructure counts. */
- Company *c = Company::Get(_current_company);
- /* Counts for the water. */
- c->infrastructure.water++;
- if (!IsWaterTile(tile - delta)) c->infrastructure.water++;
- if (!IsWaterTile(tile + delta)) c->infrastructure.water++;
- /* Count for the lock itself. */
- c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock is three tiles.
- DirtyCompanyInfrastructureWindows(_current_company);
+ Company *c = Company::GetIfValid(_current_company);
+ if (c != NULL) {
+ /* Counts for the water. */
+ c->infrastructure.water++;
+ if (!IsWaterTile(tile - delta)) c->infrastructure.water++;
+ if (!IsWaterTile(tile + delta)) c->infrastructure.water++;
+ /* Count for the lock itself. */
+ c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock is three tiles.
+ DirtyCompanyInfrastructureWindows(_current_company);
+ }
MakeLock(tile, _current_company, dir, wc_lower, wc_upper);
MarkTileDirtyByTile(tile);