From 9b81dc1c61b60737bb33f1ce13848d7ea8e139eb Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Thu, 14 May 2026 17:52:16 +0200 Subject: [PATCH 1/5] fix(gamemessage): Verify allowed network type of incoming GameMessages --- Core/GameEngine/Source/GameNetwork/Network.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Core/GameEngine/Source/GameNetwork/Network.cpp b/Core/GameEngine/Source/GameNetwork/Network.cpp index 5afa4c6d743..2012a8e0612 100644 --- a/Core/GameEngine/Source/GameNetwork/Network.cpp +++ b/Core/GameEngine/Source/GameNetwork/Network.cpp @@ -586,8 +586,15 @@ void Network::RelayCommandsToCommandList(UnsignedInt frame) { while (msg != nullptr) { NetCommandType cmdType = msg->getCommand()->getNetCommandType(); if (cmdType == NETCOMMANDTYPE_GAMECOMMAND) { - //DEBUG_LOG(("Network::RelayCommandsToCommandList - appending command %d of type %s to command list on frame %d", msg->getCommand()->getID(), ((NetGameCommandMsg *)msg->getCommand())->constructGameMessage()->getCommandAsString(), TheGameLogic->getFrame())); - TheCommandList->appendMessage(((NetGameCommandMsg *)msg->getCommand())->constructGameMessage()); + GameMessage *gmsg = ((NetGameCommandMsg *)msg->getCommand())->constructGameMessage(); + if (isTransferCommand(gmsg)) { + //DEBUG_LOG(("Network::RelayCommandsToCommandList - appending command %d of type %s to command list on frame %d", msg->getCommand()->getID(), gmsg->getCommandAsString(), TheGameLogic->getFrame())); + TheCommandList->appendMessage(gmsg); + } else { + DEBUG_LOG(("Network::RelayCommandsToCommandList - rejecting GameMessage from player %d of type %s, which is not a valid networking type.", + msg->getCommand()->getPlayerID(), gmsg->getCommandAsString())); + deleteInstance(gmsg); + } } else { processFrameSynchronizedNetCommand(msg); } From fb3688e7b122bef8491a0ec7cb26efee95c8494f Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Thu, 14 May 2026 18:09:03 +0200 Subject: [PATCH 2/5] Wrap in RETAIL_COMPATIBLE_CRC --- Core/GameEngine/Source/GameNetwork/Network.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Core/GameEngine/Source/GameNetwork/Network.cpp b/Core/GameEngine/Source/GameNetwork/Network.cpp index 2012a8e0612..0c4ab390c90 100644 --- a/Core/GameEngine/Source/GameNetwork/Network.cpp +++ b/Core/GameEngine/Source/GameNetwork/Network.cpp @@ -587,6 +587,9 @@ void Network::RelayCommandsToCommandList(UnsignedInt frame) { NetCommandType cmdType = msg->getCommand()->getNetCommandType(); if (cmdType == NETCOMMANDTYPE_GAMECOMMAND) { GameMessage *gmsg = ((NetGameCommandMsg *)msg->getCommand())->constructGameMessage(); +#if RETAIL_COMPATIBLE_CRC + TheCommandList->appendMessage(gmsg); +#else if (isTransferCommand(gmsg)) { //DEBUG_LOG(("Network::RelayCommandsToCommandList - appending command %d of type %s to command list on frame %d", msg->getCommand()->getID(), gmsg->getCommandAsString(), TheGameLogic->getFrame())); TheCommandList->appendMessage(gmsg); @@ -595,6 +598,7 @@ void Network::RelayCommandsToCommandList(UnsignedInt frame) { msg->getCommand()->getPlayerID(), gmsg->getCommandAsString())); deleteInstance(gmsg); } +#endif } else { processFrameSynchronizedNetCommand(msg); } From b957a29bf4fb4e70c5086f575390d39220b36220 Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Thu, 14 May 2026 18:30:31 +0200 Subject: [PATCH 3/5] Process review comments, add info comment --- Core/GameEngine/Source/GameNetwork/Network.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Core/GameEngine/Source/GameNetwork/Network.cpp b/Core/GameEngine/Source/GameNetwork/Network.cpp index 0c4ab390c90..d88fbb1c233 100644 --- a/Core/GameEngine/Source/GameNetwork/Network.cpp +++ b/Core/GameEngine/Source/GameNetwork/Network.cpp @@ -586,16 +586,17 @@ void Network::RelayCommandsToCommandList(UnsignedInt frame) { while (msg != nullptr) { NetCommandType cmdType = msg->getCommand()->getNetCommandType(); if (cmdType == NETCOMMANDTYPE_GAMECOMMAND) { - GameMessage *gmsg = ((NetGameCommandMsg *)msg->getCommand())->constructGameMessage(); + GameMessage* gmsg = static_cast(msg->getCommand())->constructGameMessage(); #if RETAIL_COMPATIBLE_CRC TheCommandList->appendMessage(gmsg); #else + // TheSuperHackers @fix stephanmeesters 14/05/2026 Verify allowed network type of incoming GameMessages if (isTransferCommand(gmsg)) { //DEBUG_LOG(("Network::RelayCommandsToCommandList - appending command %d of type %s to command list on frame %d", msg->getCommand()->getID(), gmsg->getCommandAsString(), TheGameLogic->getFrame())); TheCommandList->appendMessage(gmsg); } else { DEBUG_LOG(("Network::RelayCommandsToCommandList - rejecting GameMessage from player %d of type %s, which is not a valid networking type.", - msg->getCommand()->getPlayerID(), gmsg->getCommandAsString())); + gmsg->getPlayerIndex(), gmsg->getCommandAsString())); deleteInstance(gmsg); } #endif From a1e3e3ab7dd367038a43b3b69b33e61444c80dcc Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Thu, 14 May 2026 21:17:41 +0200 Subject: [PATCH 4/5] Language --- Core/GameEngine/Source/GameNetwork/Network.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/GameEngine/Source/GameNetwork/Network.cpp b/Core/GameEngine/Source/GameNetwork/Network.cpp index d88fbb1c233..fbad1d3a073 100644 --- a/Core/GameEngine/Source/GameNetwork/Network.cpp +++ b/Core/GameEngine/Source/GameNetwork/Network.cpp @@ -595,7 +595,7 @@ void Network::RelayCommandsToCommandList(UnsignedInt frame) { //DEBUG_LOG(("Network::RelayCommandsToCommandList - appending command %d of type %s to command list on frame %d", msg->getCommand()->getID(), gmsg->getCommandAsString(), TheGameLogic->getFrame())); TheCommandList->appendMessage(gmsg); } else { - DEBUG_LOG(("Network::RelayCommandsToCommandList - rejecting GameMessage from player %d of type %s, which is not a valid networking type.", + DEBUG_LOG(("Network::RelayCommandsToCommandList - rejecting GameMessage from player %d of type %s, which is not a valid network type.", gmsg->getPlayerIndex(), gmsg->getCommandAsString())); deleteInstance(gmsg); } From 8c4722ae8dbb13cf625698f1283757fdf2099211 Mon Sep 17 00:00:00 2001 From: stm <14291421+stephanmeesters@users.noreply.github.com> Date: Fri, 15 May 2026 16:39:14 +0200 Subject: [PATCH 5/5] Rework to check message type before creating GameMessage --- .../Include/GameNetwork/NetCommandMsg.h | 1 + .../Source/GameNetwork/NetCommandMsg.cpp | 4 +++ .../GameEngine/Source/GameNetwork/Network.cpp | 29 +++++++------------ 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Core/GameEngine/Include/GameNetwork/NetCommandMsg.h b/Core/GameEngine/Include/GameNetwork/NetCommandMsg.h index caf2302bc9b..f68b8362bbf 100644 --- a/Core/GameEngine/Include/GameNetwork/NetCommandMsg.h +++ b/Core/GameEngine/Include/GameNetwork/NetCommandMsg.h @@ -113,6 +113,7 @@ class NetGameCommandMsg : public NetCommandMsgTgetType() > GameMessage::MSG_BEGIN_NETWORK_MESSAGES) && (msg->getType() < GameMessage::MSG_END_NETWORK_MESSAGES))) { - return TRUE; - } - return FALSE; +Bool Network::isMessageTypeWithinNetworkRange(GameMessage::Type type) { + return type > GameMessage::MSG_BEGIN_NETWORK_MESSAGES && type < GameMessage::MSG_END_NETWORK_MESSAGES; } /** @@ -464,7 +458,7 @@ void Network::GetCommandsFromCommandList() { GameMessage *next = nullptr; while (msg != nullptr) { next = msg->next(); - if (isTransferCommand(msg)) { // Is this something we should be sending to the other players? + if (isMessageTypeWithinNetworkRange(msg->getType())) { // Is this something we should be sending to the other players? if (m_localStatus == NETLOCALSTATUS_INGAME) { m_conMgr->sendLocalGameMessage(msg, getExecutionFrame()); } @@ -586,18 +580,17 @@ void Network::RelayCommandsToCommandList(UnsignedInt frame) { while (msg != nullptr) { NetCommandType cmdType = msg->getCommand()->getNetCommandType(); if (cmdType == NETCOMMANDTYPE_GAMECOMMAND) { - GameMessage* gmsg = static_cast(msg->getCommand())->constructGameMessage(); + NetGameCommandMsg* gmsg = static_cast(msg->getCommand()); #if RETAIL_COMPATIBLE_CRC - TheCommandList->appendMessage(gmsg); + TheCommandList->appendMessage(gmsg->constructGameMessage()); #else - // TheSuperHackers @fix stephanmeesters 14/05/2026 Verify allowed network type of incoming GameMessages - if (isTransferCommand(gmsg)) { + // TheSuperHackers @fix stephanmeesters 14/05/2026 Verify accepted type of incoming game messages + if (isMessageTypeWithinNetworkRange(gmsg->getGameMessageType())) { //DEBUG_LOG(("Network::RelayCommandsToCommandList - appending command %d of type %s to command list on frame %d", msg->getCommand()->getID(), gmsg->getCommandAsString(), TheGameLogic->getFrame())); - TheCommandList->appendMessage(gmsg); + TheCommandList->appendMessage(gmsg->constructGameMessage()); } else { - DEBUG_LOG(("Network::RelayCommandsToCommandList - rejecting GameMessage from player %d of type %s, which is not a valid network type.", - gmsg->getPlayerIndex(), gmsg->getCommandAsString())); - deleteInstance(gmsg); + DEBUG_LOG(("Network::RelayCommandsToCommandList - rejecting game message from player %d of type %s, which is not a network type.", + gmsg->getPlayerID(), GameMessage::getCommandTypeAsString(gmsg->getGameMessageType()))); } #endif } else {