MCPcopy Create free account
hub / github.com/ddnet/ddnet / UnpackMessageId

Function UnpackMessageId

src/engine/shared/protocol_ex.cpp:19–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19int UnpackMessageId(int *pId, bool *pSys, CUuid *pUuid, CUnpacker *pUnpacker, CMsgPacker *pPacker)
20{
21 *pId = 0;
22 *pSys = false;
23 mem_zero(pUuid, sizeof(*pUuid));
24
25 int MsgId = pUnpacker->GetInt();
26
27 if(pUnpacker->Error())
28 {
29 return UNPACKMESSAGE_ERROR;
30 }
31
32 *pId = MsgId >> 1;
33 *pSys = MsgId & 1;
34
35 if(*pId < 0 || *pId >= OFFSET_UUID)
36 {
37 return UNPACKMESSAGE_ERROR;
38 }
39
40 if(*pId != 0) // NETMSG_EX, NETMSGTYPE_EX
41 {
42 return UNPACKMESSAGE_OK;
43 }
44
45 *pId = g_UuidManager.UnpackUuid(pUnpacker, pUuid);
46
47 if(*pId == UUID_INVALID || *pId == UUID_UNKNOWN)
48 {
49 return UNPACKMESSAGE_ERROR;
50 }
51
52 if(*pSys)
53 {
54 switch(*pId)
55 {
56 case NETMSG_WHATIS:
57 {
58 CUuid Uuid2;
59 int Id2 = g_UuidManager.UnpackUuid(pUnpacker, &Uuid2);
60 if(Id2 == UUID_INVALID)
61 {
62 break;
63 }
64 if(Id2 == UUID_UNKNOWN)
65 {
66 new(pPacker) CMsgPacker(NETMSG_IDONTKNOW, true);
67 pPacker->AddRaw(&Uuid2, sizeof(Uuid2));
68 }
69 else
70 {
71 new(pPacker) CMsgPacker(NETMSG_ITIS, true);
72 pPacker->AddRaw(&Uuid2, sizeof(Uuid2));
73 pPacker->AddString(g_UuidManager.GetName(Id2), 0);
74 }
75 return UNPACKMESSAGE_ANSWER;
76 }

Callers 4

OnDemoPlayerMessageMethod · 0.85
ProcessServerPacketMethod · 0.85
OnDemoPlayerMessageMethod · 0.85
ProcessClientPacketMethod · 0.85

Calls 10

mem_zeroFunction · 0.85
FormatUuidFunction · 0.85
dbg_msgFunction · 0.85
UnpackUuidMethod · 0.80
AddRawMethod · 0.80
GetIntMethod · 0.45
ErrorMethod · 0.45
AddStringMethod · 0.45
GetNameMethod · 0.45
GetStringMethod · 0.45

Tested by

no test coverage detected