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

The loaded plugins and the engine events raised on them, one per process. More...

#include <PluginRegistry.hpp>

Public Member Functions

 PluginRegistry (LoaderHandoff start={}, IPluginGameData *gameData=nullptr, IPluginAddons *addons=nullptr)
 
 ~PluginRegistry ()
 
 PluginRegistry (const PluginRegistry &)=delete
 
PluginRegistry & operator= (const PluginRegistry &)=delete
 
PluginContext * AddPlugin (std::string_view name, std::string_view logTag={}, std::string_view version={})
 
LeakReport RemovePlugin (std::string_view name)
 
PluginContext * FindPlugin (std::string_view name)
 
bool IsConnected (int slot) const
 
IPluginGameData * GameData () const
 
void SetSchemaLayout (uint64_t stamp, bool verified)
 
void RaiseFrame ()
 
void RaiseServerStartup (std::string_view mapName)
 
std::string RaiseClientConnecting (int slot, int64_t steamId, std::string_view name)
 
void RaiseClientConnected (int slot, int64_t steamId, std::string_view name, std::string_view address)
 
void RaiseClientDisconnected (int slot)
 
void RaiseClientFullyConnected (int slot)
 
void RaiseClientSettingsChanged (int slot)
 
bool RaiseConsoleCommand (std::string_view name, std::string_view arguments, int slot)
 
void RaiseCheckTransmit (CCheckTransmitInfo **infoList, int infoCount)
 
void RaiseBuildGameSessionManifest (IEntityResourceManifest *manifest)
 
bool HasCommandListeners () const
 
void RaisePlayerCommand (int slot, const PlayerInput &input)
 
void RaisePlayerCommandDone (int slot, const PlayerInput &input)
 
void RaiseButtonPress (int slot, std::string_view buttonId)
 
void RegisterHostCommand (std::string_view name)
 

Detailed Description

The loaded plugins and the engine events raised on them, one per process.

Owns the SharedState. Game thread only; nothing locks. SDK-free so it is unit-tested without the engine.

Definition at line 21 of file PluginRegistry.hpp.

Constructor & Destructor Documentation

◆ PluginRegistry() [1/2]

VoltMod::PluginRegistry::PluginRegistry ( LoaderHandoff  start = {},
IPluginGameData *  gameData = nullptr,
IPluginAddons *  addons = nullptr 
)
explicit

Definition at line 19 of file PluginRegistry.cpp.

◆ ~PluginRegistry()

VoltMod::PluginRegistry::~PluginRegistry ( )
default

◆ PluginRegistry() [2/2]

VoltMod::PluginRegistry::PluginRegistry ( const PluginRegistry &  )
delete

Member Function Documentation

◆ AddPlugin()

PluginContext * VoltMod::PluginRegistry::AddPlugin ( std::string_view  name,
std::string_view  logTag = {},
std::string_view  version = {} 
)

Give name its own view, at the end of the dispatch order. Nullptr when it already has one. logTag prefixes every line the plugin writes; empty means its name.

Definition at line 31 of file PluginRegistry.cpp.

References FindPlugin(), and VoltMod::SharedState::NextOrder.

◆ FindPlugin()

PluginContext * VoltMod::PluginRegistry::FindPlugin ( std::string_view  name)

Definition at line 44 of file PluginRegistry.cpp.

References VoltMod::ReadFile().

Referenced by AddPlugin().

◆ GameData()

IPluginGameData * VoltMod::PluginRegistry::GameData ( ) const
inline

The one gamedata resolution every plugin binds from, null when the host has none.

Definition at line 44 of file PluginRegistry.hpp.

References VoltMod::SharedState::GameData.

◆ HasCommandListeners()

bool VoltMod::PluginRegistry::HasCommandListeners ( ) const

Whether any plugin subscribed to player commands; the host decodes none otherwise.

Definition at line 163 of file PluginRegistry.cpp.

