(svn r13104) -Codechange: make ResetObjectToPlace safe to be called recursively via the OnPlaceObjectAbort callback and use this knowledge to simplify closing some windows.

This commit is contained in:
rubidium
2008-05-15 14:41:56 +00:00
parent 8fff6e8638
commit 5ae795953a
6 changed files with 29 additions and 82 deletions

View File

@@ -2708,12 +2708,11 @@ void SetObjectToPlaceWnd(CursorID icon, SpriteID pal, ViewportHighlightMode mode
void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num)
{
Window *w;
Window *w = NULL;
/* undo clicking on button and drag & drop */
if (_thd.place_mode != VHM_NONE || _special_mouse_mode == WSM_DRAGDROP) {
w = FindWindowById(_thd.window_class, _thd.window_number);
if (w != NULL) w->OnPlaceObjectAbort();
}
SetTileSelectSize(1, 1);
@@ -2734,10 +2733,16 @@ void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, W
if (mode == VHM_SPECIAL) // special tools, like tunnels or docks start with presizing mode
VpStartPreSizing();
if ( (int)icon < 0)
if ((int)icon < 0) {
SetAnimatedMouseCursor(_animcursors[~icon]);
else
} else {
SetMouseCursor(icon, pal);
}
/* Call the abort function only *after* the window class/number
* are reset so one doesn't get into infinite loops when someone
* resets the object to place during the abort callback. */
if (w != NULL) w->OnPlaceObjectAbort();
}
void ResetObjectToPlace()