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

Referenced by C4ControlPacket::CompileFunc().

Here is the caller graph for this function:

◆ ~C4Control()

C4Control::~C4Control ( )
override

Definition at line 80 of file C4Control.cpp.

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

Member Function Documentation

◆ Add()

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

◆ AddHead()

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:287
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.

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:312
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.

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

86 {
87  Pkts.Clear();
88 }
C4PacketList Pkts
Definition: C4Control.h:71
void Clear()
Definition: C4Packet2.cpp:318
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.

References C4Window::Active, C4EditCursor::AddToSelection(), C4GameParameters::AllowDebug, AulExec, C4ClientIDHost, C4CVT_ControlRate, C4CVT_DisableDebug, C4CVT_MaxPlayer, C4CVT_None, C4CVT_TeamColors, C4CVT_TeamDistribution, C4MaxControlRate, C4VString(), C4PropList::Call(), C4GameScriptHost::Call(), C4EditCursor::ClearSelection(), C4Game::Clients, C4Network2::Clients, C4ControlPacket::CompileFunc(), Config, Console, Control, C4GameControl::ControlRate, C4GameParameters::ControlRate, C4ConfigNetwork::ControlRate, C4AulDebug::ControlScriptEvaluated(), C4GraphicsSystem::DeactivateDebugOutput(), C4Game::DebugMode, C4AulExec::DirectExec(), C4Console::EditCursor, StdStrBuf::EscapeString(), C4ControlPacket::Execute(), C4GraphicsSystem::FlashMessage(), FormatString(), C4Game::FrameCounter, Game, GameScript, C4PlayerList::Get(), C4Network2ClientList::GetClientByID(), C4ClientList::getClientByID(), C4MessageInput::GetCommand(), C4AulExec::GetContext(), C4AulExec::GetContextDepth(), StdStrBuf::getData(), C4Value::GetDataString(), C4AulDebug::GetDebugger(), C4Network2ClientList::GetLocal(), C4PropList::GetName(), C4Network2Client::getName(), C4Client::getName(), C4Value::getPropList(), C4AulScriptEngine::GetPropList(), GraphicsSystem, C4GUI::GUISound(), C4ControlPacket::HostControl(), C4ControlPacket::iByClient, C4EditCursor::InvalidateSelection(), C4GameControl::isCtrlHost(), C4Network2::isEnabled(), C4GameParameters::isLeague(), C4GameControl::isNetwork(), C4GameControl::isReplay(), C4Game::IsRunning, LoadResStr(), C4ControlPacket::LocalControl(), Log(), LogF(), C4GameParameters::MaxPlayers, MessageInput, mkIntAdapt(), mkIntPackAdapt(), mkNamingAdapt(), Network, C4Config::Network, NO_OWNER, Objects, C4EditCursor::OnSelectionChanged(), C4Game::Parameters, C4ScriptGuiWindowPropertyName::player, Players, PSF_InputCallback, C4Player::RemoveMessageBoardQuery(), StdStrBuf::Replace(), C4GameObjects::SafeObjectPointer(), C4GameScriptHost::ScenPropList, C4MessageBoardCommand::Script, ScriptEngine, C4TeamList::SetTeamColors(), C4TeamList::SetTeamDistribution(), C4Game::Teams, 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:

◆ Copy()

void C4Control::Copy ( const C4Control Ctrl)
inline

Definition at line 86 of file C4Control.h.

References C4PacketList::Append(), 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:312
void Clear()
Definition: C4Control.cpp:85
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.

References C4ControlPacket::CompileFunc(), C4PacketList::Delete(), C4ControlPacket::Execute(), C4ControlPacket::PreExecute(), and C4ControlPacket::PreRec().

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

88 { Pkts.Delete(pPkt); }
C4PacketList Pkts
Definition: C4Control.h:71
void Delete(C4IDPacket *pPkt)
Definition: C4Packet2.cpp:345
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.

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

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:260
virtual void Execute() const =0
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.

References C4PacketList::firstPkt().

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

78 { return Pkts.firstPkt(); }
C4PacketList Pkts
Definition: C4Control.h:71
C4IDPacket * firstPkt() const
Definition: C4PacketBase.h:280
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.

References C4PacketList::nextPkt().

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

79 { return Pkts.nextPkt(pPkt); }
C4PacketList Pkts
Definition: C4Control.h:71
C4IDPacket * nextPkt(C4IDPacket *pPkt) const
Definition: C4PacketBase.h:281
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.

Referenced by MkC4NetIOPacket().

151 {
152  return C4NetIOPacket(DecompileToBuf<StdCompilerBinWrite>(*this), addr);
153 }
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.

References mkDecompileAdapt(), and mkInsertAdapt().

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

◆ PreExecute()

bool C4Control::PreExecute ( ) const

Definition at line 90 of file C4Control.cpp.

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

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

◆ Remove()

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:324
Here is the call graph for this function:

◆ Take()

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:305
Here is the call graph for this function:
Here is the caller graph for this function:

◆ unpack()

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

Definition at line 160 of file C4Packet2.cpp.

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

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

161 {
162  if (pStatus) *pStatus = Pkt.getStatus();
163  CompileFromBuf<StdCompilerBinRead>(*this, pStatus ? Pkt.getPBuf() : Pkt.getRef());
164 }
uint8_t getStatus() const
Definition: C4NetIO.h:318
StdBuf getPBuf() const
Definition: C4NetIO.h:321
C4NetIOPacket getRef() const
Definition: C4NetIO.h:324
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 Append(), Copy(), and Take().


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