forked from electronicarts/CnC_Generals_Zero_Hour
-
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
Open
Caball009
wants to merge
3
commits into
TheSuperHackers:main
Choose a base branch
from
Caball009:fix_network_commandID_overflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+37
−7
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
|
|
@@ -201,6 +202,7 @@ class Network : public NetworkInterface | |
| Int m_frameRate; | ||
| Int m_lastExecutionFrame; ///< The highest frame number that a command could have been executed on. | ||
| Int m_lastFrameCompleted; | ||
| UnsignedInt m_lastFrameResetCommandID; ///< The last frame the network command ID was reset | ||
| Bool m_didSelfSlug; | ||
| __int64 m_perfCountFreq; ///< The frequency of the performance counter. | ||
|
|
||
|
|
@@ -273,6 +275,8 @@ Network::Network() | |
| m_conMgr = nullptr; | ||
| m_messageWindow = nullptr; | ||
|
|
||
| m_lastFrameResetCommandID = 0; | ||
|
|
||
| #if defined(RTS_DEBUG) | ||
| m_networkOn = TRUE; | ||
| #endif | ||
|
|
@@ -331,6 +335,7 @@ void Network::init() | |
| m_frameRate = 30; | ||
| m_lastExecutionFrame = m_runAhead - 1; // subtract 1 since we're starting on frame 0 | ||
| m_lastFrameCompleted = m_runAhead - 1; // subtract 1 since we're starting on frame 0 | ||
| m_lastFrameResetCommandID = 0; | ||
| m_frameDataReady = FALSE; | ||
| m_isStalling = FALSE; | ||
| m_didSelfSlug = FALSE; | ||
|
|
@@ -356,6 +361,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; | ||
|
|
@@ -697,6 +703,20 @@ 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? |
||
| if (frame >= m_lastFrameResetCommandID + MAX_FRAMES_AHEAD) { | ||
| // TheSuperHackers @bugfix Caball009 20/05/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 | ||
| // and trigger the disconnect menu. | ||
| m_lastFrameResetCommandID = frame; | ||
| ResetCommandID(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| GetCommandsFromCommandList(); // Remove commands from TheCommandList and send them to the connection manager. | ||
| if (m_conMgr != nullptr) { | ||
| if (m_localStatus == NETLOCALSTATUS_INGAME) { | ||
|
|
@@ -713,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. | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.