changeset 18596:bb479fba0353 draft

(svn r23443) -Fix (r23413): Building of locks in SE failed.
author frosch <frosch@openttd.org>
date Wed, 07 Dec 2011 18:41:38 +0000
parents 3e5876e2b557
children 9c67bcbfe293
files src/water_cmd.cpp
diffstat 1 files changed, 10 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -284,14 +284,16 @@
 
 	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);