VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
NetMessage.cpp
Go to the documentation of this file.
1
#include "
Engine/Net/NetMessage.hpp
"
2
3
#include <
VoltMod/Engine/Interfaces.hpp
>
4
#include <engine/igameeventsystem.h>
5
#include <networksystem/inetworkmessages.h>
6
#include <networksystem/netmessage.h>
7
#include <string>
8
9
namespace
VoltMod
10
{
11
12
bool
PostUserMessage
(
Interfaces
&
interfaces
,
INetworkMessageInternal
*&
cached
, std::string_view
partialName
,
13
IRecipientFilter&
filter
,
const
std::function<
bool
(
CNetMessage
*)>&
fill
)
14
{
15
if
(!
interfaces
.GameEventSystem || !
interfaces
.NetworkMessages)
16
{
17
return
false
;
18
}
19
20
if
(!
cached
)
21
{
22
cached
=
interfaces
.NetworkMessages->FindNetworkMessagePartial(std::string(
partialName
).
c_str
());
23
}
24
if
(!
cached
)
25
{
26
return
false
;
27
}
28
29
CNetMessage
*
message
=
cached
->AllocateMessage();
30
if
(!
message
)
31
{
32
return
false
;
33
}
34
35
bool
posted
=
false
;
36
if
(
fill
(
message
))
37
{
38
interfaces
.GameEventSystem->PostEventAbstract(-1,
false
, &
filter
,
cached
,
message
, 0);
39
posted
=
true
;
40
}
41
42
interfaces
.NetworkMessages->DeallocateNetMessageAbstract(
cached
,
message
);
43
return
posted
;
44
}
45
46
}
// namespace VoltMod
Interfaces.hpp
NetMessage.hpp
VoltMod
Definition
Options.hpp:13
VoltMod::ReadFile
static std::string ReadFile(const std::filesystem::path &path)
Definition
Loader.cpp:56
VoltMod::PostUserMessage
bool PostUserMessage(Interfaces &interfaces, INetworkMessageInternal *&cached, std::string_view partialName, IRecipientFilter &filter, const std::function< bool(CNetMessage *)> &fill)
Definition
NetMessage.cpp:12
VoltMod::Interfaces
Centralized holder for all HL2SDK interface pointers.
Definition
Interfaces.hpp:19
src
Engine
Net
NetMessage.cpp
Generated by
1.9.8