VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
Runtime.hpp
Go to the documentation of this file.
1#pragma once
2
43#include <memory>
44#include <string>
45#include <string_view>
46
47namespace VoltMod
48{
49
50/**
51 * @brief Framework services for one load and unload cycle.
52 *
53 * Members are declared in dependency order, and each engine service does its setup when built;
54 * a feature that did not bind says why in its `Available()` and in @ref LoadReport. Screens follow
55 * the hook tiers so their hooks are removed first.
56 */
58{
59public:
60 /** @p host, @p unsafe and @p languages outlive the runtime; the plugin module opened @p unsafe first. */
61 Runtime(IPluginContext& host, UnsafeServices& unsafe, PlayerLanguages& languages);
62 ~Runtime();
63 Runtime(const Runtime&) = delete;
64 Runtime& operator=(const Runtime&) = delete;
65
66 /** Drive the scheduler. Called once per frame from the GameFrame hook. */
67 void OnGameFrame();
68
69 /** The plugin's `plugin.json` name and directory under `addons/voltmod/plugins/`. */
70 const std::string PluginName;
71 /** The plugin's `plugin.json` version. */
72 const std::string Version;
73
74 /** "addons/voltmod/plugins/<PluginName>/<relative>". */
75 std::string PluginFile(std::string_view relative) const;
76
77 /**
78 * Draw menus on @p layout for players who have it, center HTML for the rest, while the
79 * returned Subscription lives. Hold it below @p layout, which the menu refers to. A player still
80 * downloading a required addon gets center HTML.
81 */
82 [[nodiscard]] Subscription UsePanorama(PanoramaMenuLayout& layout);
83
85
87
89
90 /**
91 * Per-frame delivery, timers, and delayed work. Pending timers are discarded on destruction;
92 * their callbacks may capture only members declared above Scheduler.
93 */
95
97
98 /** The opt-in engine-access tier (Interfaces, Bindings), resolved before any service. */
100
101 /** Schema field offsets resolve themselves, per process rather than per load - see @ref Field. */
102 EntitySystem Entities{Unsafe.Interfaces, Unsafe.Bindings};
103
105
106 /** Plugin-supplied permission, targeting and reply rules, and the one gate that applies
107 * them (`Policy::Authorize`). `HasPermission` asks whichever plugin publishes
108 * @ref IPermissions until a plugin sets its own. */
110
112
113 /** Map validation and level changes. The current map is captured from StartupServer, so it
114 * is empty after a late load until the next map change. */
116
118
120
122
123 /** Resources for the next map's session manifest. */
125
126 /** Per-client latency and replicated userinfo cvars. */
128
129 /** Line and box traces for sight and reachability questions. */
131
132 /** The round timer, and ending the current round with a winner. */
134
135 /** Per-player usercmds from the host's RunCommand hook, listened to while subscribed. */
137
138 /** Which clients receive which entities. */
140
141 /** The next chat line from a player, for menu prompts. */
143
145
146 /** Chat, center and alert lines on their way to the clients. */
148
149 /** Who hears whose voice. */
151
152 /** Ask a client for one of its own convars. */
154
155 /** The game's yes/no vote panel. */
157
159
161
163
165
167
168 /** Holds players still while a menu is open. Disabled by default. */
170
172 .Slots = Slots,
173 .Entities = Entities,
174 .Freeze = Freeze,
175 .ChatInput = ChatInput,
176 .Translations = Translations,
177 .Policy = Policy,
178 .Messages = Messages}};
179
180 /** Routes menus to center HTML or a plugin-preferred surface. */
182
184
185 /** HTTP client. Completions are replayed on the game thread. */
187
188private:
189 /** Check every service into @ref LoadReport: Messages required, the rest optional. */
190 void CheckServices();
191 void AddStatusSections();
192
194};
195
196} // namespace VoltMod
Menus drawn as center HTML and driven with W/S/A/D/E/R. It needs no client addon, so runtime....
Per-player pending-prompt registry for menu free-text input.
Definition ChatInput.hpp:27
Asks a connected client what one of its own convars is set to.
The engine's simulation clock, read straight from IVEngineServer2::GetServerGlobals().
Definition Clock.hpp:19
Typed commands for chat and the server console.
Every entity's damage, from CBaseEntity::TakeDamageOld, and a way to deal it.
Definition Damage.hpp:80
runtime.Entities: finds and creates entities. Everything it returns is valid for this frame only; see...
Creates, fires and listens to game events.
Runs HTTP requests off the game thread and their completions on it.
Holding players still while a menu is open, for every menu surface.
runtime.Menus: the surface menus start on, chosen once per session.
Send chat, center print, center HTML, and alert messages.
Definition Messages.hpp:30
Each player's command from CCSPlayer_MovementServices::RunCommand.
Definition Movement.hpp:23
Per-client network access: latency, userids, usercmd status and the client's replicated userinfo cvar...
The screen built from the menu Panorama block, as PanoramaMenu draws on it.
The roster: every connected player, and the signals for the connection lifecycle.
The one permission and targeting gate, plus the plugin's reply callback.
Definition Policy.hpp:41
runtime.Rounds: the running round's timer, and ending the round with the engine's own win panel and r...
Definition Rounds.hpp:33
VoltMod::Visibility Visibility
Definition Runtime.hpp:139
VoltMod::NetChannels NetChannels
Definition Runtime.hpp:127
VoltMod::CommandManager Commands
Definition Runtime.hpp:183
VoltMod::Precache Precache
Definition Runtime.hpp:124
SlotEvents Slots
Definition Runtime.hpp:88
VoltMod::Movement Movement
Definition Runtime.hpp:136
VoltMod::WeaponDrop WeaponDrop
Definition Runtime.hpp:160
VoltMod::Map Map
Definition Runtime.hpp:115
VoltMod::Vote Vote
Definition Runtime.hpp:156
StatusService Status
Definition Runtime.hpp:86
MultiAddonManager AddonManager
Definition Runtime.hpp:164
HttpClient Http
Definition Runtime.hpp:186
VoltMod::GameEvents GameEvents
Definition Runtime.hpp:117
VoltMod::TextMessages TextMessages
Definition Runtime.hpp:147
const std::string PluginName
Definition Runtime.hpp:70
VoltMod::Trace Trace
Definition Runtime.hpp:130
VoltMod::Translations Translations
Definition Runtime.hpp:96
VoltMod::LoadReport LoadReport
Definition Runtime.hpp:84
VoltMod::ClientConVars ClientConVars
Definition Runtime.hpp:153
Runtime & operator=(const Runtime &)=delete
ServiceExchange Exchange
Definition Runtime.hpp:166
VoltMod::Messages Messages
Definition Runtime.hpp:119
VoltMod::Policy Policy
Definition Runtime.hpp:109
VoltMod::MenuFreeze Freeze
Definition Runtime.hpp:169
VoltMod::Scheduler Scheduler
Definition Runtime.hpp:94
VoltMod::Rounds Rounds
Definition Runtime.hpp:133
CenterHtmlMenu CenterHtml
Definition Runtime.hpp:171
std::string PluginFile(std::string_view relative) const
Definition Runtime.cpp:75
VoltMod::ConVars ConVars
Definition Runtime.hpp:111
EntitySystem Entities
Definition Runtime.hpp:102
MenuRouter Menus
Definition Runtime.hpp:181
PlayerManager Players
Definition Runtime.hpp:104
const std::string Version
Definition Runtime.hpp:72
VoltMod::Clock Clock
Definition Runtime.hpp:121
VoltMod::ScreenManager Screens
Definition Runtime.hpp:162
Runtime(IPluginContext &host, UnsafeServices &unsafe, PlayerLanguages &languages)
Definition Runtime.cpp:38
UnsafeServices & Unsafe
Definition Runtime.hpp:99
Runtime(const Runtime &)=delete
VoltMod::Teleport Teleport
Definition Runtime.hpp:144
Subscription UsePanorama(PanoramaMenuLayout &layout)
Definition Runtime.cpp:80
VoltMod::Damage Damage
Definition Runtime.hpp:158
VoltMod::ChatInput ChatInput
Definition Runtime.hpp:142
VoltMod::Voice Voice
Definition Runtime.hpp:150
One-shot delays and repeating timers, run on the game thread.
Definition Scheduler.hpp:18
Create Screen objects and report their button presses.
Typed view of the host's table of interfaces plugins publish to each other.
"The occupant of this slot changed" - raised by PlayerManager, consumed below it.
Build text and JSON diagnostics from named providers.
Owns one registration and releases it on destruction.
Report player pawn moves through CBaseEntity::Teleport.
Definition Teleport.hpp:29
Outgoing TextMsg user messages, the game's own lines included.
runtime.Trace: line and box traces against the physics world. Game-thread only.
Definition Trace.hpp:51
Localization system. Loads one JSON file per language; nested objects flatten into dotted keys (categ...
Which clients receive which entities, filtered after CheckTransmit.
Who hears whose voice, decided each time the game opens a voice channel.
Definition Voice.hpp:34
The game's yes/no vote panel (F1/F2), with the ballots counted here.
Definition Vote.hpp:69
A player's own weapon drops, from CCSPlayer_WeaponServices::DropWeapon.
Opt-in access to raw engine interfaces and typed gamedata bindings.