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 ()
 
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
 
virtual void CompileFunc (StdCompiler *pComp)
 
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 ( )

Definition at line 85 of file C4Control.cpp.

86 {
87 
88 }
C4Control::~C4Control ( )

Definition at line 90 of file C4Control.cpp.

References Clear().

91 {
92  Clear();
93 }
void Clear()
Definition: C4Control.cpp:95

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:297
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:304

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:329

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Control::Clear ( )

Definition at line 95 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().

96 {
97  Pkts.Clear();
98 }
C4PacketList Pkts
Definition: C4Control.h:71
void Clear()
Definition: C4Packet2.cpp:335

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Control::CompileFunc ( StdCompiler pComp)
virtual

Implements C4PacketBase.

Definition at line 148 of file C4Control.cpp.

References Pkts, and StdCompiler::Value().

149 {
150  pComp->Value(Pkts);
151 }
C4PacketList Pkts
Definition: C4Control.h:71
void Value(const T &rStruct)
Definition: StdCompiler.h:171

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:329
void Clear()
Definition: C4Control.cpp:95

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:362

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Control::Execute ( ) const

Definition at line 120 of file C4Control.cpp.

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

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

121 {
122  for (C4IDPacket *pPkt = firstPkt(); pPkt; pPkt = nextPkt(pPkt))
123  {
124  // recheck packet type: Must be control
125  if (pPkt->getPktType() & CID_First)
126  {
127  C4ControlPacket *pCtrlPkt = static_cast<C4ControlPacket *>(pPkt->getPkt());
128  if (pCtrlPkt)
129  pCtrlPkt->Execute();
130  }
131  else
132  {
133  LogF("C4Control::Execute: WARNING: Ignoring packet type %2x (not control.)", pPkt->getPktType());
134  }
135  }
136 }
C4IDPacket * firstPkt() const
Definition: C4Control.h:78
C4IDPacket * nextPkt(C4IDPacket *pPkt) const
Definition: C4Control.h:79
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:253
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 156 of file C4Packet2.cpp.

Referenced by MkC4NetIOPacket().

157 {
158  return C4NetIOPacket(DecompileToBuf<StdCompilerBinWrite>(*this), addr);
159 }

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 161 of file C4Packet2.cpp.

References mkDecompileAdapt(), and mkInsertAdapt().

162 {
163  return C4NetIOPacket(DecompileToBuf<StdCompilerBinWrite>(mkInsertAdapt(mkDecompileAdapt(*this), cStatus)), addr);
164 }
StdDecompileAdapt< T > mkDecompileAdapt(const T &rValue)
Definition: StdAdaptors.h:154
StdInsertAdapt< T, I > mkInsertAdapt(T &&rObj, I &&rIns, bool fBefore=true)
Definition: StdAdaptors.h:435

Here is the call graph for this function:

bool C4Control::PreExecute ( ) const

Definition at line 100 of file C4Control.cpp.

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

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

101 {
102  bool fReady = true;
103  for (C4IDPacket *pPkt = firstPkt(); pPkt; pPkt = nextPkt(pPkt))
104  {
105  // recheck packet type: Must be control
106  if (pPkt->getPktType() & CID_First)
107  {
108  C4ControlPacket *pCtrlPkt = static_cast<C4ControlPacket *>(pPkt->getPkt());
109  if (pCtrlPkt)
110  fReady &= pCtrlPkt->PreExecute();
111  }
112  else
113  {
114  LogF("C4Control::PreExecute: WARNING: Ignoring packet type %2x (not control.)", pPkt->getPktType());
115  }
116  }
117  return fReady;
118 }
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:253

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 138 of file C4Control.cpp.

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

Referenced by C4Record::Rec().

139 {
140  for (C4IDPacket *pPkt = firstPkt(); pPkt; pPkt = nextPkt(pPkt))
141  {
142  C4ControlPacket *pCtrlPkt = static_cast<C4ControlPacket *>(pPkt->getPkt());
143  if (pCtrlPkt)
144  pCtrlPkt->PreRec(pRecord);
145  }
146 }
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:341

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:322

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 166 of file C4Packet2.cpp.

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

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

167 {
168  if (pStatus) *pStatus = Pkt.getStatus();
169  CompileFromBuf<StdCompilerBinRead>(*this, pStatus ? Pkt.getPBuf() : Pkt.getRef());
170 }
StdBuf getPBuf() const
Definition: C4NetIO.h:321
C4NetIOPacket getRef() const
Definition: C4NetIO.h:324
uint8_t getStatus() const
Definition: C4NetIO.h:318

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: