-
Notifications
You must be signed in to change notification settings - Fork 204
bugfix(network): Reset network command id to keep commands in chronological order #2736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
3685b17
e60c7b5
5efd806
33f90dd
5f2134d
1bccb3a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ | |
| #include "Common/Player.h" | ||
| #include "Common/PlayerList.h" | ||
| #include "GameNetwork/NetworkInterface.h" | ||
| #include "GameNetwork/networkutil.h" | ||
| #include "GameNetwork/udp.h" | ||
| #include "GameNetwork/Transport.h" | ||
| #include "strtok_r.h" | ||
|
|
@@ -356,6 +357,7 @@ void Network::init() | |
| DEBUG_LOG(("FRAME_DATA_LENGTH = %d", FRAME_DATA_LENGTH)); | ||
| DEBUG_LOG(("FRAMES_TO_KEEP = %d", FRAMES_TO_KEEP)); | ||
|
|
||
| ResetCommandID(); | ||
|
|
||
| #if defined(RTS_DEBUG) | ||
| m_networkOn = TRUE; | ||
|
|
@@ -456,6 +458,7 @@ Bool Network::isMessageTypeWithinNetworkRange(GameMessage::Type type) { | |
| void Network::GetCommandsFromCommandList() { | ||
| GameMessage *msg = TheCommandList->getFirstMessage(); | ||
| GameMessage *next = nullptr; | ||
|
|
||
| while (msg != nullptr) { | ||
| next = msg->next(); | ||
| if (isMessageTypeWithinNetworkRange(msg->getType())) { // Is this something we should be sending to the other players? | ||
|
|
@@ -702,6 +705,18 @@ void Network::update() | |
| } | ||
| #endif | ||
|
|
||
| const UnsignedInt frame = TheGameLogic->getFrame(); | ||
|
|
||
| if (m_localStatus == NETLOCALSTATUS_INGAME) { | ||
| if (frame + m_runAhead > m_lastExecutionFrame) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not understand this condition. Can you explain it?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's extracted from |
||
| // TheSuperHackers @bugfix Caball009 06/06/2026 Reset the network command id to prevent it from overflowing. | ||
| // This prevents commands from being sorted incorrectly, which can cause spurious mismatches at low CRC intervals. | ||
| if (GetCommandID() >= 64000) { | ||
| ResetCommandID(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| GetCommandsFromCommandList(); // Remove commands from TheCommandList and send them to the connection manager. | ||
| if (m_conMgr != nullptr) { | ||
| if (m_localStatus == NETLOCALSTATUS_INGAME) { | ||
|
|
@@ -718,11 +733,11 @@ void Network::update() | |
| endOfGameCheck(); | ||
| } | ||
|
|
||
| if (AllCommandsReady(TheGameLogic->getFrame())) { // If all the commands are ready for the next frame... | ||
| if (AllCommandsReady(frame)) { // If all the commands are ready for the next frame... | ||
| m_conMgr->handleAllCommandsReady(); | ||
| // DEBUG_LOG(("Network::update - frame %d is ready", TheGameLogic->getFrame())); | ||
| // DEBUG_LOG(("Network::update - frame %d is ready", frame)); | ||
| if (timeForNewFrame()) { // This needs to come after any other pre-frame execution checks as this changes the timing variables. | ||
| RelayCommandsToCommandList(TheGameLogic->getFrame()); // Put the commands for the next frame on TheCommandList. | ||
| RelayCommandsToCommandList(frame); // Put the commands for the next frame on TheCommandList. | ||
| m_frameDataReady = TRUE; // Tell the GameEngine to run the commands for the new frame. | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.