Reworked client network state handling #2542
Closed
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.
Currently working with client-side prediction is a bit too limiting due to the nature of only having the info that the client is predicting and nothing else. Not only this, but handling the prediction state via
cheats
is volatile as it allows players to unset it (likely unintentionally) while predicting which will break the game state immediately.Prediction is now locked behind
ClientState
which is readonly. This will be used for getting a client's network status (both the consoleplayer and others) and currently supportsCS_PREDICTING
,CS_LATEST_TICK
, andCS_RUBBERBANDING
.CS_LATEST_TICK
is of particular interest because it can allow effects and sounds to be executed on the player's last "real" tick rather than constantly being repredicted. This allows for things like sounds on landing to be played at the last predicted tick without rapid firing when being played back.ClientTic
has also been added which can be compared againstgametic
to see how far ahead the player is currently predicting on a given tick. Note thatgametic
becomes one tick ahead when predicting since its value is incremented after all game logic but before prediction starts.These fields should mainly be used for client-side prediction as they won't give the same values across clients (similar to
consoleplayer
), but things likeCS_LATEST_TICK
andClientTic
are still set for all clients so logic can execute correctly on their end. For instance, a non-consoleplayer client will only update on a real tick, but their flag will always be set toCS_LATEST_TICK
so a landing sound would still play at the correct time if checking against it.