VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
VoltMod::ConVars Class Reference

#include <ConVar.hpp>

Public Member Functions

 ConVars (Interfaces &interfaces)
 
 ~ConVars ()
 
 ConVars (const ConVars &)=delete
 
ConVars & operator= (const ConVars &)=delete
 
Status Available () const
 
template<ConVarValue T>
Result< ConVar< T > > Find (std::string_view name)
 
void ExecuteServerCommand (std::string_view command)
 
Status ExecuteFile (std::string_view path)
 
void SetByConsole (std::string_view name, std::string_view value)
 Assign a convar over the console, quoting the value.
 

Public Attributes

Event< const ConVarChange & > Changed
 

Friends

template<class U >
class ConVar
 

Detailed Description

Convar lookup, console commands, client overrides, and global change events.

Definition at line 113 of file ConVar.hpp.

Constructor & Destructor Documentation

◆ ConVars() [1/2]

VoltMod::ConVars::ConVars ( Interfaces &  interfaces)
explicit

interfaces must outlive this service.

Definition at line 42 of file ConVars.cpp.

◆ ~ConVars()

VoltMod::ConVars::~ConVars ( )

Definition at line 47 of file ConVars.cpp.

◆ ConVars() [2/2]

VoltMod::ConVars::ConVars ( const ConVars &  )
delete

Member Function Documentation

◆ Available()

Status VoltMod::ConVars::Available ( ) const

NotReady when ICvar is unavailable.

Definition at line 53 of file ConVars.cpp.

References VoltMod::Interfaces::CVar, and VoltMod::Error::NotReady().

◆ ExecuteFile()

Status VoltMod::ConVars::ExecuteFile ( std::string_view  path)

Queue each line of a cfg file, skipping blanks and // comments; exec reads only csgo/cfg.

Definition at line 88 of file ConVars.cpp.

References ExecuteServerCommand(), VoltMod::ReadAllText(), VoltMod::ReadFile(), and VoltMod::Strings::Trim().

◆ ExecuteServerCommand()

void VoltMod::ConVars::ExecuteServerCommand ( std::string_view  command)

Queue a server console line. A line with an embedded newline is refused and logged.

Definition at line 62 of file ConVars.cpp.

References VoltMod::Interfaces::Engine, VoltMod::ReadFile(), and VoltMod::Log::Warn().

Referenced by VoltMod::Map::ChangeToWorkshop(), ExecuteFile(), and SetByConsole().

◆ Find()

template<ConVarValue T>
template Result< ConVar< float > > VoltMod::ConVars::Find< float > ( std::string_view  name)

Resolve by name. Returns NotFound when absent and Invalid on a type mismatch.

Definition at line 33 of file ConVar.cpp.

References VoltMod::Error::Engine(), VoltMod::Error::Invalid(), VoltMod::Error::NotFound(), and VoltMod::ReadFile().

◆ operator=()

ConVars & VoltMod::ConVars::operator= ( const ConVars &  )
delete

◆ SetByConsole()

void VoltMod::ConVars::SetByConsole ( std::string_view  name,
std::string_view  value 
)

Assign a convar over the console, quoting the value.

The one place the name value console line is built, so the quoting rule is not rediscovered per call site: a space would truncate the value and a ; would start a second command. A replicated payload sent straight to a client stays unquoted.

Definition at line 112 of file ConVars.cpp.

References ExecuteServerCommand(), and VoltMod::Strings::QuoteConsoleArg().

Friends And Related Symbol Documentation

◆ ConVar

template<class U >
friend class ConVar
friend

Definition at line 149 of file ConVar.hpp.

Member Data Documentation

◆ Changed

Event<const ConVarChange&> VoltMod::ConVars::Changed

All engine convar changes. The global callback exists only while this event has subscribers.

Definition at line 145 of file ConVar.hpp.

Referenced by GlobalConVarChangeCallback().


The documentation for this class was generated from the following files: