changeset 14457:5d72b506e97b draft

(svn r19016) -Fix [FS#3591]: When removing roads, the player was also charged for removing the foundations.
author terkhen <terkhen@openttd.org>
date Fri, 05 Feb 2010 14:11:25 +0000
parents 709103543899
children d809c6815bf5
files src/road_cmd.cpp
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -312,9 +312,11 @@
 				}
 			}
 
-			/* If we change the foundation we have to pay for it. */
-			return CommandCost(EXPENSES_CONSTRUCTION, CountBits(pieces) * _price[PR_CLEAR_ROAD] +
-					((GetRoadFoundation(tileh, present) != f) ? _price[PR_BUILD_FOUNDATION] : (Money)0));
+			CommandCost cost(EXPENSES_CONSTRUCTION, CountBits(pieces) * _price[PR_CLEAR_ROAD]);
+			/* If we build a foundation we have to pay for it. */
+			if (f == FOUNDATION_NONE && GetRoadFoundation(tileh, present) != FOUNDATION_NONE) cost.AddCost(_price[PR_BUILD_FOUNDATION]);
+
+			return cost;
 		}
 
 		case ROAD_TILE_CROSSING: {
@@ -420,7 +422,7 @@
 				return CommandCost();
 			}
 		} else {
-			if (CountBits(existing) == 1) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
+			if (CountBits(existing) == 1 && GetRoadFoundation(tileh, existing) == FOUNDATION_NONE) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
 			return CommandCost();
 		}
 	}