diff --git a/Generals/Code/GameEngine/Source/GameNetwork/Connection.cpp b/Generals/Code/GameEngine/Source/GameNetwork/Connection.cpp index b699d081d4..12c450410b 100644 --- a/Generals/Code/GameEngine/Source/GameNetwork/Connection.cpp +++ b/Generals/Code/GameEngine/Source/GameNetwork/Connection.cpp @@ -217,18 +217,19 @@ void Connection::clearCommandsExceptFrom( Int playerIndex ) NetCommandRef *tmp = m_netCommandList->getFirstMessage(); while (tmp) { + NetCommandRef *next = tmp->getNext(); NetCommandMsg *msg = tmp->getCommand(); + if (msg->getPlayerID() != playerIndex) { - DEBUG_LOG(("Connection::clearCommandsExceptFrom(%d) - clearing a command from %d for frame %d", + DEBUG_LOG(("Connection::clearCommandsExceptFrom(%d) - clearing a command from player %d for frame %d", playerIndex, tmp->getCommand()->getPlayerID(), tmp->getCommand()->getExecutionFrame())); + m_netCommandList->removeMessage(tmp); - NetCommandRef *toDelete = tmp; - tmp = tmp->getNext(); - deleteInstance(toDelete); - } else { - tmp = tmp->getNext(); + deleteInstance(tmp); } + + tmp = next; } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Connection.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/Connection.cpp index d0b5e377a6..e72ee57963 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Connection.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/Connection.cpp @@ -217,18 +217,19 @@ void Connection::clearCommandsExceptFrom( Int playerIndex ) NetCommandRef *tmp = m_netCommandList->getFirstMessage(); while (tmp) { + NetCommandRef *next = tmp->getNext(); NetCommandMsg *msg = tmp->getCommand(); + if (msg->getPlayerID() != playerIndex) { - DEBUG_LOG(("Connection::clearCommandsExceptFrom(%d) - clearing a command from %d for frame %d", + DEBUG_LOG(("Connection::clearCommandsExceptFrom(%d) - clearing a command from player %d for frame %d", playerIndex, tmp->getCommand()->getPlayerID(), tmp->getCommand()->getExecutionFrame())); + m_netCommandList->removeMessage(tmp); - NetCommandRef *toDelete = tmp; - tmp = tmp->getNext(); - deleteInstance(toDelete); - } else { - tmp = tmp->getNext(); + deleteInstance(tmp); } + + tmp = next; } }