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

#include <PluginContext.hpp>

Inheritance diagram for VoltMod::PluginContext:

Public Member Functions

 PluginContext (SharedState &state, std::string name, std::string logTag, std::string version, uint64_t order)
 PluginContext (const PluginContext &)=delete
PluginContext & operator= (const PluginContext &)=delete
void SetMinLogLevel (LogLevel level)
LeakReport RemoveAll ()
std::string_view Name () const override
std::string_view Version () const override
void * EngineInterface (const char *version) const override
void * ServerInterface (const char *version) const override
std::string_view BaseDir () const override
KHook::IKHook * HookDispatcher () const override
IPluginEvents & Events () override
IPluginServices & Services () override
IPluginLanguages & Languages () override
IPluginAddons & Addons () override
IPluginGameData * GameData () const override
bool RegisterCommand (std::string_view name) override
bool IsCommandRegistered (std::string_view name) const override
void WriteLog (uint8_t level, std::string_view text) override
uint8_t MinLogLevel () const override
Schema::LiveField FindSchemaField (std::string_view className, std::string_view field) const override
uint64_t OnFrame (FrameFn callback, void *context) override
uint64_t OnServerStartup (ServerStartupFn callback, void *context) override
uint64_t OnClientConnecting (ClientConnectingFn callback, void *context) override
uint64_t OnClientConnected (ClientConnectedFn callback, void *context) override
uint64_t OnClientDisconnected (ClientDisconnectedFn callback, void *context) override
uint64_t OnClientFullyConnected (ClientFullyConnectedFn callback, void *context) override
uint64_t OnClientSettingsChanged (ClientSettingsChangedFn callback, void *context) override
uint64_t OnConsoleCommand (ConsoleCommandFn callback, void *context) override
uint64_t OnCheckTransmit (CheckTransmitFn callback, void *context) override
uint64_t OnBuildGameSessionManifest (BuildGameSessionManifestFn callback, void *context) override
uint64_t OnPlayerCommand (PlayerCommandFn callback, void *context) override
uint64_t OnPlayerCommandDone (PlayerCommandFn callback, void *context) override
uint64_t OnButtonPress (ButtonPressFn callback, void *context) override
void Publish (std::string_view name, void *implementation) override
void Unpublish (std::string_view name) override
void * Find (std::string_view name) override
bool Add (uint64_t addonId) override
void Remove (uint64_t addonId) override
bool IsReady (int slot) override
void ReplayMissedEvents ()
void DisconnectClients ()
void Unsubscribe (uint64_t token) override

Additional Inherited Members

Public Types inherited from VoltMod::IPluginEvents
using FrameFn = void (*)(void* context)
using ServerStartupFn = void (*)(void* context, std::string_view mapName)
using ClientConnectingFn
using ClientConnectedFn
using ClientDisconnectedFn = void (*)(void* context, int slot)
using ClientFullyConnectedFn = void (*)(void* context, int slot)
using ClientSettingsChangedFn = void (*)(void* context, int slot)
using ConsoleCommandFn = bool (*)(void* context, std::string_view name, std::string_view arguments, int slot)
using CheckTransmitFn = void (*)(void* context, CCheckTransmitInfo** infoList, int infoCount)
using BuildGameSessionManifestFn = void (*)(void* context, IEntityResourceManifest* manifest)
using PlayerCommandFn = void (*)(void* context, int slot, const PlayerInput& input)
using ButtonPressFn = void (*)(void* context, int slot, std::string_view buttonId)
Protected Member Functions inherited from VoltMod::IPluginContext
 ~IPluginContext ()=default
Protected Member Functions inherited from VoltMod::IPluginEvents
 ~IPluginEvents ()=default
Protected Member Functions inherited from VoltMod::IPluginServices
 ~IPluginServices ()=default
Protected Member Functions inherited from VoltMod::IPluginAddons
 ~IPluginAddons ()=default

Detailed Description

One plugin's view of the host and the record of what it took, so every call has a known owner. Owned by PluginRegistry; valid from AddPlugin until RemovePlugin.

Definition at line 82 of file PluginContext.hpp.

Constructor & Destructor Documentation

◆ PluginContext() [1/2]

VoltMod::PluginContext::PluginContext ( SharedState & state,
std::string name,
std::string logTag,
std::string version,
uint64_t order )

Definition at line 10 of file PluginContext.cpp.

Referenced by operator=(), and PluginContext().

◆ PluginContext() [2/2]

VoltMod::PluginContext::PluginContext ( const PluginContext & )
delete

References PluginContext().

Member Function Documentation

◆ Add()

bool VoltMod::PluginContext::Add ( uint64_t addonId)
overridevirtual

Require addonId until a matching Remove; false when nothing was added, as for id 0 or a listen server.

Implements VoltMod::IPluginAddons.

Definition at line 87 of file PluginContext.cpp.

◆ Addons()

IPluginAddons & VoltMod::PluginContext::Addons ( )
overridevirtual

Implements VoltMod::IPluginContext.

Definition at line 82 of file PluginContext.cpp.

◆ BaseDir()

