Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/ddraw/surface.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 8805014..c2d794b 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -3786,7 +3786,18 @@ static HRESULT WINAPI ddraw_surface7_Restore(IDirectDrawSurface7 *iface) }
if (surface->ddraw->device_state == DDRAW_DEVICE_STATE_LOST && ddraw_surface_can_be_lost(surface)) - return DDERR_WRONGMODE; + { + HWND window = surface->ddraw->focuswindow ? surface->ddraw->focuswindow : surface->ddraw->dest_window; + + /* Railroad Tycoon 2 tries to restore the surface from within + a WM_QUERYNEWPALETTE message and expects it to succeed. We + haven't received the WM_ACTIVATEAPP message by that point, + so the device state is still LOST, even though we are in + the foreground. */ + if (!window || GetForegroundWindow() != window) return DDERR_WRONGMODE; + + surface->ddraw->device_state = DDRAW_DEVICE_STATE_NOT_RESTORED; + }
ddraw_update_lost_surfaces(surface->ddraw); surface->is_lost = FALSE;