(svn r10833) -Fix [FS#1115]: assertion (different cost between test and execution) of overbuilding road tunnels with tram tracks (and vice versa) when the dragged area contains both ends of the tunnel.
authorrubidium
Thu, 09 Aug 2007 05:25:33 +0000
changeset 7428 0ce522a7072b
parent 7427 91823842ea52
child 7429 9147a1f31a4e
(svn r10833) -Fix [FS#1115]: assertion (different cost between test and execution) of overbuilding road tunnels with tram tracks (and vice versa) when the dragged area contains both ends of the tunnel.
src/road_cmd.cpp
src/video/win32_v.cpp
--- a/src/road_cmd.cpp	Wed Aug 08 21:28:03 2007 +0000
+++ b/src/road_cmd.cpp	Thu Aug 09 05:25:33 2007 +0000
@@ -588,6 +588,7 @@
 	TileIndex start_tile, tile;
 	CommandCost cost, ret;
 	bool had_bridge = false;
+	bool had_tunnel = false;
 	bool had_success = false;
 	DisallowedRoadDirections drd = DRD_NORTHBOUND;
 
@@ -633,12 +634,19 @@
 			_error_message = INVALID_STRING_ID;
 		} else {
 			had_success = true;
-			/* 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.AddCost(ret);
+			/* Only pay for the upgrade on one side of the bridges and tunnels */
+			if (IsTileType(tile, MP_TUNNELBRIDGE)) {
+				if (IsBridge(tile)) {
+					if ((!had_bridge || GetBridgeRampDirection(tile) == DIAGDIR_SE || GetBridgeRampDirection(tile) == DIAGDIR_SW)) {
+						cost.AddCost(ret);
+					}
+					had_bridge = true;
+				} else {
+					if ((!had_tunnel || GetTunnelDirection(tile) == DIAGDIR_SE || GetTunnelDirection(tile) == DIAGDIR_SW)) {
+						cost.AddCost(ret);
+					}
+					had_tunnel = true;
 				}
-				had_bridge = true;
 			} else {
 				cost.AddCost(ret);
 			}
--- a/src/video/win32_v.cpp	Wed Aug 08 21:28:03 2007 +0000
+++ b/src/video/win32_v.cpp	Thu Aug 09 05:25:33 2007 +0000
@@ -219,8 +219,9 @@
 
 	// recreate window?
 	if ((full_screen || _wnd.fullscreen) && _wnd.main_wnd) {
-		DestroyWindow(_wnd.main_wnd);
+		HWND wnd = _wnd.main_wnd;
 		_wnd.main_wnd = 0;
+		DestroyWindow(wnd);
 	}
 
 #if defined(WINCE)
@@ -519,6 +520,9 @@
 			break;
 
 		case WM_SIZE:
+			/* Resizing a destroy window is NOT good */
+			if (_wnd.main_wnd == 0) return;
+
 			if (wParam != SIZE_MINIMIZED) {
 				/* Set maximized flag when we maximize (obviously), but also when we
 				 * switched to fullscreen from a maximized state */
@@ -792,7 +796,9 @@
 {
 	DeleteObject(_wnd.gdi_palette);
 	DeleteObject(_wnd.dib_sect);
-	DestroyWindow(_wnd.main_wnd);
+	HWND wnd = _wnd.main_wnd;
+	_wnd.main_wnd = 0;
+	DestroyWindow(wnd);
 
 #if !defined(WINCE)
 	if (_wnd.fullscreen) ChangeDisplaySettings(NULL, 0);