std::string_view VoltMod::PluginContext::BaseDir ( ) const
overridevirtual

The absolute csgo directory that relative paths resolve against.

Implements VoltMod::IPluginContext.

Definition at line 35 of file PluginContext.cpp.

◆ DisconnectClients()

void VoltMod::PluginContext::DisconnectClients ( )

Raise OnClientDisconnected on this plugin alone for each player still in, before a mid-map unload.

Definition at line 257 of file PluginContext.cpp.

References VoltMod::MaxPlayers.

◆ EngineInterface()

void * VoltMod::PluginContext::EngineInterface ( const char * version) const
overridevirtual

An engine interface by its exact version name, or null.

Implements VoltMod::IPluginContext.

Definition at line 25 of file PluginContext.cpp.

◆ Events()

IPluginEvents & VoltMod::PluginContext::Events ( )
overridevirtual

Implements VoltMod::IPluginContext.

Definition at line 45 of file PluginContext.cpp.

◆ Find()

void * VoltMod::PluginContext::Find ( std::string_view name)
overridevirtual

Implements VoltMod::IPluginServices.

Definition at line 223 of file PluginContext.cpp.

◆ FindSchemaField()

Schema::LiveField VoltMod::PluginContext::FindSchemaField ( std::string_view className,
std::string_view field ) const
overridevirtual

Where the running server lays out field of className; Offset -1 when it is gone.

Implements VoltMod::IPluginContext.

Definition at line 129 of file PluginContext.cpp.

◆ GameData()

IPluginGameData * VoltMod::PluginContext::GameData ( ) const
overridevirtual

Null when the host resolved no gamedata.

Implements VoltMod::IPluginContext.

Definition at line 55 of file PluginContext.cpp.

◆ HookDispatcher()

KHook::IKHook * VoltMod::PluginContext::HookDispatcher ( ) const
overridevirtual

Each module has its own KHook::__exported__khook; a plugin seeds it from this before hooking.

Implements VoltMod::IPluginContext.

Definition at line 40 of file PluginContext.cpp.

◆ IsCommandRegistered()

bool VoltMod::PluginContext::IsCommandRegistered ( std::string_view name) const
overridevirtual

True while any plugin, this one included, or the host holds name.

Implements VoltMod::IPluginContext.

Definition at line 72 of file PluginContext.cpp.

◆ IsReady()

bool VoltMod::PluginContext::IsReady ( int slot)
overridevirtual

Whether slot has every required addon.

Implements VoltMod::IPluginAddons.

Definition at line 107 of file PluginContext.cpp.

◆ Languages()

IPluginLanguages & VoltMod::PluginContext::Languages ( )
overridevirtual

Implements VoltMod::IPluginContext.

Definition at line 77 of file PluginContext.cpp.

◆ MinLogLevel()

uint8_t VoltMod::PluginContext::MinLogLevel ( ) const
overridevirtual

Lines below this are dropped; volt log <name> <level> changes it.

Implements VoltMod::IPluginContext.

Definition at line 124 of file PluginContext.cpp.

◆ Name()

std::string_view VoltMod::PluginContext::Name ( ) const
overridevirtual

The plugin's name: its manifest name and directory under addons/voltmod/plugins/.

Implements VoltMod::IPluginContext.

Definition at line 15 of file PluginContext.cpp.

◆ OnBuildGameSessionManifest()

uint64_t VoltMod::PluginContext::OnBuildGameSessionManifest ( BuildGameSessionManifestFn callback,
void * context )
overridevirtual

Implements VoltMod::IPluginEvents.

Definition at line 193 of file PluginContext.cpp.

◆ OnButtonPress()

uint64_t VoltMod::PluginContext::OnButtonPress ( ButtonPressFn callback,
void * context )
overridevirtual

Implements VoltMod::IPluginEvents.

Definition at line 208 of file PluginContext.cpp.

◆ OnCheckTransmit()

uint64_t VoltMod::PluginContext::OnCheckTransmit ( CheckTransmitFn callback,
void * context )
overridevirtual

Implements VoltMod::IPluginEvents.

Definition at line 188 of file PluginContext.cpp.

◆ OnClientConnected()

uint64_t VoltMod::PluginContext::OnClientConnected ( ClientConnectedFn callback,
void * context )
overridevirtual

Implements VoltMod::IPluginEvents.

Definition at line 163 of file PluginContext.cpp.

◆ OnClientConnecting()

uint64_t VoltMod::PluginContext::OnClientConnecting ( ClientConnectingFn callback,
void * context )
overridevirtual

Before the engine admits a player, and before OnClientConnected.

Implements VoltMod::IPluginEvents.

Definition at line 158 of file PluginContext.cpp.

◆ OnClientDisconnected()

uint64_t VoltMod::PluginContext::OnClientDisconnected ( ClientDisconnectedFn callback,
void * context )
overridevirtual

Implements VoltMod::IPluginEvents.

Definition at line 168 of file PluginContext.cpp.

◆ OnClientFullyConnected()

uint64_t VoltMod::PluginContext::OnClientFullyConnected ( ClientFullyConnectedFn callback,
void * context )
overridevirtual

