OpenClonk
C4Control Class Reference

#include <C4Control.h>

Inheritance diagram for C4Control:
[legend]
Collaboration diagram for C4Control:
[legend]

Public Member Functions

 C4Control ()
 
 ~C4Control () override
 
void Clear ()
 
C4IDPacketfirstPkt () const
 
C4IDPacketnextPkt (C4IDPacket *pPkt) const
 
void AddHead (C4PacketType eType, C4ControlPacket *pCtrl)
 
void Add (C4PacketType eType, C4ControlPacket *pCtrl)
 
void Take (C4Control &Ctrl)
 
void Append (const C4Control &Ctrl)
 
void Copy (const C4Control &Ctrl)
 
void Remove (C4IDPacket *pPkt)
 
void Delete (C4IDPacket *pPkt)
 
bool PreExecute () const
 
void Execute () const
 
void PreRec (C4Record *pRecord) const
 
void CompileFunc (StdCompiler *pComp) override
 
C4NetIOPacket pack (const C4NetIO::addr_t &addr=C4NetIO::addr_t()) const
 
C4NetIOPacket pack (uint8_t cStatus, const C4NetIO::addr_t &addr=C4NetIO::addr_t()) const
 
void unpack (const C4NetIOPacket &Pkt, char *pStatus=nullptr)
 

Protected Attributes

C4PacketList Pkts
 

Detailed Description

Definition at line 64 of file C4Control.h.

Constructor & Destructor Documentation

◆ C4Control()

C4Control::C4Control ( )
default

◆ ~C4Control()

C4Control::~C4Control ( )
override

Definition at line 80 of file C4Control.cpp.

81 {
82  Clear();
83 }
void Clear()
Definition: C4Control.cpp:85

References Clear().

Here is the call graph for this function:

Member Function Documentation

◆ Add()

void C4Control::Add ( C4PacketType  eType,
C4ControlPacket pCtrl 
)
inline

Definition at line 82 of file C4Control.h.

82 { Pkts.Add(eType, pCtrl); }
C4PacketList Pkts
Definition: C4Control.h:71
void Add(C4IDPacket *pPkt)
Definition: C4Packet2.cpp:283

References C4PacketList::Add(), and Pkts.

Referenced by C4Network2::AddVote(), C4MouseControl::ButtonUpDragScript(), ConsoleDlgProc(), C4PlayerList::CtrlRemove(), C4GameControl::DoInput(), C4GameControlNetwork::DoInput(), C4GameControl::DoSyncCheck(), C4ScriptGuiWindowAction::Execute(), C4Playback::ExecuteControl(), C4GameControlNetwork::HandleControlPkt(), C4MouseControl::LeftUpDragNone(), C4PlayerInfoList::LocalJoinUnjoinedPlayersInQueue(), C4GameSaveSavegame::OnSaving(), C4ObjectMenu::OnUserClose(), C4ObjectMenu::OnUserEnter(), C4ObjectMenu::OnUserSelectItem(), C4MouseControl::RightUpDragNone(), and C4MouseControl::UpdateCursorTarget().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddHead()

void C4Control::AddHead ( C4PacketType  eType,
C4ControlPacket pCtrl 
)
inline

Definition at line 81 of file C4Control.h.

81 { Pkts.AddHead(eType, pCtrl); }
void AddHead(C4IDPacket *pPkt)
Definition: C4Packet2.cpp:290

References C4PacketList::AddHead(), and Pkts.

Referenced by C4PlayerControl::PrepareInput().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Append()

void C4Control::Append ( const C4Control Ctrl)
inline

Definition at line 85 of file C4Control.h.

85 { Pkts.Append(Ctrl.Pkts); }
void Append(const C4PacketList &List)
Definition: C4Packet2.cpp:315

References C4PacketList::Append(), and Pkts.

Referenced by C4GameControlPacket::Add(), C4Playback::ExecuteControl(), and C4GameControlNetwork::GetControl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Clear()

void C4Control::Clear ( )

Definition at line 85 of file C4Control.cpp.

86 {
87  Pkts.Clear();
88 }
void Clear()
Definition: C4Packet2.cpp:321

References C4PacketList::Clear(), and Pkts.

Referenced by C4GameControlNetwork::Clear(), C4Network2::Clear(), Copy(), C4GameControl::Default(), C4GameControlNetwork::ExecSyncControl(), C4GameControlNetwork::GetControl(), C4GameControl::Prepare(), and ~C4Control().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompileFunc()

