VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
SchemaCheck.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
Host/Plugins/PluginRegistry.hpp
"
4
5
#include <
VoltMod/Core/Result.hpp
>
6
#include <
VoltMod/Engine/EngineTypes.hpp
>
7
#include <
VoltMod/Host/IPluginGameData.hpp
>
8
9
namespace
VoltMod
10
{
11
12
/**
13
* Compares the baked schema offsets with the live game once per process. The answer is recorded on
14
* @ref PluginRegistry and covers only plugins carrying the same layout stamp.
15
*/
16
class
SchemaCheck
17
{
18
public
:
19
/** Compare the layout once and record the answer on @p registry. Null interfaces check and dump nothing. */
20
SchemaCheck
(
PluginRegistry
&
registry
,
ISchemaSystem
* schema,
IGameResourceService
*
resources
);
21
22
/** Write the dump once a map's entities exist: at most once per process, never over a dump of this build. */
23
void
OnServerStartup
();
24
25
private
:
26
void
Check();
27
28
/** The entity system the engine caches in the resource service, null before the first map. */
29
CGameEntitySystem
* Entities()
const
;
30
31
PluginRegistry
& _registry;
32
ISchemaSystem
* _schema =
nullptr
;
33
IGameResourceService
* _resources =
nullptr
;
34
int
_entitySystemOffset = -1;
35
bool
_schemaLoaded =
false
;
///< false while the schema scope did not exist to compare against
36
};
37
38
namespace
Schema
39
{
40
41
/**
42
* Compare @ref GeneratedLayout with the live schema. Stale offsets hit wrong addresses, so a plugin
43
* built from this layout refuses to load when it fails.
44
* @return Every mismatch in one message, or ErrorCode::NotReady before the server scope exists.
45
*/
46
Status
VerifySchemaLayout
(
ISchemaSystem
* schema);
47
48
/**
49
* Write `addons/voltmod/gamedata/dumps/schema.json` for `voltmod framework schemagen` unless it matches this build.
50
* Null @p entities (before the first map) writes nothing: the networked flags need its serializers.
51
*/
52
void
WriteSchemaDump
(
ISchemaSystem
* schema,
CGameEntitySystem
*
entities
);
53
54
}
// namespace Schema
55
}
// namespace VoltMod
EngineTypes.hpp
IPluginGameData.hpp
PluginRegistry.hpp
Result.hpp
VoltMod::PluginRegistry
The loaded plugins and the engine events raised on them, one per process.
Definition
PluginRegistry.hpp:22
VoltMod::SchemaCheck
Definition
SchemaCheck.hpp:17
VoltMod::SchemaCheck::OnServerStartup
void OnServerStartup()
Definition
SchemaCheck.cpp:178
VoltMod::Schema::VerifySchemaLayout
Status VerifySchemaLayout(ISchemaSystem *schema)
Definition
SchemaCheck.cpp:99
VoltMod::Schema::WriteSchemaDump
void WriteSchemaDump(ISchemaSystem *schema, CGameEntitySystem *entities)
Definition
SchemaCheck.cpp:65
VoltMod
Definition
Options.hpp:13
VoltMod::ReadFile
static std::string ReadFile(const std::filesystem::path &path)
Definition
Loader.cpp:56
VoltMod::Status
std::expected< void, Error > Status
Definition
Result.hpp:67
src
Host
Schema
SchemaCheck.hpp
Generated by
1.9.8