VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
Precache.cpp
Go to the documentation of this file.
3#include <algorithm>
4
5// The SDK declares this without defining it. The overloads are in Linux order; MSVC reverses them.
7{
8public:
9 virtual void AddResource(const char*) = 0;
10 virtual void AddResource(const char*, void*) = 0;
11 virtual void AddResource(const char*, void*, void*, void*) = 0;
12};
13
14namespace VoltMod
15{
16
17void Precache::Add(std::string_view path)
18{
19 if (path.empty())
20 {
21 return;
22 }
23
24 if (std::ranges::find(_resources, path) != _resources.end())
25 {
26 return;
27 }
28
29 _resources.emplace_back(path);
30}
31
33{
34 for (const auto& path : _resources)
35 {
36 manifest.AddResource(path.c_str());
37 }
38
39 if (!_resources.empty())
40 {
41 Log::Info("Precache: added {} resource(s) to the session manifest.", _resources.size());
42 }
43}
44
45} // namespace VoltMod
virtual void AddResource(const char *)=0
virtual void AddResource(const char *, void *)=0
virtual void AddResource(const char *, void *, void *, void *)=0
void Add(std::string_view path)
Definition Precache.cpp:17
void WriteTo(IEntityResourceManifest &manifest) const
Definition Precache.cpp:32
void Info(std::format_string< Args... > fmt, Args &&... args)
Definition Log.hpp:79
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56