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#include <networksystem/networkvar.h>
6
7namespace VoltMod::Schema
8{
9
10void NotifyEntity(CEntityInstance* entity, int32_t offset)
11{
12 if (!entity)
13 {
14 return;
15 }
16
17 entity->NetworkStateChanged(NetworkStateChangedData(static_cast<uint32>(offset)));
18}
19
20void NotifyComponentOwner(void* component, int32_t ownerLinkOffset, int32_t offset)
21{
22 if (!component || ownerLinkOffset < 0)
23 {
24 return;
25 }
26
27 // The chainer adds its path index and, like the engine, skips an owner still being constructed.
28 NetworkStateChangedData change(static_cast<uint32>(offset));
29 MemberPtr<CNetworkVarChainer>(component, ownerLinkOffset)->NetworkStateChanged(change);
30}
31
32CEntityInstance* ComponentOwner(const void* component, int32_t ownerLinkOffset)
33{
34 if (!component || ownerLinkOffset < 0)
35 {
36 return nullptr;
37 }
38 // MemberPtr takes a mutable base; the read here never writes through it.
39 return *MemberPtr<CNetworkVarChainer>(const_cast<void*>(component), ownerLinkOffset);
40}
41
42} // 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:20
void NotifyEntity(CEntityInstance *entity, int32_t offset)
Definition Notify.cpp:10
CEntityInstance * ComponentOwner(const void *component, int32_t ownerLinkOffset)
Definition Notify.cpp:32
T * MemberPtr(void *base, std::ptrdiff_t offset) noexcept