fix(client/console): Handle replicated ConVars #1699
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.
This is a proposal at resolving an issue with replicated ConVars coming from the server. Right now the
ConsoleVariableManager::Register
method takes whatever is fed by the client (via ConVar definitions) and doesn't check if the ConVar was already present inm_entries
prior to defining it, therefore 'eating' the value (by deleting any old entry) as well as the flags.This so called 'fix' currently finds any old entries (those that were sent by the server via msgConVars) and checks if they exist.
If they do exist and are replicated we store the old entry flag and value. We then proceed to remove the old entry (mainly so we can use
SetValue
, which callsSetRawValue
, which happens to callGetEntryFlags
, which finds the old replicated ConVar and ends up telling us we can't modify replicated variables) and transfer over the data (flags and value) to the new ConVar that is being created.I'm not sure if this is the best way to solve this, hence why I'm PR'ing it as a proposal to see if there's perhaps a better way.
Thanks.