void C4Control::CompileFunc ( StdCompiler pComp)
overridevirtual

Implements C4PacketBase.

Definition at line 138 of file C4Control.cpp.

139 {
140  pComp->Value(Pkts);
141 }
void Value(const T &rStruct)
Definition: StdCompiler.h:161

References Pkts, and StdCompiler::Value().

Here is the call graph for this function:

◆ Copy()

void C4Control::Copy ( const C4Control Ctrl)
inline

Definition at line 86 of file C4Control.h.

86 { Clear(); Pkts.Append(Ctrl.Pkts); }

References C4PacketList::Append(), Clear(), and Pkts.

Referenced by C4GameControlPacket::C4GameControlPacket(), C4Record::Rec(), and C4GameControlPacket::Set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Delete()

void C4Control::Delete ( C4IDPacket pPkt)
inline

Definition at line 88 of file C4Control.h.

88 { Pkts.Delete(pPkt); }
void Delete(C4IDPacket *pPkt)
Definition: C4Packet2.cpp:348

References C4PacketList::Delete(), and Pkts.

Referenced by C4Network2::EndVote(), and C4GameControl::RemoveOldSyncChecks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Execute()

void C4Control::Execute ( ) const

Definition at line 110 of file C4Control.cpp.

111 {
112  for (C4IDPacket *pPkt = firstPkt(); pPkt; pPkt = nextPkt(pPkt))
113  {
114  // recheck packet type: Must be control
115  if (pPkt->getPktType() & CID_First)
116  {
117  C4ControlPacket *pCtrlPkt = static_cast<C4ControlPacket *>(pPkt->getPkt());
118  if (pCtrlPkt)
119  pCtrlPkt->Execute();
120  }
121  else
122  {
123  LogF("C4Control::Execute: WARNING: Ignoring packet type %2x (not control.)", pPkt->getPktType());
124  }
125  }
126 }
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:262
@ CID_First
Definition: C4PacketBase.h:142
C4IDPacket * firstPkt() const
Definition: C4Control.h:78
C4IDPacket * nextPkt(C4IDPacket *pPkt) const
Definition: C4Control.h:79
virtual void Execute() const =0

References CID_First, C4ControlPacket::Execute(), firstPkt(), LogF(), and nextPkt().

Referenced by C4GameControl::ExecControl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ firstPkt()

C4IDPacket* C4Control::firstPkt ( ) const
inline

Definition at line 78 of file C4Control.h.

78 { return Pkts.firstPkt(); }
C4IDPacket * firstPkt() const
Definition: C4PacketBase.h:282

References C4PacketList::firstPkt(), and Pkts.

Referenced by C4Network2::AddVote(), C4Network2::EndVote(), C4GameControl::ExecControl(), C4GameControlNetwork::ExecSyncControl(), C4Network2::Execute(), Execute(), C4GameControl::GetSyncCheck(), C4Network2::GetVote(), C4Network2::OpenVoteDialog(), PreExecute(), C4GameControl::Prepare(), PreRec(), C4Record::Rec(), C4GameControl::RemoveOldSyncChecks(), and C4Playback::Strip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nextPkt()

C4IDPacket* C4Control::nextPkt ( C4IDPacket pPkt) const
inline

Definition at line 79 of file C4Control.h.

79 { return Pkts.nextPkt(pPkt); }
C4IDPacket * nextPkt(C4IDPacket *pPkt) const
Definition: C4PacketBase.h:283

References C4PacketList::nextPkt(), and Pkts.

Referenced by Execute(), C4GameControl::GetSyncCheck(), C4Network2::GetVote(), C4Network2::OpenVoteDialog(), PreExecute(), PreRec(), C4GameControl::RemoveOldSyncChecks(), and C4Playback::Strip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pack() [1/2]

C4NetIOPacket C4PacketBase::pack ( const C4NetIO::addr_t addr = C4NetIO::addr_t()) const
inherited

Definition at line 150 of file C4Packet2.cpp.

151 {
152  return C4NetIOPacket(DecompileToBuf<StdCompilerBinWrite>(*this), addr);
153 }

Referenced by MkC4NetIOPacket().

Here is the caller graph for this function:

◆ pack() [2/2]

