Skip to content

[Enchancement] Cvar restoration system. #725

Open
@Crimewavez

Description

@Crimewavez

This issue is a continuation of conversation from discord.


Problem:

Currently when modders change player cvars, players have to hope that good programming practices were implemented(change reversal) and that they won't crash or disconnect before the change reversal occurs. This is particularly bothersome because:

  • We shouldn't rely on someones common sense at all and hope that modders will write code responsibly.
  • Even if cvar restoration is implemented in script, if client crashes unexpectedly, then server has no time to restore cvars. Leaving player with possibly annoying changes to his config.
  • Most player's are not experienced with cvars and whatnot, they may not realize that sudden change in gameplay and feel of game may be result of bad programming or bad luck.

Possible solution:

Implement a client-side cvar restoration system that will track the changes made by server, then attempt to rollback automatically on disconnection or next client startup. It could work as follows:

  • Client connect to the server, nothing happens yet.
    • When server sends command to change user's cvar and value is different from original, save original cvar to temp file.
    • Change the original cvar in player's cfg with value provided by server.
  • Client disconnects from the server.
    • Attempt to restore cvars from temp file and delete it.
  • Client crashes.
    • Attempt to restore cvars on the next client launch.
  • Other considerations
    • If player manually changes the cvar value set by server, there is no need to store it anymore, we can safely assume that if player touches console at all, he knows what he's doing and we can delete the cvar from temp file.
    • If server sets the cvar again, we have to throw it into temp file again.
    • CFG files support comments, maybe in case cvar restore fails, a section could be added to the bottom of cfg, like:
//These cvars were changed by server during last session.
cg_CrimeavezBestDev = "1"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions