Changeset - r16887:fa78cf9583b3
[Not reviewed]
master
0 2 0
smatz - 13 years ago 2010-12-25 12:47:05
smatz@openttd.org
(svn r21632) -Codechange: call ResetObjectToPlace() even when current place_mode is HT_NONE
2 files changed with 10 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/viewport.cpp
Show inline comments
 
@@ -2830,36 +2830,34 @@ EventState VpHandlePlaceSizingDrag()
 
	return ES_HANDLED;
 
}
 

	
 
void SetObjectToPlaceWnd(CursorID icon, PaletteID pal, HighLightStyle mode, Window *w)
 
{
 
	SetObjectToPlace(icon, pal, mode, w->window_class, w->window_number);
 
}
 

	
 
#include "table/animcursors.h"
 

	
 
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);
 

	
 
	_thd.make_square_red = false;
 

	
 
	if (mode == HT_DRAG) { // HT_DRAG is for dragdropping trains in the depot window
 
		mode = HT_NONE;
 
		_special_mouse_mode = WSM_DRAGDROP;
 
	} else {
 
		_special_mouse_mode = WSM_NONE;
 
	}
src/window.cpp
Show inline comments
 
@@ -644,26 +644,25 @@ void Window::DeleteChildWindows(WindowCl
 
	Window *child = FindChildWindow(this, wc);
 
	while (child != NULL) {
 
		delete child;
 
		child = FindChildWindow(this, wc);
 
	}
 
}
 

	
 
/**
 
 * Remove window and all its child windows from the window stack.
 
 */
 
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();
 
	}
 

	
 
	/* Prevent Mouseover() from resetting mouse-over coordinates on a non-existing window */
 
	if (_mouseover_last_w == this) _mouseover_last_w = NULL;
 

	
 
	/* Make sure we don't try to access this window as the focused window when it doesn't exist anymore. */
 
	if (_focused_window == this) _focused_window = NULL;
 

	
 
	this->DeleteChildWindows();
 

	
0 comments (0 inline, 0 general)