VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
WorkshopDownloads.hpp
Go to the documentation of this file.
1#pragma once
2
5
9#include <cstdint>
10#include <vector>
11
12namespace VoltMod
13{
14
15/**
16 * The workshop addons connecting clients must download, for every plugin at once: one set of hooks
17 * and one list, so an addon two plugins require downloads once. One addon per reconnect; see
18 * @ref workshop_guide. Game thread only.
19 */
21{
22public:
23 /** Unbound @p bindings or a listen server downloads nothing. @p bindings must outlive this. */
25
26 /** Require @p addonId of every client until a matching @ref Remove; false when nothing was added. */
27 bool Add(uint64_t addonId) override;
28 void Remove(uint64_t addonId) override;
29
30 /** Whether @p slot has every required addon. */
31 bool IsReady(int slot) override;
32
33 /** A reconnect is the only sign a download finished. */
35
36 /** A player who really left, not one moved by a map change. */
38
39 /** Runs the kicks queued last frame: kicking inside the send hook crashes on Windows. */
40 void OnFrame();
41
42private:
43 Status Install();
44 void RemoveHooksIfUnused();
45
46 void OnJoinMessage(const CNetMessage* message, void* client);
47 /** Add @p client's addons to the server's list for its connection reply, then remove them. */
48 void AddToReply(CNetworkGameServerBase& server, const EngineClient* client);
49 void RestoreReply(CNetworkGameServerBase& server);
50
51 struct Kick
52 {
53 int Slot = -1;
54 int64_t SteamId = 0;
55 };
56
57 IVEngineServer2* _engine;
58 const Bindings& _bindings;
59 DownloadQueue _queue;
60 std::vector<Kick> _kicks;
61 std::vector<uint64_t> _addedToReply;
62 Subscription _joinMessageHook; ///< tells a client what to download
63 Subscription _connectionReplyHook; ///< tells a client what to mount
64};
65
66} // namespace VoltMod
Static utilities for converting between SteamID formats (64-bit, SteamID2, SteamID3).
Definition SteamId.hpp:12
Owns one registration and releases it on destruction.
void OnClientDisconnected(int64_t steamId)
void Remove(uint64_t addonId) override
bool IsReady(int slot) override
bool Add(uint64_t addonId) override
void OnClientConnected(int64_t steamId)
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
std::expected< void, Error > Status
Definition Result.hpp:67
@ Kick
the client refused AddonDecision::Id too often