diff options
author | rubidium <rubidium@openttd.org> | 2008-05-15 14:41:56 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-05-15 14:41:56 +0000 |
commit | 5ae795953afac677134e54f91a11436acb3c969d (patch) | |
tree | 43c72cfecc28dfa3d1fafc35fe5d61d59367a67c /src/viewport.cpp | |
parent | 8fff6e8638b848b129a3609ef22c0d0b611940e8 (diff) | |
download | openttd-5ae795953afac677134e54f91a11436acb3c969d.tar.xz |
(svn r13104) -Codechange: make ResetObjectToPlace safe to be called recursively via the OnPlaceObjectAbort callback and use this knowledge to simplify closing some windows.
Diffstat (limited to 'src/viewport.cpp')
-rw-r--r-- | src/viewport.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/viewport.cpp b/src/viewport.cpp index 1eb5ec63d..10369e1ec 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -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() |