summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-05-26 20:52:23 +0000
committerrubidium <rubidium@openttd.org>2007-05-26 20:52:23 +0000
commit016e651ffdf9f0c4517db110c26b450a22133543 (patch)
treecb6abba68dfacbc194981286966af59cdcae8d78
parentc346cc430ad0396c7eaefa909f251ea9185ac627 (diff)
downloadopenttd-016e651ffdf9f0c4517db110c26b450a22133543.tar.xz
(svn r9942) -Fix [FS#804]: crash when upgrading both ends of a bridge.
-rw-r--r--src/road_cmd.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 78c7897b7..ecb395b65 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -538,6 +538,7 @@ int32 CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
{
TileIndex start_tile, tile;
int32 cost, ret;
+ bool had_bridge = false;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
@@ -573,7 +574,15 @@ int32 CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
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;