References VoltMod::CallbackList< Fn >::Empty(), VoltMod::SharedState::PlayerCommand, and VoltMod::SharedState::PlayerCommandDone.

◆ IsConnected()

bool VoltMod::PluginRegistry::IsConnected ( int  slot) const
inline

Between ClientConnected and ClientDisconnected on slot.

Definition at line 41 of file PluginRegistry.hpp.

References VoltMod::SharedState::Clients, VoltMod::IsValidSlot(), and VoltMod::ReadFile().

Referenced by VoltMod::EngineHooks::EngineHooks().

◆ operator=()

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

◆ RaiseBuildGameSessionManifest()

void VoltMod::PluginRegistry::RaiseBuildGameSessionManifest ( IEntityResourceManifest *  manifest)

◆ RaiseButtonPress()

void VoltMod::PluginRegistry::RaiseButtonPress ( int  slot,
std::string_view  buttonId 
)

◆ RaiseCheckTransmit()

void VoltMod::PluginRegistry::RaiseCheckTransmit ( CCheckTransmitInfo **  infoList,
int  infoCount 
)

◆ RaiseClientConnected()

void VoltMod::PluginRegistry::RaiseClientConnected ( int  slot,
int64_t  steamId,
std::string_view  name,
std::string_view  address 
)

◆ RaiseClientConnecting()

std::string VoltMod::PluginRegistry::RaiseClientConnecting ( int  slot,
int64_t  steamId,
std::string_view  name 
)

Ask each plugin whether slot may join. The first refusal's reason, or empty to admit.

Definition at line 80 of file PluginRegistry.cpp.

References VoltMod::SharedState::ClientConnecting, VoltMod::CallbackList< Fn >::Dispatch(), and VoltMod::ReadFile().

◆ RaiseClientDisconnected()

◆ RaiseClientFullyConnected()

◆ RaiseClientSettingsChanged()

void VoltMod::PluginRegistry::RaiseClientSettingsChanged ( int  slot)

◆ RaiseConsoleCommand()

bool VoltMod::PluginRegistry::RaiseConsoleCommand ( std::string_view  name,
std::string_view  arguments,
int  slot 
)

True when a plugin answered it: later plugins never see it and the engine call is blocked.

Definition at line 140 of file PluginRegistry.cpp.

References VoltMod::SharedState::ConsoleCommand, VoltMod::CallbackList< Fn >::Dispatch(), and VoltMod::ReadFile().

◆ RaiseFrame()

void VoltMod::PluginRegistry::RaiseFrame ( )

◆ RaisePlayerCommand()

void VoltMod::PluginRegistry::RaisePlayerCommand ( int  slot,
const PlayerInput &  input 
)

◆ RaisePlayerCommandDone()

void VoltMod::PluginRegistry::RaisePlayerCommandDone ( int  slot,
const PlayerInput &  input 
)

◆ RaiseServerStartup()

void VoltMod::PluginRegistry::RaiseServerStartup ( std::string_view  mapName)

◆ RegisterHostCommand()

void VoltMod::PluginRegistry::RegisterHostCommand ( std::string_view  name)

Keep name for the host's own console commands, so no plugin can take it.

Definition at line 186 of file PluginRegistry.cpp.

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

◆ RemovePlugin()

LeakReport VoltMod::PluginRegistry::RemovePlugin ( std::string_view  name)

Drop every subscription, publication and command name name still holds, and report them.

Definition at line 50 of file PluginRegistry.cpp.

References VoltMod::ReadFile().

◆ SetSchemaLayout()

void VoltMod::PluginRegistry::SetSchemaLayout ( uint64_t  stamp,
bool  verified 
)

Record what the host's own schema check found. stamp identifies the layout it checked, so a plugin can tell whether the answer covers the offsets it was built with.

Definition at line 25 of file PluginRegistry.cpp.

References VoltMod::ReadFile(), VoltMod::SharedState::SchemaLayoutStamp, and VoltMod::SharedState::SchemaVerified.


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