(svn r9942) -Fix [FS#804]: crash when upgrading both ends of a bridge.
authorrubidium
Sat, 26 May 2007 20:52:23 +0000
changeset 6710 fd3ade8bf17a
parent 6709 2de208267583
child 6711 8b1b0795ef19
(svn r9942) -Fix [FS#804]: crash when upgrading both ends of a bridge.
src/road_cmd.cpp
--- a/src/road_cmd.cpp	Sat May 26 20:30:55 2007 +0000
+++ b/src/road_cmd.cpp	Sat May 26 20:52:23 2007 +0000
@@ -538,6 +538,7 @@
 {
 	TileIndex start_tile, tile;
 	int32 cost, ret;
+	bool had_bridge = false;
 
 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 
@@ -573,7 +574,15 @@
 			if (_error_message != STR_1007_ALREADY_BUILT) return CMD_ERROR;
 			_error_message = INVALID_STRING_ID;
 		} else {
-			cost += ret;
+			/* Only pay for the upgrade on one side of the bridge */
+			if (IsBridgeTile(tile)) {
+				if ((!had_bridge || GetBridgeRampDirection(tile) == DIAGDIR_SE || GetBridgeRampDirection(tile) == DIAGDIR_SW)) {
+					cost += ret;
+				}
+				had_bridge = true;
+			} else {
+				cost += ret;
+			}
 		}
 
 		if (tile == end_tile) break;