Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Core/GameEngine/Include/GameNetwork/NetCommandMsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class NetGameCommandMsg : public NetCommandMsgT<NetPacketGameCommand, SmallNetPa
GameMessage *constructGameMessage() const;
void addArgument(const GameMessageArgumentDataType type, GameMessageArgumentType arg);
void setGameMessageType(GameMessage::Type type);
GameMessage::Type getGameMessageType() const;

virtual Select getSmallNetPacketSelect() const override;

Expand Down
4 changes: 4 additions & 0 deletions Core/GameEngine/Source/GameNetwork/NetCommandMsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ void NetGameCommandMsg::setGameMessageType(GameMessage::Type type) {
m_type = type;
}

GameMessage::Type NetGameCommandMsg::getGameMessageType() const {
return m_type;
}

NetCommandMsg::Select NetGameCommandMsg::getSmallNetPacketSelect() const {
Select select;
select.useCommandType = 1;
Expand Down
29 changes: 17 additions & 12 deletions Core/GameEngine/Source/GameNetwork/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class Network : public NetworkInterface
void SendCommandsToConnectionManager(); ///< Send the new commands to the ConnectionManager
Bool AllCommandsReady(UnsignedInt frame); ///< Do we have all the commands for the given frame?
void RelayCommandsToCommandList(UnsignedInt frame); ///< Put the commands for the given frame onto TheCommandList.
Bool isTransferCommand(GameMessage *msg); ///< Is this a command that needs to be transfered to the other clients?
static Bool isMessageTypeWithinNetworkRange(GameMessage::Type type);
Bool processCommand(GameMessage *msg); ///< Whatever needs to be done as a result of this command, do it now.
void processFrameSynchronizedNetCommand(NetCommandRef *msg); ///< If there is a network command that needs to be executed at the same frame number on all clients, it happens here.
void processRunAheadCommand(NetRunAheadCommandMsg *msg); ///< Do what needs to be done when we get a new run ahead command.
Expand Down Expand Up @@ -446,14 +446,8 @@ void Network::attachTransport(Transport *transport) {
}
}

/**
* Does this command need to be transfered to the other game clients?
*/
Bool Network::isTransferCommand(GameMessage *msg) {
if ((msg != nullptr) && ((msg->getType() > 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;
}

/**
Expand All @@ -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());
}
Expand Down Expand Up @@ -586,8 +580,19 @@ 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());
NetGameCommandMsg* gmsg = static_cast<NetGameCommandMsg*>(msg->getCommand());
#if RETAIL_COMPATIBLE_CRC
TheCommandList->appendMessage(gmsg->constructGameMessage());
#else
// 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->constructGameMessage());
} else {
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
Comment thread
stephanmeesters marked this conversation as resolved.
} else {
processFrameSynchronizedNetCommand(msg);
}
Expand Down
Loading