OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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 ( )
default
C4Control::~C4Control ( )
override

Definition at line 80 of file C4Control.cpp.

References Clear().

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

Here is the call graph for this function:

Member Function Documentation

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

Definition at line 82 of file C4Control.h.

References C4PacketList::Add().

Referenced by C4Network2::AddVote(), C4MouseControl::ButtonUpDragScript(), ConsoleDlgProc(), C4PlayerList::CtrlRemove(), C4GameControlNetwork::DoInput(), C4GameControl::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().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 81 of file C4Control.h.

References C4PacketList::AddHead().

Referenced by C4PlayerControl::PrepareInput().

81 { Pkts.AddHead(eType, pCtrl); }
C4PacketList Pkts
Definition: C4Control.h:71
void AddHead(C4IDPacket *pPkt)
Definition: C4Packet2.cpp:286

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Control::Append ( const C4Control Ctrl)
inline

Definition at line 85 of file C4Control.h.

References C4PacketList::Append(), and Pkts.

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

85 { Pkts.Append(Ctrl.Pkts); }
C4PacketList Pkts
Definition: C4Control.h:71
void Append(const C4PacketList &List)
Definition: C4Packet2.cpp:311

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Control::Clear ( )

Definition at line 85 of file C4Control.cpp.

References C4PacketList::Clear(), and Pkts.

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

86 {
87  Pkts.Clear();
88 }
C4PacketList Pkts
Definition: C4Control.h:71
void Clear()
Definition: C4Packet2.cpp:317

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Control::CompileFunc ( StdCompiler pComp)
overridevirtual

Implements C4PacketBase.

Definition at line 138 of file C4Control.cpp.

References Pkts, and StdCompiler::Value().

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

Here is the call graph for this function:

void C4Control::Copy ( const C4Control Ctrl)
inline

Definition at line 86 of file C4Control.h.

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

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

86 { Clear(); Pkts.Append(Ctrl.Pkts); }
C4PacketList Pkts
Definition: C4Control.h:71
void Append(const C4PacketList &List)
Definition: C4Packet2.cpp:311
void Clear()
Definition: C4Control.cpp:85

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Control::Delete ( C4IDPacket pPkt)
inline

Definition at line 88 of file C4Control.h.

References C4PacketList::Delete().

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

88 { Pkts.Delete(pPkt); }
C4PacketList Pkts
Definition: C4Control.h:71
void Delete(C4IDPacket *pPkt)
Definition: C4Packet2.cpp:344

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Control::Execute ( ) const

Definition at line 110 of file C4Control.cpp.

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

Referenced by C4GameControl::ExecControl(), and C4GameControl::Execute().

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 }
C4IDPacket * firstPkt() const
Definition: C4Control.h:78
C4IDPacket * nextPkt(C4IDPacket *pPkt) const
Definition: C4Control.h:79
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:250
virtual void Execute() const =0

Here is the call graph for this function:

Here is the caller graph for this function:

C4IDPacket* C4Control::firstPkt ( ) const
inline

Definition at line 78 of file C4Control.h.

References C4PacketList::firstPkt().

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

78 { return Pkts.firstPkt(); }
C4PacketList Pkts
Definition: C4Control.h:71
C4IDPacket * firstPkt() const
Definition: C4PacketBase.h:277

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 79 of file C4Control.h.

References C4PacketList::nextPkt().

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

79 { return Pkts.nextPkt(pPkt); }
C4PacketList Pkts
Definition: C4Control.h:71
C4IDPacket * nextPkt(C4IDPacket *pPkt) const
Definition: C4PacketBase.h:278

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 149 of file C4Packet2.cpp.

Referenced by MkC4NetIOPacket().

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

Here is the caller graph for this function:

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

Definition at line 154 of file C4Packet2.cpp.

References mkDecompileAdapt(), and mkInsertAdapt().

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

Here is the call graph for this function:

bool C4Control::PreExecute ( ) const

Definition at line 90 of file C4Control.cpp.

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

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

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 }
C4IDPacket * firstPkt() const
Definition: C4Control.h:78
virtual bool PreExecute() const
Definition: C4Control.h:48
C4IDPacket * nextPkt(C4IDPacket *pPkt) const
Definition: C4Control.h:79
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:250

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Control::PreRec ( C4Record pRecord) const

Definition at line 128 of file C4Control.cpp.

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

Referenced by C4Record::Rec().

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 }
C4IDPacket * firstPkt() const
Definition: C4Control.h:78
virtual void PreRec(C4Record *pRecord)
Definition: C4Control.h:50
C4IDPacket * nextPkt(C4IDPacket *pPkt) const
Definition: C4Control.h:79

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Control::Remove ( C4IDPacket pPkt)
inline

Definition at line 87 of file C4Control.h.

References C4PacketList::Remove().

87 { Pkts.Remove(pPkt); }
C4PacketList Pkts
Definition: C4Control.h:71
void Remove(C4IDPacket *pPkt)
Definition: C4Packet2.cpp:323

Here is the call graph for this function:

void C4Control::Take ( C4Control Ctrl)
inline

Definition at line 84 of file C4Control.h.

References Pkts, and C4PacketList::Take().

Referenced by C4GameControl::Execute().

84 { Pkts.Take(Ctrl.Pkts); }
C4PacketList Pkts
Definition: C4Control.h:71
void Take(C4PacketList &List)
Definition: C4Packet2.cpp:304

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 159 of file C4Packet2.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

C4PacketList C4Control::Pkts
protected

Definition at line 71 of file C4Control.h.

Referenced by Append(), Clear(), CompileFunc(), Copy(), and Take().


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