changeset 16897:083a488420e0 draft

(svn r21632) -Codechange: call ResetObjectToPlace() even when current place_mode is HT_NONE
author smatz <smatz@openttd.org>
date Sat, 25 Dec 2010 12:47:05 +0000
parents 87e2867ad7a3
children d577acf03bba
files src/viewport.cpp src/window.cpp
diffstat 2 files changed, 10 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -2839,18 +2839,16 @@
 
 void SetObjectToPlace(CursorID icon, PaletteID pal, HighLightStyle mode, WindowClass window_class, WindowNumber window_num)
 {
-	/* undo clicking on button and drag & drop */
-	if ((_thd.place_mode & ~HT_DIR_MASK) != HT_NONE || _special_mouse_mode == WSM_DRAGDROP) {
+	if (_thd.window_class != WC_INVALID) {
+		/* Undo clicking on button and drag & drop */
 		Window *w = FindWindowById(_thd.window_class, _thd.window_number);
-		if (w != NULL) {
-			/* Call the abort function, but set the window class to something
-			 * that will never be used to avoid infinite loops. Setting it to
-			 * the 'next' window class must not be done because recursion into
-			 * this function might in some cases reset the newly set object to
-			 * place or not properly reset the original selection. */
-			_thd.window_class = WC_INVALID;
-			w->OnPlaceObjectAbort();
-		}
+		/* Call the abort function, but set the window class to something
+		 * that will never be used to avoid infinite loops. Setting it to
+		 * the 'next' window class must not be done because recursion into
+		 * this function might in some cases reset the newly set object to
+		 * place or not properly reset the original selection. */
+		_thd.window_class = WC_INVALID;
+		if (w != NULL) w->OnPlaceObjectAbort();
 	}
 
 	SetTileSelectSize(1, 1);
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -653,8 +653,7 @@
  */
 Window::~Window()
 {
-	if ((_thd.place_mode & ~HT_DIR_MASK) != HT_NONE &&
-			_thd.window_class == this->window_class &&
+	if (_thd.window_class == this->window_class &&
 			_thd.window_number == this->window_number) {
 		ResetObjectToPlace();
 	}