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
9#include <cstdint>
10#include <string_view>
11
12namespace VoltMod
13{
14
15/** One plugin's view of the host. Everything reachable from it is host-owned and outlives the plugin.
16 * Game thread only. */
18{
19 /** The plugin's name: its manifest name and directory under `addons/voltmod/plugins/`. */
20 virtual std::string_view Name() const = 0;
21 virtual std::string_view Version() const = 0;
22
23 /** An engine interface by its exact version name, or null. */
24 virtual void* EngineInterface(const char* version) const = 0;
25 /** A game server interface by its exact version name, or null. */
26 virtual void* ServerInterface(const char* version) const = 0;
27 /** The absolute `csgo` directory that relative paths resolve against. */
28 virtual std::string_view BaseDir() const = 0;
29 /** Each module has its own `KHook::__exported__khook`; a plugin seeds it from this before hooking. */
30 virtual KHook::IKHook* HookDispatcher() const = 0;
31
32 virtual IPluginEvents& Events() = 0;
33 virtual IPluginServices& Services() = 0;
35 virtual IPluginAddons& Addons() = 0;
36 /** Null when the host resolved no gamedata. */
37 virtual IPluginGameData* GameData() const = 0;
38
39 /** False when another plugin holds @p name, which the host logs naming both. Released with the plugin. */
40 virtual bool RegisterCommand(std::string_view name) = 0;
41 /** True while any plugin, this one included, or the host holds @p name. */
42 virtual bool IsCommandRegistered(std::string_view name) const = 0;
43
44 /** Print one line under this plugin's `logTag`. @p level is a @ref LogLevel. */
45 virtual void WriteLog(uint8_t level, std::string_view text) = 0;
46 /** Lines below this are dropped; `volt log <name> <level>` changes it. */
47 virtual uint8_t MinLogLevel() const = 0;
48
49 /** The hash of the baked schema layout the host compared with the live game. */
50 virtual uint64_t SchemaLayoutStamp() const = 0;
51 virtual bool SchemaVerified() const = 0;
52
53protected:
54 ~IPluginContext() = default;
55};
56
57} // namespace VoltMod
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
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 uint64_t SchemaLayoutStamp() 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 bool SchemaVerified() const =0
virtual void * ServerInterface(const char *version) 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