Implements VoltMod::IPluginEvents.

Definition at line 173 of file PluginContext.cpp.

◆ OnClientSettingsChanged()

uint64_t VoltMod::PluginContext::OnClientSettingsChanged ( ClientSettingsChangedFn callback,
void * context )
overridevirtual

Implements VoltMod::IPluginEvents.

Definition at line 178 of file PluginContext.cpp.

◆ OnConsoleCommand()

uint64_t VoltMod::PluginContext::OnConsoleCommand ( ConsoleCommandFn callback,
void * context )
overridevirtual

Implements VoltMod::IPluginEvents.

Definition at line 183 of file PluginContext.cpp.

◆ OnFrame()

uint64_t VoltMod::PluginContext::OnFrame ( FrameFn callback,
void * context )
overridevirtual

Implements VoltMod::IPluginEvents.

Definition at line 148 of file PluginContext.cpp.

◆ OnPlayerCommand()

uint64_t VoltMod::PluginContext::OnPlayerCommand ( PlayerCommandFn callback,
void * context )
overridevirtual

Before the engine runs a player's command. Commands are decoded only while one is subscribed.

Implements VoltMod::IPluginEvents.

Definition at line 198 of file PluginContext.cpp.

◆ OnPlayerCommandDone()

uint64_t VoltMod::PluginContext::OnPlayerCommandDone ( PlayerCommandFn callback,
void * context )
overridevirtual

After the engine ran it.

Implements VoltMod::IPluginEvents.

Definition at line 203 of file PluginContext.cpp.

◆ OnServerStartup()

uint64_t VoltMod::PluginContext::OnServerStartup ( ServerStartupFn callback,
void * context )
overridevirtual

Implements VoltMod::IPluginEvents.

Definition at line 153 of file PluginContext.cpp.

◆ operator=()

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

References PluginContext().

◆ Publish()

void VoltMod::PluginContext::Publish ( std::string_view name,
void * implementation )
overridevirtual

Implements VoltMod::IPluginServices.

Definition at line 213 of file PluginContext.cpp.

◆ RegisterCommand()

bool VoltMod::PluginContext::RegisterCommand ( std::string_view name)
overridevirtual

False when another plugin holds name, which the host logs naming both. Released with the plugin.

Implements VoltMod::IPluginContext.

Definition at line 60 of file PluginContext.cpp.

References VoltMod::Log::Error().

◆ Remove()

void VoltMod::PluginContext::Remove ( uint64_t addonId)
overridevirtual

Implements VoltMod::IPluginAddons.

Definition at line 97 of file PluginContext.cpp.

◆ RemoveAll()

LeakReport VoltMod::PluginContext::RemoveAll ( )

Remove what the plugin still holds. Command names are the host's to remove, so they are not reported.

Definition at line 281 of file PluginContext.cpp.

References VoltMod::LeakReport::Addons, VoltMod::LeakReport::Services, and VoltMod::LeakReport::Subscriptions.

◆ ReplayMissedEvents()

void VoltMod::PluginContext::ReplayMissedEvents ( )

Raise on this plugin alone what it missed by loading mid-map: OnServerStartup for the running map, then OnClientConnected and OnClientFullyConnected for each player already in.

Definition at line 228 of file PluginContext.cpp.

References VoltMod::ConnectedClient::Address, VoltMod::MaxPlayers, VoltMod::ConnectedClient::Name, and VoltMod::ConnectedClient::SteamId.

◆ ServerInterface()

void * VoltMod::PluginContext::ServerInterface ( const char * version) const
overridevirtual

A game server interface by its exact version name, or null.

Implements VoltMod::IPluginContext.

Definition at line 30 of file PluginContext.cpp.

◆ Services()

IPluginServices & VoltMod::PluginContext::Services ( )
overridevirtual

Implements VoltMod::IPluginContext.

Definition at line 50 of file PluginContext.cpp.

◆ SetMinLogLevel()

void VoltMod::PluginContext::SetMinLogLevel ( LogLevel level)
inline

Definition at line 90 of file PluginContext.hpp.

◆ Unpublish()

void VoltMod::PluginContext::Unpublish ( std::string_view name)
overridevirtual

Implements VoltMod::IPluginServices.

Definition at line 218 of file PluginContext.cpp.

◆ Unsubscribe()

void VoltMod::PluginContext::Unsubscribe ( uint64_t token)
overridevirtual

A token this plugin never took is ignored.

Implements VoltMod::IPluginEvents.

Definition at line 269 of file PluginContext.cpp.

◆ Version()

std::string_view VoltMod::PluginContext::Version ( ) const
overridevirtual

Implements VoltMod::IPluginContext.

Definition at line 20 of file PluginContext.cpp.

◆ WriteLog()

void VoltMod::PluginContext::WriteLog ( uint8_t level,
std::string_view text )
overridevirtual

Print one line under this plugin's logTag. level is a LogLevel.

Implements VoltMod::IPluginContext.

Definition at line 112 of file PluginContext.cpp.

References VoltMod::Log::Emit().


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