VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
GameDataRecord.cpp
Go to the documentation of this file.
2
5
9#include <string_view>
10
11template <>
12struct glz::meta<VoltMod::GameDataRecord::Location>
13{
15 static constexpr auto value = glz::object("module", &T::Module, "rva", &T::Rva);
16};
17
18template <>
19struct glz::meta<VoltMod::GameDataRecord::Slot>
20{
22 static constexpr auto value =
23 glz::object("module", &T::Module, "table", &T::Table, "index", &T::Index, "code", &T::Code);
24};
25
26template <>
27struct glz::meta<VoltMod::GameDataRecord>
28{
30 static constexpr auto value = glz::object("build", &T::Build, "functions", &T::Functions, "globals", &T::Globals,
31 "vtables", &T::VTables, "offsets", &T::Offsets);
32};
33
34namespace VoltMod
35{
36
38{
39 constexpr std::string_view path = "addons/voltmod/gamedata/dumps/resolved.json";
40 const std::string build(GameBuild());
41 if (const auto existing = Json::ReadFile<GameDataRecord>(path); existing && existing->Build == build)
42 {
43 return;
44 }
45
47 stamped.Build = build;
49 {
50 Log::Warn("GameData: no record written to {}: {}", path, written.error().Detail);
51 }
52 else
53 {
54 Log::Info("GameData: recorded what resolved on server {} in {}.", build, path);
55 }
56}
57
58} // namespace VoltMod
static std::string WritePretty(const T &value)
Serialize value as prettified JSON.
Definition Json.hpp:89
static Result< T > ReadFile(std::string_view path)
Parse path (resolved via ResolvePath) into T.
Definition Json.hpp:46
void Info(std::format_string< Args... > fmt, Args &&... args)
Definition Log.hpp:79
void Warn(std::format_string< Args... > fmt, Args &&... args)
Definition Log.hpp:88
void WriteGameDataRecord(const GameDataRecord &resolved)
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
std::string_view GameBuild()
Definition GameBuild.cpp:10
std::expected< void, Error > Status
Definition Result.hpp:67
Status WriteAllText(std::string_view path, std::string_view text)
Write text to path (resolved via ResolvePath), creating its directory.
Definition File.cpp:24