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
 
uint64_t SchemaLayoutStamp () const override
 
bool SchemaVerified () 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 = bool(*)(void *context, int slot, int64_t steamId, std::string_view name, char *reason, size_t reasonSize)
 
using ClientConnectedFn = void(*)(void *context, int slot, int64_t steamId, std::string_view name, std::string_view address)
 
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.

◆ PluginContext() [2/2]

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

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.

References VoltMod::IPluginAddons::Add(), VoltMod::SharedState::Addons, and VoltMod::ReadFile().

◆ 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.

References VoltMod::LoaderHandoff::GameDir, and VoltMod::SharedState::Start.

◆ DisconnectClients()

void VoltMod::PluginContext::DisconnectClients ( )

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

Definition at line 262 of file PluginContext.cpp.

References VoltMod::SharedState::ClientDisconnected, VoltMod::SharedState::Clients, VoltMod::CallbackList< Fn >::DispatchTo(), VoltMod::MaxPlayers, and VoltMod::ReadFile().

◆ 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.

References VoltMod::LoaderHandoff::EngineFactory, and VoltMod::SharedState::Start.

◆ 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

◆ 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.

References VoltMod::SharedState::GameData.

◆ 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.

References VoltMod::LoaderHandoff::HookDispatcher, and VoltMod::SharedState::Start.

◆ 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.

References VoltMod::SharedState::Commands, and VoltMod::CommandNames::OwnerOf().

◆ 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.

References VoltMod::SharedState::Addons, VoltMod::IPluginAddons::IsReady(), and VoltMod::ReadFile().

◆ Languages()

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

Implements VoltMod::IPluginContext.

Definition at line 77 of file PluginContext.cpp.

References VoltMod::SharedState::Languages.

◆ 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.

References VoltMod::ReadFile().

◆ 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

◆ OnButtonPress()

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

Implements VoltMod::IPluginEvents.

Definition at line 213 of file PluginContext.cpp.

References VoltMod::SharedState::ButtonPress, and VoltMod::ReadFile().

◆ OnCheckTransmit()

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

◆ OnClientConnected()

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

◆ 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 163 of file PluginContext.cpp.

References VoltMod::SharedState::ClientConnecting, and VoltMod::ReadFile().

◆ OnClientDisconnected()

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

◆ OnClientFullyConnected()

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

◆ OnClientSettingsChanged()

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

◆ OnConsoleCommand()

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

◆ OnFrame()

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

Implements VoltMod::IPluginEvents.

Definition at line 153 of file PluginContext.cpp.

References VoltMod::SharedState::Frame, and VoltMod::ReadFile().

◆ 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 203 of file PluginContext.cpp.

References VoltMod::SharedState::PlayerCommand, and VoltMod::ReadFile().

◆ OnPlayerCommandDone()

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

After the engine ran it.

Implements VoltMod::IPluginEvents.

Definition at line 208 of file PluginContext.cpp.

References VoltMod::SharedState::PlayerCommandDone, and VoltMod::ReadFile().

◆ OnServerStartup()

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

◆ operator=()

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

◆ Publish()

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

◆ 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::SharedState::Commands, VoltMod::Log::Error(), VoltMod::CommandNames::OwnerOf(), and VoltMod::CommandNames::Register().

◆ Remove()

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

◆ RemoveAll()

LeakReport VoltMod::PluginContext::RemoveAll ( )

◆ 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 233 of file PluginContext.cpp.

References VoltMod::SharedState::ClientConnected, VoltMod::SharedState::ClientFullyConnected, VoltMod::SharedState::Clients, VoltMod::SharedState::CurrentMap, VoltMod::CallbackList< Fn >::DispatchTo(), VoltMod::MaxPlayers, VoltMod::ReadFile(), and VoltMod::SharedState::ServerStartup.

◆ SchemaLayoutStamp()

uint64_t VoltMod::PluginContext::SchemaLayoutStamp ( ) const
overridevirtual

The hash of the baked schema layout the host compared with the live game.

Implements VoltMod::IPluginContext.

Definition at line 129 of file PluginContext.cpp.

References VoltMod::SharedState::SchemaLayoutStamp.

◆ SchemaVerified()

bool VoltMod::PluginContext::SchemaVerified ( ) const
overridevirtual

Implements VoltMod::IPluginContext.

Definition at line 134 of file PluginContext.cpp.

References VoltMod::SharedState::SchemaVerified.

◆ 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.

References VoltMod::LoaderHandoff::ServerFactory, and VoltMod::SharedState::Start.

◆ 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.

References VoltMod::ReadFile().

◆ Unpublish()

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

◆ Unsubscribe()

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

A token this plugin never took is ignored.

Implements VoltMod::IPluginEvents.

Definition at line 274 of file PluginContext.cpp.

References VoltMod::ReadFile().

◆ 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(), and VoltMod::ReadFile().


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