C4NetIOPacket C4PacketBase::pack ( uint8_t  cStatus,
const C4NetIO::addr_t addr = C4NetIO::addr_t() 
) const
inherited

Definition at line 155 of file C4Packet2.cpp.

156 {
157  return C4NetIOPacket(DecompileToBuf<StdCompilerBinWrite>(mkInsertAdapt(mkDecompileAdapt(*this), cStatus)), addr);
158 }
StdInsertAdapt< T, I > mkInsertAdapt(T &&rObj, I &&rIns, bool fBefore=true)
Definition: StdAdaptors.h:469
StdDecompileAdapt< T > mkDecompileAdapt(const T &rValue)
Definition: StdAdaptors.h:153

References mkDecompileAdapt(), and mkInsertAdapt().

Here is the call graph for this function:

◆ PreExecute()

bool C4Control::PreExecute ( ) const

Definition at line 90 of file C4Control.cpp.

91 {
92  bool fReady = true;
93  for (C4IDPacket *pPkt = firstPkt(); pPkt; pPkt = nextPkt(pPkt))
94  {
95  // recheck packet type: Must be control
96  if (pPkt->getPktType() & CID_First)
97  {
98  C4ControlPacket *pCtrlPkt = static_cast<C4ControlPacket *>(pPkt->getPkt());
99  if (pCtrlPkt)
100  fReady &= pCtrlPkt->PreExecute();
101  }
102  else
103  {
104  LogF("C4Control::PreExecute: WARNING: Ignoring packet type %2x (not control.)", pPkt->getPktType());
105  }
106  }
107  return fReady;
108 }
virtual bool PreExecute() const
Definition: C4Control.h:48

References CID_First, firstPkt(), LogF(), nextPkt(), and C4ControlPacket::PreExecute().

Referenced by C4GameControlNetwork::CheckCompleteCtrl(), and C4GameControl::ExecControl().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PreRec()

void C4Control::PreRec ( C4Record pRecord) const

Definition at line 128 of file C4Control.cpp.

129 {
130  for (C4IDPacket *pPkt = firstPkt(); pPkt; pPkt = nextPkt(pPkt))
131  {
132  C4ControlPacket *pCtrlPkt = static_cast<C4ControlPacket *>(pPkt->getPkt());
133  if (pCtrlPkt)
134  pCtrlPkt->PreRec(pRecord);
135  }
136 }
virtual void PreRec(C4Record *pRecord)
Definition: C4Control.h:50

References firstPkt(), nextPkt(), and C4ControlPacket::PreRec().

Referenced by C4Record::Rec().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Remove()

void C4Control::Remove ( C4IDPacket pPkt)
inline

Definition at line 87 of file C4Control.h.

87 { Pkts.Remove(pPkt); }
void Remove(C4IDPacket *pPkt)
Definition: C4Packet2.cpp:327

References Pkts, and C4PacketList::Remove().

Here is the call graph for this function:

◆ Take()

void C4Control::Take ( C4Control Ctrl)
inline

Definition at line 84 of file C4Control.h.

84 { Pkts.Take(Ctrl.Pkts); }
void Take(C4PacketList &List)
Definition: C4Packet2.cpp:308

References Pkts, and C4PacketList::Take().

Here is the call graph for this function:

◆ unpack()

void C4PacketBase::unpack ( const C4NetIOPacket Pkt,
char *  pStatus = nullptr 
)
inherited

Definition at line 160 of file C4Packet2.cpp.

161 {
162  if (pStatus) *pStatus = Pkt.getStatus();
163  CompileFromBuf<StdCompilerBinRead>(*this, pStatus ? Pkt.getPBuf() : Pkt.getRef());
164 }
uint8_t getStatus() const
Definition: C4NetIO.h:319
StdBuf getPBuf() const
Definition: C4NetIO.h:322
C4NetIOPacket getRef() const
Definition: C4NetIO.h:325

References C4NetIOPacket::getPBuf(), C4NetIOPacket::getRef(), and C4NetIOPacket::getStatus().

Referenced by C4IDPacket::C4IDPacket(), and C4Network2IO::HandlePacket().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ Pkts

C4PacketList C4Control::Pkts
protected

Definition at line 71 of file C4Control.h.

Referenced by Add(), AddHead(), Append(), Clear(), CompileFunc(), Copy(), Delete(), firstPkt(), nextPkt(), Remove(), and Take().


The documentation for this class was generated from the following files: