- fixed: GetDisplayDeviceName must always pick a valid monitor.

There is no default here, so if vid_adapter is invalid for whatever reason the engine would crash without a defined setting.
This commit is contained in:
Christoph Oelckers 2019-04-19 07:33:51 +02:00
parent 68597da75d
commit 327a83a54b
1 changed files with 2 additions and 2 deletions

View File

@ -90,7 +90,7 @@ static BOOL CALLBACK GetDisplayDeviceNameMonitorEnumProc(HMONITOR hMonitor, HDC,
// This assumes the monitors are returned by EnumDisplayMonitors in the // This assumes the monitors are returned by EnumDisplayMonitors in the
// order they're found in the Direct3D9 adapters list. Fingers crossed... // order they're found in the Direct3D9 adapters list. Fingers crossed...
if (state->curIdx == vid_adapter) if (state->curIdx == vid_adapter || state->hFoundMonitor == nullptr)
{ {
state->hFoundMonitor = hMonitor; state->hFoundMonitor = hMonitor;
@ -119,7 +119,7 @@ void Win32BaseVideo::GetDisplayDeviceName()
MonitorEnumState mes; MonitorEnumState mes;
mes.curIdx = 1; mes.curIdx = 1;
mes.hFoundMonitor = 0; mes.hFoundMonitor = nullptr;
// Could also use EnumDisplayDevices, I guess. That might work. // Could also use EnumDisplayDevices, I guess. That might work.
if (EnumDisplayMonitors(0, 0, &GetDisplayDeviceNameMonitorEnumProc, LPARAM(&mes))) if (EnumDisplayMonitors(0, 0, &GetDisplayDeviceNameMonitorEnumProc, LPARAM(&mes)))