VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
IPluginContext.hpp
Go to the documentation of this file.
1#pragma once
2
10#include <cstdint>
11#include <string_view>
12
13namespace VoltMod
14{
15
16/** One plugin's view of the host. Everything reachable from it is host-owned and outlives the plugin.
17 * Game thread only. */
19{
20 /** The plugin's name: its manifest name and directory under `addons/voltmod/plugins/`. */
21 virtual std::string_view Name() const = 0;
22 virtual std::string_view Version() const = 0;
23
24 /** An engine interface by its exact version name, or null. */
25 virtual void* EngineInterface(const char* version) const = 0;
26 /** A game server interface by its exact version name, or null. */
27 virtual void* ServerInterface(const char* version) const = 0;
28 /** The absolute `csgo` directory that relative paths resolve against. */
29 virtual std::string_view BaseDir() const = 0;
30 /** Each module has its own `KHook::__exported__khook`; a plugin seeds it from this before hooking. */
31 virtual KHook::IKHook* HookDispatcher() const = 0;
32
33 virtual IPluginEvents& Events() = 0;
34 virtual IPluginServices& Services() = 0;
36 virtual IPluginAddons& Addons() = 0;
37 /** Null when the host resolved no gamedata. */
38 virtual IPluginGameData* GameData() const = 0;
39
40 /** False when another plugin holds @p name, which the host logs naming both. Released with the plugin. */
41 virtual bool RegisterCommand(std::string_view name) = 0;
42 /** True while any plugin, this one included, or the host holds @p name. */
43 virtual bool IsCommandRegistered(std::string_view name) const = 0;
44
45 /** Print one line under this plugin's `logTag`. @p level is a @ref LogLevel. */
46 virtual void WriteLog(uint8_t level, std::string_view text) = 0;
47 /** Lines below this are dropped; `volt log <name> <level>` changes it. */
48 virtual uint8_t MinLogLevel() const = 0;
49
50 /** Where the running server lays out @p field of @p className; Offset -1 when it is gone. */
51 virtual Schema::LiveField FindSchemaField(std::string_view className, std::string_view field) const = 0;
52
53protected:
54 ~IPluginContext() = default;
55};
56
57} // namespace VoltMod
virtual std::string_view Name() const =0
virtual bool RegisterCommand(std::string_view name)=0
virtual std::string_view Version() const =0
virtual IPluginGameData * GameData() const =0
virtual IPluginAddons & Addons()=0
virtual IPluginEvents & Events()=0
virtual IPluginServices & Services()=0
virtual bool IsCommandRegistered(std::string_view name) const =0
virtual KHook::IKHook * HookDispatcher() const =0
virtual void * ServerInterface(const char *version) const =0
virtual Schema::LiveField FindSchemaField(std::string_view className, std::string_view field) const =0
virtual void WriteLog(uint8_t level, std::string_view text)=0
virtual std::string_view BaseDir() const =0
virtual uint8_t MinLogLevel() const =0
virtual void * EngineInterface(const char *version) const =0
virtual IPluginLanguages & Languages()=0