Skip to content
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

fix(client/console): Handle replicated ConVars #1699

Closed

Conversation

4mmonium
Copy link

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 in m_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 calls SetRawValue, which happens to call GetEntryFlags, 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.

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 in `m_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 calls `SetRawValue`, which happens to call
`GetEntryFlags`, 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.
@blattersturm
Copy link
Contributor

I'd say the value-retaining behavior should not be exclusive to replicated convars, as this same concern can and will apply with e.g. +set variables, or seta variables from the fivem.cfg file.

@thorium-cfx thorium-cfx added the triage Needs a preliminary assessment to determine the urgency and required action label Nov 3, 2023
@prikolium-cfx prikolium-cfx added manual-review PRs that need manual review and work before merging. and removed manual-review PRs that need manual review and work before merging. labels Sep 6, 2024
@prikolium-cfx
Copy link
Contributor

Closing it as stale. Feel free to reopen if you have more details on the issue itself and think that's it's critical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Needs a preliminary assessment to determine the urgency and required action
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants