|
VoltMod
C++23 framework for CS2 server plugins
|
Asks a connected client what one of its own convars is set to. More...
#include <ClientConVars.hpp>
Public Types | |
| using | QueryCallback |
Public Member Functions | |
| ClientConVars (Interfaces &interfaces, const Bindings &bindings, SlotEvents &slots) | |
| ~ClientConVars () | |
| ClientConVars (const ClientConVars &)=delete | |
| ClientConVars & | operator= (const ClientConVars &)=delete |
| Status | Available () const |
| bool | Query (int slot, std::string_view cvarName, QueryCallback callback) |
| size_t | PendingCount (int slot) const |
| void | OnServerStartup () |
Asks a connected client what one of its own convars is set to.
The server sends CSVCMsg_GetCvarValue with a cookie. The client answers later with CCLCMsg_RespondCvarValue, intercepted through a vtable hook on CServerSideClient. Queries are asynchronous, unordered, and may never complete.
A modified client can answer with anything, so treat the result as evidence, not proof.
This optional load step depends on an RTTI or symbol lookup of the CServerSideClient vtable. These values drift with engine updates. On failure Available carries the reason.
Definition at line 47 of file ClientConVars.hpp.
Invoked on the game thread when the client answers. name and value borrow the decoded message, so copy what you keep. value is empty unless status is Answered.
Definition at line 54 of file ClientConVars.hpp.
| VoltMod::ClientConVars::ClientConVars | ( | Interfaces & | interfaces, |
| const Bindings & | bindings, | ||
| SlotEvents & | slots ) |
interfaces and bindings drive the response hook and the query send path. slots tells the service when a slot changes hands, so an answer can never reach the callback of whoever held the slot before. All three must outlive it; the Runtime declares them above. Installs the response hook; a failure leaves the service inert and names itself in Available.
Definition at line 28 of file ClientConVars.cpp.
References VoltMod::SlotEvents::Changed.
Referenced by ClientConVars(), and operator=().
|
default |
|
delete |
References ClientConVars().
| Status VoltMod::ClientConVars::Available | ( | ) | const |
Why queries cannot be sent: the error the hook install returned.
Definition at line 42 of file ClientConVars.cpp.
| void VoltMod::ClientConVars::OnServerStartup | ( | ) |
Definition at line 118 of file ClientConVars.cpp.
|
delete |
References ClientConVars().
| size_t VoltMod::ClientConVars::PendingCount | ( | int | slot | ) | const |
Number of queries awaiting an answer on slot. Diagnostics only.
Definition at line 113 of file ClientConVars.cpp.
| bool VoltMod::ClientConVars::Query | ( | int | slot, |
| std::string_view | cvarName, | ||
| QueryCallback | callback ) |
Ask slot for its value of cvarName. False when the service is not Available, the slot holds a bot or nobody, the per-slot pending cap is reached, or the message could not be sent.
A convar already in flight for that slot re-targets the outstanding request rather than sending a second one, so polling cannot flood a client. Pending entries expire silently after 10 seconds.
Definition at line 81 of file ClientConVars.cpp.
References VoltMod::IsValidSlot(), and VoltMod::Time::MonotonicSeconds().