Skip to content

Commit beb6f94

Browse files
authored
Merge branch 'master' into fix/client-side-entity
2 parents a468c71 + d70219c commit beb6f94

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

Client/core/Graphics/CVideoModeManager.cpp

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -671,11 +671,29 @@ bool CVideoModeManager::GetRequiredDisplayResolution(int& iOutWidth, int& iOutHe
671671
///////////////////////////////////////////////////////////////
672672
bool CVideoModeManager::GetCurrentAdapterRect(LPRECT pOutRect)
673673
{
674-
MONITORINFOEX monitorInfo;
674+
if (!pOutRect)
675+
return false;
676+
677+
// Initialize to safe defaults
678+
pOutRect->left = 0;
679+
pOutRect->top = 0;
680+
pOutRect->right = 1024;
681+
pOutRect->bottom = 768;
682+
683+
if (!m_hCurrentMonitor)
684+
return false;
685+
686+
MONITORINFOEX monitorInfo{};
675687
monitorInfo.cbSize = sizeof(MONITORINFOEX);
676-
BOOL bResult = GetMonitorInfo(m_hCurrentMonitor, &monitorInfo);
677-
*pOutRect = monitorInfo.rcMonitor;
678-
return bResult != 0;
688+
689+
BOOL bResult = GetMonitorInfoA(m_hCurrentMonitor, &monitorInfo);
690+
if (bResult)
691+
{
692+
*pOutRect = monitorInfo.rcMonitor;
693+
return true;
694+
}
695+
696+
return false;
679697
}
680698

681699
///////////////////////////////////////////////////////////////
@@ -687,9 +705,18 @@ bool CVideoModeManager::GetCurrentAdapterRect(LPRECT pOutRect)
687705
///////////////////////////////////////////////////////////////
688706
SString CVideoModeManager::GetCurrentAdapterDeviceName()
689707
{
690-
MONITORINFOEX monitorInfo;
708+
if (!m_hCurrentMonitor)
709+
return "";
710+
711+
MONITORINFOEX monitorInfo{};
691712
monitorInfo.cbSize = sizeof(MONITORINFOEX);
692-
if (GetMonitorInfo(m_hCurrentMonitor, &monitorInfo))
693-
return monitorInfo.szDevice;
713+
714+
if (GetMonitorInfoA(m_hCurrentMonitor, &monitorInfo))
715+
{
716+
// Ensure null termination for x86 safety
717+
monitorInfo.szDevice[sizeof(monitorInfo.szDevice) - 1] = '\0';
718+
return std::string(monitorInfo.szDevice);
719+
}
720+
694721
return "";
695722
}

Shared/sdk/SharedUtil.Template.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#pragma once
22

3+
#ifdef __INTELLISENSE__
4+
#pragma diag_suppress 842
5+
#endif
6+
37
#include <type_traits>
48
#include <variant>
59

0 commit comments

Comments
 (0)