Skip to content

Commit c4b97a5

Browse files
authored
Merge branch 'master' into commandhandler-controlling
2 parents 2c921fb + 9e62309 commit c4b97a5

File tree

5 files changed

+38
-18
lines changed

5 files changed

+38
-18
lines changed

Client/core/Graphics/CVideoModeManager.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,18 @@ bool CVideoModeManager::GetCurrentAdapterRect(LPRECT pOutRect)
687687
///////////////////////////////////////////////////////////////
688688
SString CVideoModeManager::GetCurrentAdapterDeviceName()
689689
{
690-
MONITORINFOEX monitorInfo;
690+
if (!m_hCurrentMonitor)
691+
return "";
692+
693+
MONITORINFOEX monitorInfo{};
691694
monitorInfo.cbSize = sizeof(MONITORINFOEX);
692-
if (GetMonitorInfo(m_hCurrentMonitor, &monitorInfo))
693-
return monitorInfo.szDevice;
695+
696+
if (GetMonitorInfoA(m_hCurrentMonitor, &monitorInfo))
697+
{
698+
// Ensure null termination for x86 safety
699+
monitorInfo.szDevice[sizeof(monitorInfo.szDevice) - 1] = '\0';
700+
return std::string(monitorInfo.szDevice);
701+
}
702+
694703
return "";
695704
}

Client/mods/deathmatch/logic/CPacketHandler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1412,7 +1412,8 @@ void CPacketHandler::Packet_ChatEcho(NetBitStreamInterface& bitStream)
14121412
bitStream.Read(szMessage, iNumberOfBytesUsed);
14131413
szMessage[iNumberOfBytesUsed] = 0;
14141414
// actual limits enforced on the remote client, this is the maximum a string can be to be printed.
1415-
if (MbUTF8ToUTF16(szMessage).size() <=
1415+
SString textToProcess = bColorCoded ? RemoveColorCodes(szMessage) : szMessage;
1416+
if (MbUTF8ToUTF16(textToProcess).size() <=
14161417
MAX_CHATECHO_LENGTH + 6) // Extra 6 characters to fix #7125 (Teamsay + long name + long message = too long message)
14171418
{
14181419
// Strip it for bad characters

Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -260,21 +260,27 @@ bool CStaticFunctionDefinitions::ClearChatBox()
260260

261261
bool CStaticFunctionDefinitions::OutputChatBox(const char* szText, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue, bool bColorCoded)
262262
{
263-
if (strlen(szText) <= MAX_OUTPUTCHATBOX_LENGTH)
264-
{
265-
CLuaArguments Arguments;
266-
Arguments.PushString(szText);
267-
Arguments.PushNumber(ucRed);
268-
Arguments.PushNumber(ucGreen);
269-
Arguments.PushNumber(ucBlue);
263+
if (!szText || szText[0] == '\0')
264+
return false;
265+
266+
SString textToProcess = bColorCoded ? RemoveColorCodes(szText) : szText;
267+
268+
if (textToProcess.length() > MAX_OUTPUTCHATBOX_LENGTH) {
269+
return false;
270+
}
270271

271-
bool bCancelled = !g_pClientGame->GetRootEntity()->CallEvent("onClientChatMessage", Arguments, false);
272-
if (!bCancelled)
273-
{
274-
m_pCore->ChatPrintfColor("%s", bColorCoded, ucRed, ucGreen, ucBlue, szText);
275-
return true;
276-
}
272+
CLuaArguments Arguments;
273+
Arguments.PushString(szText);
274+
Arguments.PushNumber(ucRed);
275+
Arguments.PushNumber(ucGreen);
276+
Arguments.PushNumber(ucBlue);
277+
278+
bool bCancelled = !g_pClientGame->GetRootEntity()->CallEvent("onClientChatMessage", Arguments, false);
279+
if (!bCancelled) {
280+
m_pCore->ChatPrintfColor("%s", bColorCoded, ucRed, ucGreen, ucBlue, szText);
281+
return true;
277282
}
283+
278284
return false;
279285
}
280286

Shared/mods/deathmatch/logic/luadefs/CLuaUtilDefs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ int CLuaUtilDefs::Split(lua_State* luaVM)
227227
lua_pushstring(luaVM, szToken);
228228
lua_settable(luaVM, -3);
229229

230-
szToken = strtok(NULL, strDelimiter);
230+
szToken = strtok(nullptr, strDelimiter.c_str());
231231
}
232232

233233
// Delete the text

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)