refactor(network): Sort command list fast path by sort number - #3052
refactor(network): Sort command list fast path by sort number#3052CryoTheRenegade wants to merge 2 commits into
Conversation
Skyaero42
left a comment
There was a problem hiding this comment.
Starting to look better, but still a few points of attention and some formatting
|
I'm a bit concerned this may affect retail compatibility. Please test this change in a multiplayer match. You can use two local instances, one with the change and one without. |
Tested with latest weekly as control, no issues seen (had 2 instances of tracy in the background and nothing weird happened, but im not very good at playing against myself so i didnt stress it out too much :/) |
4c4ac92 to
727de6a
Compare
|
The title says that this is a bug fix. What is the bug that can be observed in the game before this fix? |
|
The cached fast path could order network commands differently from the full scan. Peers can then consume commands in different orders, causing multiplayer desync. This makes both paths use the same ordering: type, player, then sort number |
|
Would you mind writing test code that forces a mismatch because of this bug? FWIW I did something similar for a similar PR here: https://www.github.com/TheSuperHackers/GeneralsGameCode/pull/2736/changes/f386e5fb030acf148f7d038c6c2a09808ab7425d |
|
Added test code (https://github.com/CryoTheRenegade/GeneralsGameCode/tree/test/netcommandlist-order-repro)
The game catches this live and runs the correct order, but we should not be relying on a fallback when we can get it right the first time |
727de6a to
4cf2901
Compare
xezon
left a comment
There was a problem hiding this comment.
Code is difficult to read and understand.
a43b0c8 to
728969a
Compare
xezon
left a comment
There was a problem hiding this comment.
This change is now a mix of refactor and fix; is that right? If yes, can we split it into 2 commits or 2 pull requests to merge to main?
728969a to
0ac54e8
Compare
|
Yes, the PR now includes the fix and some cleanup added during review. I kept one PR and split it into two commits so each part is clear. |
Ok that is good. Please add pull id to commit titles |
0ac54e8 to
bfff4b5
Compare
|
Done. |
Changed the cached
NetCommandList::addMessageinsertion path to usegetSortNumber(), matching the full list traversal.For normal commands this is equivalent to
getID(). ACK commands override it with the ID of the command being acknowledged, so using it consistently prevents incorrect ACK ordering.