|
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 = std::function< void(int slot, ClientConVarStatus status, std::string_view name, std::string_view value)> |
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 the CServerSideClient::ProcessRespondCvarValue vtable slot, the CServerSideClientBase::m_nClientSlot offset, and an RTTI or symbol lookup of the CServerSideClient vtable. These values drift with engine updates. On failure Available carries the reason.
Definition at line 49 of file ClientConVars.hpp.
| using VoltMod::ClientConVars::QueryCallback = std::function<void(int slot, ClientConVarStatus status, std::string_view name, std::string_view value)> |
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 56 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 29 of file ClientConVars.cpp.
References VoltMod::ReadFile().
|
default |
|
delete |
| Status VoltMod::ClientConVars::Available | ( | ) | const |
Why queries cannot be sent: the error the hook install returned.
Definition at line 43 of file ClientConVars.cpp.
| void VoltMod::ClientConVars::OnServerStartup | ( | ) |
Definition at line 123 of file ClientConVars.cpp.
|
delete |
Number of queries awaiting an answer on slot. Diagnostics only.
Definition at line 118 of file ClientConVars.cpp.
References VoltMod::ReadFile().
| 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 86 of file ClientConVars.cpp.
References VoltMod::IsValidSlot(), VoltMod::Time::MonotonicSeconds(), VoltMod::ReadFile(), and VoltMod::Send.
Referenced by VoltMod::Internal::ClientLanguage::ClientLanguage().