MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / StartProtobufMessage

Method StartProtobufMessage

core/UserMessages.cpp:237–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235}
236
237google::protobuf::Message *UserMessages::StartProtobufMessage(int msg_id, const cell_t players[], unsigned int playersNum, int flags)
238{
239#ifndef USE_PROTOBUF_USERMESSAGES
240 return NULL;
241#else
242 protobuf::Message *buffer;
243
244 if (m_InExec || m_InHook)
245 {
246 return NULL;
247 }
248 if (msg_id < 0 || msg_id >= 255)
249 {
250 return NULL;
251 }
252
253 m_CurId = msg_id;
254 m_CellRecFilter.Initialize(players, playersNum);
255
256 m_CurFlags = flags;
257 if (m_CurFlags & USERMSG_INITMSG)
258 {
259 m_CellRecFilter.SetToInit(true);
260 }
261 if (m_CurFlags & USERMSG_RELIABLE)
262 {
263 m_CellRecFilter.SetToReliable(true);
264 }
265
266 m_InExec = true;
267
268 if (m_CurFlags & USERMSG_BLOCKHOOKS)
269 {
270 // direct message creation, return buffer "from engine". keep track
271 m_FakeEngineBuffer = GetMessagePrototype(msg_id)->New();
272 buffer = m_FakeEngineBuffer;
273 } else {
274 char messageName[32];
275 if (!GetMessageName(msg_id, messageName, sizeof(messageName)))
276 {
277 m_InExec = false;
278 return NULL;
279 }
280
281 protobuf::Message *msg = OnStartMessage_Pre(static_cast<IRecipientFilter *>(&m_CellRecFilter), msg_id, messageName);
282 switch (m_FakeMetaRes)
283 {
284 case MRES_IGNORED:
285 case MRES_HANDLED:
286 m_FakeEngineBuffer = GetMessagePrototype(msg_id)->New();
287 buffer = m_FakeEngineBuffer;
288 break;
289
290 case MRES_OVERRIDE:
291 m_FakeEngineBuffer = GetMessagePrototype(msg_id)->New();
292 // fallthrough
293 case MRES_SUPERCEDE:
294 buffer = msg;

Callers 7

smn_StartMessageFunction · 0.80
smn_StartMessageExFunction · 0.80
TextMsgMethod · 0.80
HintTextMsgMethod · 0.80
ShowVGUIMenuMethod · 0.80
UTIL_SendHudTextFunction · 0.80
Radio_RefreshMethod · 0.80

Calls 4

NewMethod · 0.80
InitializeMethod · 0.45
SetToInitMethod · 0.45
SetToReliableMethod · 0.45

Tested by

no test coverage detected