Skip to content

Commit cfbe8a1

Browse files
committed
bugfix: All external network commands are now correctly cleared when leaving a game
1 parent 04b968f commit cfbe8a1

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,18 +217,19 @@ void Connection::clearCommandsExceptFrom( Int playerIndex )
217217
NetCommandRef *tmp = m_netCommandList->getFirstMessage();
218218
while (tmp)
219219
{
220+
NetCommandRef *next = tmp->getNext();
220221
NetCommandMsg *msg = tmp->getCommand();
222+
221223
if (msg->getPlayerID() != playerIndex)
222224
{
223-
DEBUG_LOG(("Connection::clearCommandsExceptFrom(%d) - clearing a command from %d for frame %d",
225+
DEBUG_LOG(("Connection::clearCommandsExceptFrom(%d) - clearing a command from player %d for frame %d",
224226
playerIndex, tmp->getCommand()->getPlayerID(), tmp->getCommand()->getExecutionFrame()));
227+
225228
m_netCommandList->removeMessage(tmp);
226-
NetCommandRef *toDelete = tmp;
227-
tmp = tmp->getNext();
228-
deleteInstance(toDelete);
229-
} else {
230-
tmp = tmp->getNext();
229+
deleteInstance(tmp);
231230
}
231+
232+
tmp = next;
232233
}
233234
}
234235

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,18 +217,19 @@ void Connection::clearCommandsExceptFrom( Int playerIndex )
217217
NetCommandRef *tmp = m_netCommandList->getFirstMessage();
218218
while (tmp)
219219
{
220+
NetCommandRef *next = tmp->getNext();
220221
NetCommandMsg *msg = tmp->getCommand();
222+
221223
if (msg->getPlayerID() != playerIndex)
222224
{
223-
DEBUG_LOG(("Connection::clearCommandsExceptFrom(%d) - clearing a command from %d for frame %d",
225+
DEBUG_LOG(("Connection::clearCommandsExceptFrom(%d) - clearing a command from player %d for frame %d",
224226
playerIndex, tmp->getCommand()->getPlayerID(), tmp->getCommand()->getExecutionFrame()));
227+
225228
m_netCommandList->removeMessage(tmp);
226-
NetCommandRef *toDelete = tmp;
227-
tmp = tmp->getNext();
228-
deleteInstance(toDelete);
229-
} else {
230-
tmp = tmp->getNext();
229+
deleteInstance(tmp);
231230
}
231+
232+
tmp = next;
232233
}
233234
}
234235

0 commit comments

Comments
 (0)