VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
ConVarOverrides.cpp
Go to the documentation of this file.
3#include <algorithm>
4#include <string>
5
6namespace VoltMod
7{
8
9void ConVarOverrides::Restore(std::string_view name)
10{
11 const auto it = std::ranges::find(_saved, name, &Snapshot::Name);
12 if (it == _saved.end())
13 {
14 return;
15 }
16
17 Write(it->Name, it->Value);
18 _saved.erase(it);
19}
20
22{
23 for (const auto& entry : _saved)
24 {
25 Write(entry.Name, entry.Value);
26 }
27 _saved.clear();
28}
29
30void ConVarOverrides::Write(std::string_view name, std::string_view value)
31{
32 // A snapshot restores whatever the value was, spaces and semicolons included; SetByConsole
33 // owns the quoting. Restoration is best effort during engine shutdown.
34 _conVars.SetByConsole(name, value);
35}
36
37} // namespace VoltMod
void Restore(const ConVar< T > &cvar)
void SetByConsole(std::string_view name, std::string_view value)
Assign a convar over the console, quoting the value.
Definition ConVars.cpp:112
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56