OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Packet2.cpp
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 #include "C4Include.h"
17 
18 #include "C4Version.h"
19 #include "control/C4RoundResults.h"
20 #include "gui/C4GameLobby.h"
22 #include "network/C4Network2.h"
23 #include "network/C4Network2Res.h"
24 
25 // *** constants
26 
27 // workaround
28 template <class T> struct unpack_class
29 {
31  {
32  assert(pComp->isDeserializer());
33  T *pPkt = new T();
34  try
35  {
36  pComp->Value(*pPkt);
37  }
38  catch (...)
39  {
40  delete pPkt;
41  throw;
42  }
43  return pPkt;
44  }
45 };
46 
47 #define PKT_UNPACK(T) unpack_class<T>::unpack
48 
49 
51 {
52 
53  // C4Network2IO (network thread)
54  { PID_Conn, PC_Network, "Connection Request", true, true, PH_C4Network2IO, PKT_UNPACK(C4PacketConn) },
55  { PID_ConnRe, PC_Network, "Connection Request Reply", true, true, PH_C4Network2IO, PKT_UNPACK(C4PacketConnRe) },
56 
57  { PID_Ping, PC_Network, "Ping", true, true, PH_C4Network2IO, PKT_UNPACK(C4PacketPing) },
58  { PID_Pong, PC_Network, "Pong", true, true, PH_C4Network2IO, PKT_UNPACK(C4PacketPing) },
59 
60  { PID_FwdReq, PC_Network, "Forward Request", false, true, PH_C4Network2IO, PKT_UNPACK(C4PacketFwd) },
61  { PID_Fwd, PC_Network, "Forward", false, true, PH_C4Network2IO, PKT_UNPACK(C4PacketFwd) },
62 
63  { PID_PostMortem, PC_Network, "Post Mortem", false, true, PH_C4Network2IO, PKT_UNPACK(C4PacketPostMortem) },
64 
65  // C4Network2 (main thread)
66  { PID_Conn, PC_Network, "Connection Request", true, false, PH_C4Network2, PKT_UNPACK(C4PacketConn) },
67  { PID_ConnRe, PC_Network, "Connection Request Reply", true, false, PH_C4Network2, PKT_UNPACK(C4PacketConnRe) },
68 
69  { PID_Status, PC_Network, "Game Status", true, false, PH_C4Network2, PKT_UNPACK(C4Network2Status) },
70  { PID_StatusAck, PC_Network, "Game Status Acknowledgement",true, false, PH_C4Network2, PKT_UNPACK(C4Network2Status) },
71 
72  { PID_ClientActReq, PC_Network, "Client Activation Request", false, false, PH_C4Network2, PKT_UNPACK(C4PacketActivateReq) },
73 
74  { PID_JoinData, PC_Network, "Join Data", false, false, PH_C4Network2, PKT_UNPACK(C4PacketJoinData) },
75 
76  // C4Network2PlayerList (main thread)
77  { PID_PlayerInfoUpdReq,PC_Network, "Player info update request",true, false, PH_C4Network2Players, PKT_UNPACK(C4PacketPlayerInfoUpdRequest) },
78 
80 
81  // C4GameLobby (main thread)
84 
85  // C4Network2ClientList (main thread)
86  { PID_Addr, PC_Network, "Client Address", false, false, PH_C4Network2ClientList, PKT_UNPACK(C4PacketAddr) },
87 
88 
89  // C4Network2ResList (network thread)
90  { PID_NetResDis, PC_Network, "Resource Discover", true, true, PH_C4Network2ResList, PKT_UNPACK(C4PacketResDiscover) },
91  { PID_NetResStat, PC_Network, "Resource Status", false, true, PH_C4Network2ResList, PKT_UNPACK(C4PacketResStatus) },
92  { PID_NetResDerive, PC_Network, "Resource Derive", false, true, PH_C4Network2ResList, PKT_UNPACK(C4Network2ResCore) },
93  { PID_NetResReq, PC_Network, "Resource Request", false, true, PH_C4Network2ResList, PKT_UNPACK(C4PacketResRequest) },
94  { PID_NetResData, PC_Network, "Resource Data", false, true, PH_C4Network2ResList, PKT_UNPACK(C4Network2ResChunk) },
95 
96  // C4GameControlNetwork (network thread)
98  { PID_ControlReq, PC_Network, "Control Request", false, true, PH_C4GameControlNetwork, PKT_UNPACK(C4PacketControlReq) },
99  // main thread
100  { PID_ControlPkt, PC_Network, "Control Paket", false, false, PH_C4GameControlNetwork, PKT_UNPACK(C4PacketControlPkt) },
101  { PID_ExecSyncCtrl, PC_Network, "Execute Sync Control", false, false, PH_C4GameControlNetwork, PKT_UNPACK(C4PacketExecSyncCtrl)},
102 
103  // Control (Isn't send over network, handled only as part of a control list)
104  { CID_ClientJoin, PC_Control, "Client Join", false, true, 0, PKT_UNPACK(C4ControlClientJoin) },
105  { CID_ClientUpdate, PC_Control, "Client Update", false, true, 0, PKT_UNPACK(C4ControlClientUpdate)},
106  { CID_ClientRemove, PC_Control, "Client Remove", false, true, 0, PKT_UNPACK(C4ControlClientRemove)},
107  { CID_Vote, PC_Control, "Voting", false, true, 0, PKT_UNPACK(C4ControlVote) },
108  { CID_VoteEnd, PC_Control, "Voting End", false, true, 0, PKT_UNPACK(C4ControlVoteEnd) },
109  { CID_SyncCheck, PC_Control, "Sync Check", false, true, 0, PKT_UNPACK(C4ControlSyncCheck) },
110  { CID_Synchronize, PC_Control, "Synchronize", false, true, 0, PKT_UNPACK(C4ControlSynchronize)},
111  { CID_Set, PC_Control, "Set", false, true, 0, PKT_UNPACK(C4ControlSet) },
112  { CID_Script, PC_Control, "Script", false, true, 0, PKT_UNPACK(C4ControlScript) },
113  { CID_MsgBoardReply,PC_Control, "Message Board Reply", false, true, 0, PKT_UNPACK(C4ControlMsgBoardReply)},
114  { CID_MsgBoardCmd ,PC_Control, "Message Board Command", false, true, 0, PKT_UNPACK(C4ControlMsgBoardCmd)},
115  { CID_PlrInfo, PC_Control, "Player Info", false, true, 0, PKT_UNPACK(C4ControlPlayerInfo) },
116  { CID_JoinPlr, PC_Control, "Join Player", false, true, 0, PKT_UNPACK(C4ControlJoinPlayer) },
117  { CID_RemovePlr, PC_Control, "Remove Player", false, true, 0, PKT_UNPACK(C4ControlRemovePlr) },
118  { CID_PlrSelect, PC_Control, "Player Select", false, true, 0, PKT_UNPACK(C4ControlPlayerSelect)},
119  { CID_PlrControl, PC_Control, "Player Control", false, true, 0, PKT_UNPACK(C4ControlPlayerControl)},
120  { CID_PlrAction, PC_Control, "Player Self-Mgmt Action", false, true, 0, PKT_UNPACK(C4ControlPlayerAction)},
121  { CID_PlrMouseMove, PC_Control, "Player Mouse Movement", false, true, 0, PKT_UNPACK(C4ControlPlayerMouse)},
122  { CID_Message, PC_Control, "Message", false, true, 0, PKT_UNPACK(C4ControlMessage) },
123  { CID_MenuCommand, PC_Control, "Menu Command", false, true, 0, PKT_UNPACK(C4ControlMenuCommand)},
124  { CID_EMMoveObj, PC_Control, "EM Move Obj", false, true, 0, PKT_UNPACK(C4ControlEMMoveObject)},
125  { CID_EMDrawTool, PC_Control, "EM Draw Tool", false, true, 0, PKT_UNPACK(C4ControlEMDrawTool) },
126  { CID_ReInitScenario,PC_Control, "Reinit Scenario", false, true, 0, PKT_UNPACK(C4ControlReInitScenario) },
127  { CID_EditGraph, PC_Control, "Edit Graph", false, true, 0, PKT_UNPACK(C4ControlEditGraph) },
128 
129  { CID_DebugRec, PC_Control, "Debug Rec", false, true, 0, PKT_UNPACK(C4ControlDebugRec) },
130 
131  // EOL
132  { PID_None, PC_Network, nullptr, false, true, 0, nullptr }
133 };
134 
135 const char *PacketNameByID(C4PacketType eID)
136 {
137  for (const C4PktHandlingData *pPData = PktHandlingData; pPData->ID != PID_None; pPData++)
138  if (pPData->ID == eID)
139  return pPData->Name;
140  return "?!?";
141 }
142 
143 // *** C4PacketBase
144 
145 C4PacketBase::C4PacketBase() = default;
146 
147 C4PacketBase::~C4PacketBase() = default;
148 
150 {
151  return C4NetIOPacket(DecompileToBuf<StdCompilerBinWrite>(*this), addr);
152 }
153 
154 C4NetIOPacket C4PacketBase::pack(uint8_t cStatus, const C4NetIO::addr_t &addr) const
155 {
156  return C4NetIOPacket(DecompileToBuf<StdCompilerBinWrite>(mkInsertAdapt(mkDecompileAdapt(*this), cStatus)), addr);
157 }
158 
159 void C4PacketBase::unpack(const C4NetIOPacket &Pkt, char *pStatus)
160 {
161  if (pStatus) *pStatus = Pkt.getStatus();
162  CompileFromBuf<StdCompilerBinRead>(*this, pStatus ? Pkt.getPBuf() : Pkt.getRef());
163 }
164 
165 
166 // *** C4PktBuf
167 
168 C4PktBuf::C4PktBuf() = default;
169 
171 {
172  Data.Copy(rCopy.Data);
173 }
174 
175 C4PktBuf::C4PktBuf(const StdBuf &rCpyData)
176 {
177  Data.Copy(rCpyData);
178 }
179 
181 {
182  pComp->Value(mkNamingAdapt(Data, "Data"));
183 }
184 
185 // *** C4IDPacket
186 
187 C4IDPacket::C4IDPacket() = default;
188 
190  : eID(eID), pPkt(pPkt), fOwnPkt(fTakePkt), pNext(nullptr)
191 {
192 
193 }
194 
196  : C4PacketBase(Packet2)
197 {
198  // kinda hacky (note this might throw an uncaught exception)
199  C4PacketBase::unpack(Packet2.C4PacketBase::pack());
200 }
201 
203 {
204  Clear();
205 }
206 
207 const char *C4IDPacket::getPktName() const
208 {
209  // Use map
210  for (const C4PktHandlingData *pPData = PktHandlingData; pPData->ID != PID_None; pPData++)
211  if (pPData->ID == eID && pPData->Name)
212  return pPData->Name;
213  return "Unknown Packet Type";
214 }
215 
217 {
218  eID = PID_None; pPkt = nullptr;
219 }
220 
222 {
223  if (fOwnPkt) delete pPkt; pPkt = nullptr;
224  eID = PID_None;
225 }
226 
228 {
229  // Packet ID
230  pComp->Value(mkNamingAdapt(mkIntAdaptT<uint8_t>(eID), "ID", PID_None));
231  // Compiling or Decompiling?
232  if (pComp->isDeserializer())
233  {
234  if (!pComp->Name(getPktName()))
235  { pComp->excCorrupt("C4IDPacket: Data value needed! Packet data missing!"); return; }
236  // Delete old packet
237  if (fOwnPkt) delete pPkt; pPkt = nullptr;
238  if (eID == PID_None) return;
239  // Search unpacking function
240  for (const C4PktHandlingData *pPData = PktHandlingData; pPData->ID != PID_None; pPData++)
241  if (pPData->ID == eID && pPData->FnUnpack)
242  {
243  pPkt = pPData->FnUnpack(pComp);
244  break;
245  }
246  if (!pPkt)
247  pComp->excCorrupt("C4IDPacket: could not unpack packet id %02x!", eID);
248  pComp->NameEnd();
249  }
250  else if (eID != PID_None)
251  // Just write
252  pComp->Value(mkNamingAdapt(*pPkt, getPktName()));
253 }
254 
255 // *** C4PacketList
256 
257 C4PacketList::C4PacketList() = default;
258 
260  : C4PacketBase(List2),
261  pFirst(nullptr), pLast(nullptr)
262 {
263  Append(List2);
264 }
265 
267 {
268  Clear();
269 }
270 
271 int32_t C4PacketList::getPktCnt() const
272 {
273  int32_t iCnt = 0;
274  for (C4IDPacket *pPkt = pFirst; pPkt; pPkt = pPkt->pNext)
275  iCnt++;
276  return iCnt;
277 }
278 
280 {
281  assert(!pPkt->pNext);
282  (pLast ? pLast->pNext : pFirst) = pPkt;
283  pLast = pPkt;
284 }
285 
287 {
288  assert(!pPkt->pNext);
289  pPkt->pNext = pFirst;
290  pFirst = pPkt;
291  if (!pLast) pLast = pPkt;
292 }
293 
295 {
296  Add(new C4IDPacket(eType, pPkt));
297 }
298 
300 {
301  AddHead(new C4IDPacket(eType, pPkt));
302 }
303 
305 {
306  pFirst = List.pFirst;
307  pLast = List.pLast;
308  List.pFirst = List.pLast = nullptr;
309 }
310 
312 {
313  for (C4IDPacket *pPkt = List.firstPkt(); pPkt; pPkt = List.nextPkt(pPkt))
314  Add(new C4IDPacket(*pPkt));
315 }
316 
318 {
319  while (pFirst)
320  Delete(pFirst);
321 }
322 
324 {
325  if (pPkt == pFirst)
326  {
327  pFirst = pPkt->pNext;
328  if (pPkt == pLast)
329  pLast = nullptr;
330  }
331  else
332  {
333  C4IDPacket *pPrev;
334  for (pPrev = pFirst; pPrev && pPrev->pNext != pPkt; pPrev = pPrev->pNext) {}
335  if (pPrev)
336  {
337  pPrev->pNext = pPkt->pNext;
338  if (pPkt == pLast)
339  pLast = pPrev;
340  }
341  }
342 }
343 
345 {
346  Remove(pPkt);
347  delete pPkt;
348 }
349 
351 {
352  // unpack packets
353  if (pComp->isDeserializer())
354  {
355  // Read until no further sections available
356  while (pComp->Name("IDPacket"))
357  {
358  // Read the packet
359  C4IDPacket *pPkt = new C4IDPacket();
360  try
361  {
362  pComp->Value(*pPkt);
363  pComp->NameEnd();
364  }
365  catch (...)
366  {
367  delete pPkt;
368  throw;
369  }
370  // Terminator?
371  if (!pPkt->getPkt()) { delete pPkt; break; }
372  // Add to list
373  Add(pPkt);
374  }
375  pComp->NameEnd();
376  }
377  else
378  {
379  // Write all packets
380  for (C4IDPacket *pPkt = pFirst; pPkt; pPkt = pPkt->pNext)
381  pComp->Value(mkNamingAdapt(*pPkt, "IDPacket"));
382  // Terminate, if no naming is available
383  if (!pComp->hasNaming())
384  {
385  C4IDPacket Pkt;
386  pComp->Value(mkNamingAdapt(Pkt, "IDPacket"));
387  }
388  }
389 }
390 
391 // *** C4PacketConn
392 
394  : iVer(C4XVER1*100 + C4XVER2)
395 {
396 }
397 
398 C4PacketConn::C4PacketConn(const C4ClientCore &nCCore, uint32_t inConnID, const char *szPassword)
399  : iVer(C4XVER1*100 + C4XVER2),
400  iConnID(inConnID),
401  CCore(nCCore),
402  Password(szPassword)
403 {
404 }
405 
407 {
408  pComp->Value(mkNamingAdapt(CCore, "CCore"));
409  pComp->Value(mkNamingAdapt(mkIntPackAdapt(iVer), "Version", -1));
410  pComp->Value(mkNamingAdapt(Password, "Password", ""));
411  pComp->Value(mkNamingAdapt(mkIntPackAdapt(iConnID), "ConnID", ~0u));
412 }
413 
414 // *** C4PacketConnRe
415 
417 
418 C4PacketConnRe::C4PacketConnRe(bool fnOK, bool fWrongPassword, const char *sznMsg)
419  : fOK(fnOK),
420  fWrongPassword(fWrongPassword),
421  szMsg(sznMsg, true)
422 {
423 }
424 
426 {
427  pComp->Value(mkNamingAdapt(fOK, "OK", true));
428  pComp->Value(mkNamingAdapt(szMsg, "Message", ""));
429  pComp->Value(mkNamingAdapt(fWrongPassword, "WrongPassword", false));
430 }
431 
432 // *** C4PacketFwd
433 
434 C4PacketFwd::C4PacketFwd() = default;
435 
437  : Data(Pkt)
438 {
439 }
440 
441 bool C4PacketFwd::DoFwdTo(int32_t iClient) const
442 {
443  for (int32_t i = 0; i < iClientCnt; i++)
444  if (iClients[i] == iClient)
445  return !fNegativeList;
446  return fNegativeList;
447 }
448 
449 void C4PacketFwd::SetData(const StdBuf &Pkt)
450 {
451  Data = Pkt;
452 }
453 
454 void C4PacketFwd::SetListType(bool fnNegativeList)
455 {
456  fNegativeList = fnNegativeList;
457 }
458 
459 void C4PacketFwd::AddClient(int32_t iClient)
460 {
461  if (iClientCnt + 1 > C4NetMaxClients) return;
462  // add
463  iClients[iClientCnt++] = iClient;
464 }
465 
467 {
468  pComp->Value(mkNamingAdapt(fNegativeList, "Negative", false));
469  pComp->Value(mkNamingAdapt(mkIntPackAdapt(iClientCnt), "ClientCnt", 0));
470  pComp->Value(mkNamingAdapt(mkArrayAdaptMap(iClients, iClientCnt, mkIntPackAdapt<int32_t>), "Clients", -1));
471  pComp->Value(mkNamingAdapt(Data, "Data"));
472 }
473 
474 // *** C4PacketJoinData
475 
477 {
479  pComp->Value(mkNamingAdapt(mkIntPackAdapt(iStartCtrlTick), "CtrlTick", -1));
480  pComp->Value(mkNamingAdapt(mkParAdapt(GameStatus, true), "GameStatus"));
481  pComp->Value(mkNamingAdapt(Dynamic, "Dynamic"));
482  pComp->Value(mkNamingAdapt(ScenarioParameterDefs, "ParameterDefs"));
483  pComp->Value(Parameters);
484 }
485 
486 // *** C4PacketPing
487 
488 C4PacketPing::C4PacketPing(uint32_t iPacketCounter, uint32_t iRemotePacketCounter)
489  : tTime(C4TimeMilliseconds::Now()),
490  iPacketCounter(iPacketCounter)
491 {
492 }
493 
495 {
496  return C4TimeMilliseconds::Now() - tTime;
497 }
498 
500 {
501  uint32_t time = tTime.AsInt();
502  pComp->Value(mkNamingAdapt(time, "Time", 0U));
503  tTime = C4TimeMilliseconds(time);
504 
505  pComp->Value(mkNamingAdapt(iPacketCounter, "PacketCounter", 0U));
506 }
507 
508 // *** C4PacketResStatus
509 
511 
513  : iResID(iResID), Chunks(nChunks)
514 {
515 
516 }
517 
519 {
520  pComp->Value(mkNamingAdapt(iResID, "ResID"));
521  pComp->Value(mkNamingAdapt(Chunks, "Chunks"));
522 }
523 
524 // *** C4PacketResDiscover
525 
527 
528 bool C4PacketResDiscover::isIDPresent(int32_t iID) const
529 {
530  for (int32_t i = 0; i < iDisIDCnt; i++)
531  if (iDisIDs[i] == iID)
532  return true;
533  return false;
534 }
535 
537 {
538  if (iDisIDCnt + 1 >= int32_t(sizeof(iDisIDs) / sizeof(*iDisIDs))) return false;
539  // add
540  iDisIDs[iDisIDCnt++] = iID;
541  return true;
542 }
543 
545 {
546  pComp->Value(mkNamingAdapt(mkIntPackAdapt(iDisIDCnt), "DiscoverCnt", 0));
547  pComp->Value(mkNamingAdapt(mkArrayAdapt(iDisIDs, iDisIDCnt), "Discovers", -1));
548 }
549 
550 // *** C4PacketResRequest
551 
552 C4PacketResRequest::C4PacketResRequest(int32_t inID, int32_t inChunk)
553  : iReqID(inID), iReqChunk(inChunk)
554 {
555 
556 }
557 
559 {
560  pComp->Value(mkNamingAdapt(iReqID, "ResID", -1));
561  pComp->Value(mkNamingAdapt(mkIntPackAdapt(iReqChunk), "Chunk", -1));
562 }
563 
564 // *** C4PacketControlReq
565 
567  : iCtrlTick(inCtrlTick)
568 {
569 
570 }
571 
573 {
574  pComp->Value(mkNamingAdapt(mkIntPackAdapt(iCtrlTick), "CtrlTick", -1));
575 }
576 
577 // *** C4PacketActivateReq
578 
580 {
581  pComp->Value(mkNamingAdapt(mkIntPackAdapt(iTick), "Tick", -1));
582 }
583 
584 
585 // *** C4PacketControlPkt
586 
588 {
589  pComp->Value(mkNamingAdapt(mkIntAdaptT<uint8_t>(eDelivery), "Delivery", CDT_Queue));
590  pComp->Value(Ctrl);
591 }
C4PacketBase * pPkt
Definition: C4PacketBase.h:247
virtual bool hasNaming()
Definition: StdCompiler.h:58
StdStrBuf szMsg
Definition: C4Network2IO.h:377
Definition: StdBuf.h:29
C4IDPacket * pNext
Definition: C4PacketBase.h:251
void CompileFunc(StdCompiler *pComp) override
Definition: C4Packet2.cpp:180
const char * PacketNameByID(C4PacketType eID)
Definition: C4Packet2.cpp:135
void CompileFunc(StdCompiler *pComp) override
Definition: C4Packet2.cpp:499
void Clear()
Definition: C4Packet2.cpp:221
void Add(C4IDPacket *pPkt)
Definition: C4Packet2.cpp:279
void excCorrupt(const char *szMessage,...)
Definition: StdCompiler.h:249
C4Network2Status GameStatus
Definition: C4Network2.h:429
void CompileFunc(StdCompiler *pComp) override
Definition: C4Packet2.cpp:350
C4PacketType eID
Definition: C4PacketBase.h:246
uint32_t getTravelTime() const
Definition: C4Packet2.cpp:494
C4IDPacket * pFirst
Definition: C4PacketBase.h:274
StdBuf getPBuf() const
Definition: C4NetIO.h:320
bool AddDisID(int32_t iID)
Definition: C4Packet2.cpp:536
C4PacketControlReq(int32_t iCtrlTick=-1)
Definition: C4Packet2.cpp:566
C4PacketType
Definition: C4PacketBase.h:76
C4Network2ResCore Dynamic
Definition: C4Network2.h:426
C4ScenarioParameterDefs ScenarioParameterDefs
Definition: C4Network2.h:437
uint32_t iPacketCounter
Definition: C4Network2IO.h:339
C4IDPacket * pLast
Definition: C4PacketBase.h:274
C4NetIOPacket getRef() const
Definition: C4NetIO.h:323
C4Network2ResChunkData Chunks
virtual bool Name(const char *szName)
Definition: StdCompiler.h:77
int32_t iStartCtrlTick
Definition: C4Network2.h:432
const C4PktHandlingData PktHandlingData[]
Definition: C4Packet2.cpp:50
void Append(const C4PacketList &List)
Definition: C4Packet2.cpp:311
C4PacketType ID
Definition: C4PacketBase.h:201
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
void CompileFunc(StdCompiler *pComp) override
Definition: C4Packet2.cpp:558
void AddClient(int32_t iClient)
Definition: C4Packet2.cpp:459
const char * getPktName() const
Definition: C4Packet2.cpp:207
void CompileFunc(StdCompiler *pComp) override
Definition: C4Packet2.cpp:587
void Take(C4PacketList &List)
Definition: C4Packet2.cpp:304
int32_t iClients[C4NetMaxClients]
Definition: C4Network2IO.h:395
void CompileFunc(StdCompiler *pComp) override
Definition: C4Packet2.cpp:476
int iCnt
Definition: TstC4NetIO.cpp:32
#define PKT_UNPACK(T)
Definition: C4Packet2.cpp:47
void Copy(size_t inSize)
Definition: StdBuf.h:225
StdArrayAdapt< T > mkArrayAdapt(T *pArray, int iSize)
Definition: StdAdaptors.h:310
StdDecompileAdapt< T > mkDecompileAdapt(const T &rValue)
Definition: StdAdaptors.h:153
C4IDPacket * nextPkt(C4IDPacket *pPkt) const
Definition: C4PacketBase.h:278
void SetListType(bool fnNegativeList)
Definition: C4Packet2.cpp:454
static C4PacketBase * unpack(StdCompiler *pComp)
Definition: C4Packet2.cpp:30
void CompileFunc(StdCompiler *pComp) override
Definition: C4Packet2.cpp:406
StdInsertAdapt< T, I > mkInsertAdapt(T &&rObj, I &&rIns, bool fBefore=true)
Definition: StdAdaptors.h:437
void Clear()
Definition: C4Packet2.cpp:317
StdCopyBuf Data
Definition: C4PacketBase.h:223
void Delete(C4IDPacket *pPkt)
Definition: C4Packet2.cpp:344
void Value(const T &rStruct)
Definition: StdCompiler.h:161
const int32_t C4ClientIDUnknown
Definition: C4Client.h:24
C4PacketPing(uint32_t iPacketCounter=0, uint32_t iRemotePacketCounter=0)
Definition: C4Packet2.cpp:488
virtual bool isDeserializer()
Definition: StdCompiler.h:53
bool fNegativeList
Definition: C4Network2IO.h:394
void CompileFunc(StdCompiler *pComp) override
Definition: C4Packet2.cpp:572
StdIntPackAdapt< T > mkIntPackAdapt(T &rVal)
Definition: StdAdaptors.h:759
void CompileFunc(StdCompiler *pComp) override
Definition: C4Packet2.cpp:466
C4PacketResRequest(int32_t iID=-1, int32_t iChunk=-1)
Definition: C4Packet2.cpp:552
int32_t iClientCnt
Definition: C4Network2IO.h:396
virtual ~C4PacketBase()
void AddHead(C4IDPacket *pPkt)
Definition: C4Packet2.cpp:286
uint8_t getStatus() const
Definition: C4NetIO.h:317
int32_t iVer
Definition: C4Network2IO.h:355
void Remove(C4IDPacket *pPkt)
Definition: C4Packet2.cpp:323
int32_t iClientID
Definition: C4Network2.h:423
void CompileFunc(StdCompiler *pComp) override
Definition: C4Packet2.cpp:518
bool DoFwdTo(int32_t iClient) const
Definition: C4Packet2.cpp:441
bool isIDPresent(int32_t iID) const
Definition: C4Packet2.cpp:528
void CompileFunc(StdCompiler *pComp) override
Definition: C4Packet2.cpp:544
C4TimeMilliseconds tTime
Definition: C4Network2IO.h:338
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:458
void SetData(const StdBuf &Pkt)
Definition: C4Packet2.cpp:449
C4ClientCore CCore
Definition: C4Network2IO.h:357
C4NetIOPacket pack(const C4NetIO::addr_t &addr=C4NetIO::addr_t()) const
Definition: C4Packet2.cpp:149
uint32_t AsInt() const
StdArrayAdapt< T, M > mkArrayAdaptMap(T *pArray, int iSize, M &&map)
Definition: StdAdaptors.h:313
void CompileFunc(StdCompiler *pComp) override
Definition: C4Packet2.cpp:227
~C4IDPacket() override
Definition: C4Packet2.cpp:202
C4PacketBase * getPkt() const
Definition: C4PacketBase.h:255
StdCopyBuf Data
Definition: C4Network2IO.h:397
int32_t getPktCnt() const
Definition: C4Packet2.cpp:271
uint32_t iConnID
Definition: C4Network2IO.h:356
Definition: C4Network2IO.h:414
virtual void NameEnd(bool fBreak=false)
Definition: StdCompiler.h:78
void Default()
Definition: C4Packet2.cpp:216
void unpack(const C4NetIOPacket &Pkt, char *pStatus=nullptr)
Definition: C4Packet2.cpp:159
void CompileFunc(StdCompiler *pComp) override
Definition: C4Packet2.cpp:425
static C4TimeMilliseconds Now()
C4GameParameters Parameters
Definition: C4Network2.h:440
C4IDPacket * firstPkt() const
Definition: C4PacketBase.h:277
~C4PacketList() override
Definition: C4Packet2.cpp:266
StdCopyStrBuf Password
Definition: C4Network2IO.h:358
void CompileFunc(StdCompiler *pComp) override
Definition: C4Packet2.cpp:579
const int C4NetMaxClients
Definition: C4Network2IO.h:41