You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR removes the "-RunAhead" command line so that a couple of global network variables can be marked static conststatic constexpr const for safety and performance. Considering that the "RunAhead" command is for development only and likely rarely used, I think it's ok to get rid of it.
The current setup with extern in the header and definition in the source file causes the compiler to miss out on optimizations. It's possible that link time optimization would fix this, but that's not currently used.
This PR converts five network timing globals (MIN_LOGIC_FRAMES, MAX_FRAMES_AHEAD, MIN_RUNAHEAD, FRAME_DATA_LENGTH, FRAMES_TO_KEEP) from extern linkage into static constexpr const definitions in the shared header, and removes the -RunAhead developer command line that was the only runtime mutation point for GeneralsMD.
NetworkDefs.h: The five variables are now compile-time constants, enabling inlining and constant-folding optimizations.
NetworkUtil.cpp: The corresponding global definitions are deleted.
GeneralsMD/CommandLine.cpp: parseRunAhead and the -RunAhead entry are removed cleanly — but the equivalent Generals/Code/GameEngine/Source/Common/CommandLine.cpp is not updated, so it still tries to assign to these now-const symbols and will fail to compile.
Confidence Score: 2/5
Not safe to merge as-is — the shared header change breaks compilation of the Generals code path.
The shared NetworkDefs.h now declares all five network timing constants as static constexpr const, but Generals/Code/GameEngine/Source/Common/CommandLine.cpp still includes that header and directly assigns to those constants inside parseRunAhead. This is a definite compilation failure for the Generals build. The TODO in the PR description acknowledges the gap, but the header change is already present, so the Generals code is broken by this PR in its current state.
Generals/Code/GameEngine/Source/Common/CommandLine.cpp — the parseRunAhead function and -RunAhead command-line entry must be removed (mirroring what was done in GeneralsMD) before this PR can be merged.
Important Files Changed
Filename
Overview
Core/GameEngine/Include/GameNetwork/NetworkDefs.h
Converts five network timing globals from extern declarations to static constexpr const inline definitions; moves the @tweak comment here from NetworkUtil.cpp
Removes parseRunAhead function and -RunAhead command-line entry from GeneralsMD correctly, but the equivalent Generals/ file is not updated in this PR, causing a compile error there
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
subgraph Before
A["NetworkUtil.cpp\nglobal Int MIN_RUNAHEAD = 4\nglobal Int MAX_FRAMES_AHEAD = 128\n..."]
B["NetworkDefs.h\nextern Int MIN_RUNAHEAD\nextern Int MAX_FRAMES_AHEAD\n..."]
C["CommandLine.cpp (GeneralsMD)\nparseRunAhead:\n MIN_RUNAHEAD = atoi(args[1])\n MAX_FRAMES_AHEAD = atoi(args[2])"]
D["CommandLine.cpp (Generals)\nparseRunAhead:\n MIN_RUNAHEAD = atoi(args[1])\n MAX_FRAMES_AHEAD = atoi(args[2])"]
A --> B
B --> C
B --> D
end
subgraph After
E["NetworkDefs.h\nstatic constexpr const Int MIN_RUNAHEAD = 4\nstatic constexpr const Int MAX_FRAMES_AHEAD = 128\n..."]
F["CommandLine.cpp (GeneralsMD)\n-RunAhead REMOVED ✅"]
G["CommandLine.cpp (Generals)\nparseRunAhead still assigns\nto const variables ❌ COMPILE ERROR"]
E --> F
E --> G
end
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
MinorSeverity: Minor < Major < Critical < BlockerNetworkAnything related to network, serversPerformanceIs a performance concern
2 participants
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.
This PR removes the "-RunAhead" command line so that a couple of global network variables can be marked
static conststatic constexpr constfor safety and performance. Considering that the "RunAhead" command is for development only and likely rarely used, I think it's ok to get rid of it.The current setup with
externin the header and definition in the source file causes the compiler to miss out on optimizations. It's possible that link time optimization would fix this, but that's not currently used.TODO: