Skip to content

Commit e15748b

Browse files
committed
fix(network): preserve original execution order for ACK and WRAPPER commands
1 parent ae99f38 commit e15748b

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

Generals/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -392,12 +392,26 @@ Bool ConnectionManager::processNetCommand(NetCommandRef *ref) {
392392
NetCommandMsg *msg = ref->getCommand();
393393
NetCommandType cmdType = msg->getNetCommandType();
394394

395+
// Handle ACK commands first (before connection validation)
396+
if ((cmdType == NETCOMMANDTYPE_ACKSTAGE1) ||
397+
(cmdType == NETCOMMANDTYPE_ACKSTAGE2) ||
398+
(cmdType == NETCOMMANDTYPE_ACKBOTH)) {
399+
processAck(msg);
400+
return FALSE;
401+
}
402+
395403
// Early validation checks
396404
if ((m_connections[msg->getPlayerID()] == NULL) && (msg->getPlayerID() != m_localSlot)) {
397405
// if this is from a player that is no longer in the game, then ignore them.
398406
return TRUE;
399407
}
400408

409+
// Handle WRAPPER commands (before second connection validation)
410+
if (cmdType == NETCOMMANDTYPE_WRAPPER) {
411+
processWrapper(ref); // need to send the NetCommandRef since we have to construct the relay for the wrapped command.
412+
return FALSE;
413+
}
414+
401415
if ((msg->getPlayerID() >= 0) && (msg->getPlayerID() < MAX_SLOTS) && (msg->getPlayerID() != m_localSlot)) {
402416
if (m_connections[msg->getPlayerID()] == NULL) {
403417
return TRUE;
@@ -424,15 +438,6 @@ Bool ConnectionManager::processNetCommand(NetCommandRef *ref) {
424438

425439
// Process command by type
426440
switch (cmdType) {
427-
case NETCOMMANDTYPE_ACKSTAGE1:
428-
case NETCOMMANDTYPE_ACKSTAGE2:
429-
case NETCOMMANDTYPE_ACKBOTH:
430-
processAck(msg);
431-
return FALSE;
432-
433-
case NETCOMMANDTYPE_WRAPPER:
434-
processWrapper(ref); // need to send the NetCommandRef since we have to construct the relay for the wrapped command.
435-
return FALSE;
436441

437442
case NETCOMMANDTYPE_FRAMEINFO: {
438443
processFrameInfo((NetFrameCommandMsg *)msg);

GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -392,12 +392,26 @@ Bool ConnectionManager::processNetCommand(NetCommandRef *ref) {
392392
NetCommandMsg *msg = ref->getCommand();
393393
NetCommandType cmdType = msg->getNetCommandType();
394394

395+
// Handle ACK commands first (before connection validation)
396+
if ((cmdType == NETCOMMANDTYPE_ACKSTAGE1) ||
397+
(cmdType == NETCOMMANDTYPE_ACKSTAGE2) ||
398+
(cmdType == NETCOMMANDTYPE_ACKBOTH)) {
399+
processAck(msg);
400+
return FALSE;
401+
}
402+
395403
// Early validation checks
396404
if ((m_connections[msg->getPlayerID()] == NULL) && (msg->getPlayerID() != m_localSlot)) {
397405
// if this is from a player that is no longer in the game, then ignore them.
398406
return TRUE;
399407
}
400408

409+
// Handle WRAPPER commands (before second connection validation)
410+
if (cmdType == NETCOMMANDTYPE_WRAPPER) {
411+
processWrapper(ref); // need to send the NetCommandRef since we have to construct the relay for the wrapped command.
412+
return FALSE;
413+
}
414+
401415
if ((msg->getPlayerID() >= 0) && (msg->getPlayerID() < MAX_SLOTS) && (msg->getPlayerID() != m_localSlot)) {
402416
if (m_connections[msg->getPlayerID()] == NULL) {
403417
return TRUE;
@@ -424,15 +438,6 @@ Bool ConnectionManager::processNetCommand(NetCommandRef *ref) {
424438

425439
// Process command by type
426440
switch (cmdType) {
427-
case NETCOMMANDTYPE_ACKSTAGE1:
428-
case NETCOMMANDTYPE_ACKSTAGE2:
429-
case NETCOMMANDTYPE_ACKBOTH:
430-
processAck(msg);
431-
return FALSE;
432-
433-
case NETCOMMANDTYPE_WRAPPER:
434-
processWrapper(ref); // need to send the NetCommandRef since we have to construct the relay for the wrapped command.
435-
return FALSE;
436441

437442
case NETCOMMANDTYPE_FRAMEINFO: {
438443
processFrameInfo((NetFrameCommandMsg *)msg);

0 commit comments

Comments
 (0)