(svn r10695) -Fix [FS#1079]: building single pieces of road over tramtrack or vice versa on slopes did not work as expected.
authorrubidium
Thu, 26 Jul 2007 11:19:03 +0000
changeset 7828 b78d1fab57da
parent 7827 526cc294e6e5
child 7829 88883899c9e6
(svn r10695) -Fix [FS#1079]: building single pieces of road over tramtrack or vice versa on slopes did not work as expected.
src/road_cmd.cpp
--- a/src/road_cmd.cpp	Thu Jul 26 09:53:58 2007 +0000
+++ b/src/road_cmd.cpp	Thu Jul 26 11:19:03 2007 +0000
@@ -298,10 +298,11 @@
 	RoadBits road_bits;
 
 	if (IsSteepSlope(tileh)) {
-		if (existing == 0) {
-			/* force full pieces. */
-			*pieces |= (RoadBits)((*pieces & 0xC) >> 2);
-			*pieces |= (RoadBits)((*pieces & 0x3) << 2);
+		/* force full pieces. */
+		*pieces |= (RoadBits)((*pieces & 0xC) >> 2);
+		*pieces |= (RoadBits)((*pieces & 0x3) << 2);
+
+		if (existing == 0 || existing == *pieces) {
 			if (*pieces == ROAD_X || *pieces == ROAD_Y) return _price.terraform;
 		}
 		return CMD_ERROR;
@@ -320,11 +321,12 @@
 		return CommandCost(existing != 0 ? 0 : _price.terraform);
 	}
 
+	*pieces |= (RoadBits)((*pieces & 0xC) >> 2);
+	*pieces |= (RoadBits)((*pieces & 0x3) << 2);
+
 	/* partly leveled up tile, only if there's no road on that tile */
-	if (existing == 0 && (tileh == SLOPE_W || tileh == SLOPE_S || tileh == SLOPE_E || tileh == SLOPE_N)) {
+	if ((existing == 0 || existing == *pieces) && (tileh == SLOPE_W || tileh == SLOPE_S || tileh == SLOPE_E || tileh == SLOPE_N)) {
 		/* force full pieces. */
-		*pieces |= (RoadBits)((*pieces & 0xC) >> 2);
-		*pieces |= (RoadBits)((*pieces & 0x3) << 2);
 		if (*pieces == ROAD_X || *pieces == ROAD_Y) return _price.terraform;
 	}
 	return CMD_ERROR;