Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com ---
I haven't been able to add a reliable test for this, mostly because WM_QUERYNEWPALETTE is rarely sent on Windows. In fact, for some reason even changing the display mode to 8bpp still didn't send it. But it was sent if the application was forced into "Run in 256 colors" (Windows XP) while having a 32bpp desktop display mode, which sounds like a compatibility shim hack to me.
dlls/ddraw/surface.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 3230410..0ffc274 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -3753,13 +3753,21 @@ static HRESULT WINAPI ddraw_surface7_Restore(IDirectDrawSurface7 *iface)
if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) { + HWND window = surface->ddraw->focuswindow ? surface->ddraw->focuswindow : surface->ddraw->dest_window; struct wined3d_swapchain *swapchain = surface->ddraw->wined3d_swapchain; struct wined3d_sub_resource_desc wined3d_desc; struct wined3d_display_mode mode; HRESULT hr;
if (surface->ddraw->device_state == DDRAW_DEVICE_STATE_LOST) - return DDERR_WRONGMODE; + { + /* Railroad Tycoon 2 tries to restore the surface from within + a WM_QUERYNEWPALETTE message and expects it to succeed. */ + if (GetForegroundWindow() != window) return DDERR_WRONGMODE; + + surface->ddraw->device_state = DDRAW_DEVICE_STATE_NOT_RESTORED; + } +
if (FAILED(hr = wined3d_swapchain_get_display_mode(swapchain, &mode, NULL))) {