VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
Layout.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <cstdint>
6#include <functional>
7#include <span>
8#include <string_view>
9
10namespace VoltMod::Schema
11{
12
13/** Finds @p field on @p className or its bases in the live server schema. */
14using LiveFieldLookup = std::function<LiveField(std::string_view className, std::string_view field)>;
15
16/** One field the generated accessors use; its offset comes from the live schema at load. */
18{
19 std::string_view Class;
20 std::string_view Field;
21 int32_t Size = 0; ///< checked against the live field; 0 skips the check
22 int32_t Offset = -1;
23};
24
25/** This module's own copy: the generated accessors read their offsets from it. */
27
28/** Every field in @ref GeneratedFields, owner links included. */
29std::span<FieldLayout> GeneratedLayout();
30
31/**
32 * Fill every offset in @p fields from @p lookup. Game thread, before any accessor runs.
33 * @return Every gone or resized field in one message; offsets that were found are filled either way.
34 */
35Status ResolveLayout(std::span<FieldLayout> fields, const LiveFieldLookup& lookup);
36
37} // namespace VoltMod::Schema
std::function< LiveField(std::string_view className, std::string_view field)> LiveFieldLookup
Definition Layout.hpp:14
FieldLayout GeneratedFields[]
Definition Layout.cpp:8
Status ResolveLayout(std::span< FieldLayout > fields, const LiveFieldLookup &lookup)
Definition Layout.cpp:10
std::span< FieldLayout > GeneratedLayout()
Definition Layout.cpp:137
std::expected< void, Error > Status
Definition Result.hpp:67
int32_t Size
checked against the live field; 0 skips the check
Definition Layout.hpp:21
std::string_view Field
Definition Layout.hpp:20
std::string_view Class
Definition Layout.hpp:19