VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
NetMessage.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
VoltMod/Engine/EngineTypes.hpp
>
4
#include <
VoltMod/Engine/Interfaces.hpp
>
5
#include <functional>
6
#include <string_view>
7
8
namespace
VoltMod
9
{
10
11
/**
12
* Send one user message: resolve its type, allocate it, let @p fill populate it, post it to
13
* @p filter, and deallocate it.
14
*
15
* The deallocate has to pair with the allocate on every exit path, including the one where the
16
* protobuf cast fails. Getting that wrong leaks a net message per send, which is why every
17
* sender goes through here instead of repeating the sequence.
18
*
19
* @param cached the caller's cache of the resolved message type, filled on the first call.
20
* Message types are stable for the process, so this is resolved once per sender.
21
* @param partialName matched with FindNetworkMessagePartial, e.g. "TextMsg" or "VoteStart".
22
* Partial rather than exact because a registered message is named with its id appended
23
* (`"CUserMessageTextMsg [124]"`), so INetworkMessages::FindNetworkMessage matches
24
* nothing at all - there is no name a caller could pass it that would.
25
* @param fill returns false to abandon the send; the message is still deallocated.
26
* @return whether the message was posted.
27
*/
28
bool
PostUserMessage
(Interfaces&
interfaces
,
INetworkMessageInternal
*&
cached
, std::string_view
partialName
,
29
IRecipientFilter&
filter
,
const
std::function<
bool
(
CNetMessage
*)>&
fill
);
30
31
}
// namespace VoltMod
EngineTypes.hpp
Interfaces.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
src
Engine
Net
NetMessage.hpp
Generated by
1.9.8