VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
Notify.cpp
Go to the documentation of this file.
1#include "Schema/Notify.hpp"
2
4#include <entity2/entityinstance.h>
5
6namespace VoltMod::Schema
7{
8
9// The engine's CNetworkVarChainer: the link from a replicated sub-object to its owner. Only the
10// two fields the notification needs are named; the padding is the engine's layout, re-verify
11// after a CS2 update.
18static_assert(offsetof(OwnerLink, PathIndex) == 0x20);
19
21{
22 if (!entity)
23 {
24 return;
25 }
26
27 entity->NetworkStateChanged(NetworkStateChangedData(static_cast<uint32>(offset)));
28}
29
31{
32 if (!component || ownerLinkOffset < 0)
33 {
34 return;
35 }
36
38 if (!link->Entity)
39 {
40 return;
41 }
42
43 link->Entity->NetworkStateChanged(NetworkStateChangedData(static_cast<uint32>(offset), -1, link->PathIndex));
44}
45
47{
48 if (!component || ownerLinkOffset < 0)
49 {
50 return nullptr;
51 }
52 // MemberPtr takes a mutable base; the read here never writes through it.
53 return MemberPtr<const OwnerLink>(const_cast<void*>(component), ownerLinkOffset)->Entity;
54}
55
56} // namespace VoltMod::Schema
Typed read/write of engine fields at a base pointer + byte offset.
void NotifyComponentOwner(void *component, int32_t ownerLinkOffset, int32_t offset)
Definition Notify.cpp:30
void NotifyEntity(CEntityInstance *entity, int32_t offset)
Definition Notify.cpp:20
CEntityInstance * ComponentOwner(const void *component, int32_t ownerLinkOffset)
Definition Notify.cpp:46
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56