OpenClonk
C4Network2Status Class Reference

#include <C4Network2.h>

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

Public Member Functions

 C4Network2Status ()
 
C4NetGameState getState () const
 
int32_t getCtrlMode () const
 
int32_t getTargetCtrlTick () const
 
const char * getStateName () const
 
const char * getDescription () const
 
bool isEnabled () const
 
bool isLobbyActive () const
 
bool isPastLobby () const
 
bool isPaused () const
 
bool isRunning () const
 
void Set (C4NetGameState eState, int32_t iTargetCtrlTick)
 
void SetCtrlMode (int32_t iCtrlMode)
 
void SetTargetTick (int32_t iTargetCtrlTick)
 
void Clear ()
 
void CompileFunc (StdCompiler *pComp, bool fReference)
 
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

C4NetGameState eState {GS_None}
 
int32_t iCtrlMode
 
int32_t iTargetCtrlTick {-1}
 

Detailed Description

Definition at line 69 of file C4Network2.h.

Constructor & Destructor Documentation

◆ C4Network2Status()

C4Network2Status::C4Network2Status ( )
default

Member Function Documentation

◆ Clear()

void C4Network2Status::Clear ( )

Definition at line 97 of file C4Network2.cpp.

98 {
100 }
@ GS_None
Definition: C4Network2.h:62
int32_t iTargetCtrlTick
Definition: C4Network2.h:77
C4NetGameState eState
Definition: C4Network2.h:75

References eState, GS_None, and iTargetCtrlTick.

Referenced by C4Network2::Clear().

Here is the caller graph for this function:

◆ CompileFunc() [1/2]

void C4Network2Status::CompileFunc ( StdCompiler pComp)
overridevirtual

Implements C4PacketBase.

Definition at line 102 of file C4Network2.cpp.

103 {
104  CompileFunc(pComp, false);
105 }
void CompileFunc(StdCompiler *pComp, bool fReference)
Definition: C4Network2.cpp:107

References CompileFunc().

Here is the call graph for this function:

◆ CompileFunc() [2/2]

void C4Network2Status::CompileFunc ( StdCompiler pComp,
bool  fReference 
)

Definition at line 107 of file C4Network2.cpp.

108 {
109  StdEnumEntry<C4NetGameState> GameStates[] =
110  {
111  { "None", GS_None },
112  { "Init", GS_Init },
113  { "Lobby", GS_Lobby },
114  { "Paused", GS_Pause },
115  { "Running", GS_Go },
116  };
117  pComp->Value(mkNamingAdapt(mkEnumAdaptT<uint8_t>(eState, GameStates), "State", GS_None));
118  pComp->Value(mkNamingAdapt(mkIntPackAdapt(iCtrlMode), "CtrlMode", -1));
119 
120  if (!fReference)
121  pComp->Value(mkNamingAdapt(mkIntPackAdapt(iTargetCtrlTick), "TargetTick", -1));
122 }
@ GS_Pause
Definition: C4Network2.h:65
@ GS_Init
Definition: C4Network2.h:63
@ GS_Go
Definition: C4Network2.h:66
@ GS_Lobby
Definition: C4Network2.h:64
StdIntPackAdapt< T > mkIntPackAdapt(T &rVal)
Definition: StdAdaptors.h:791
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
Definition: StdAdaptors.h:795
int32_t iCtrlMode
Definition: C4Network2.h:76
void Value(const T &rStruct)
Definition: StdCompiler.h:161

References eState, GS_Go, GS_Init, GS_Lobby, GS_None, GS_Pause, iCtrlMode, iTargetCtrlTick, mkIntPackAdapt(), mkNamingAdapt(), and StdCompiler::Value().

Referenced by CompileFunc().

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

◆ getCtrlMode()

int32_t C4Network2Status::getCtrlMode ( ) const
inline

Definition at line 81 of file C4Network2.h.

81 { return iCtrlMode; }

References iCtrlMode.

Referenced by C4Network2::DrawStatus(), C4Network2::OnStatusAck(), and C4Network2::SetCtrlMode().

Here is the caller graph for this function:

◆ getDescription()

const char * C4Network2Status::getDescription ( ) const

Definition at line 69 of file C4Network2.cpp.

70 {
71  switch (eState)
72  {
73  case GS_None: return LoadResStr("IDS_DESC_NOTINITED");
74  case GS_Init: return LoadResStr("IDS_DESC_WAITFORHOST");
75  case GS_Lobby: return LoadResStr("IDS_DESC_EXPECTING");
76  case GS_Pause: return LoadResStr("IDS_DESC_GAMEPAUSED");
77  case GS_Go: return LoadResStr("IDS_DESC_GAMERUNNING");
78  }
79  return LoadResStr("IDS_DESC_UNKNOWNGAMESTATE");
80 }
const char * LoadResStr(const char *id)
Definition: C4Language.h:83

References eState, GS_Go, GS_Init, GS_Lobby, GS_None, GS_Pause, and LoadResStr().

Referenced by C4StartupNetListEntry::SetReference().

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

◆ getState()

C4NetGameState C4Network2Status::getState ( ) const
inline

◆ getStateName()

const char * C4Network2Status::getStateName ( ) const

Definition at line 56 of file C4Network2.cpp.

57 {
58  switch (eState)
59  {
60  case GS_None: return "none";
61  case GS_Init: return "init";
62  case GS_Lobby: return "lobby";
63  case GS_Pause: return "pause";
64  case GS_Go: return "go";
65  }
66  return "???";
67 }

References eState, GS_Go, GS_Init, GS_Lobby, GS_None, and GS_Pause.

Referenced by C4Network2::ChangeGameStatus(), C4Network2::DrawStatus(), C4Network2::HandleJoinData(), C4Network2::HandleStatus(), and C4Network2::OnStatusAck().

Here is the caller graph for this function:

◆ getTargetCtrlTick()

int32_t C4Network2Status::getTargetCtrlTick ( ) const
inline

Definition at line 82 of file C4Network2.h.

82 { return iTargetCtrlTick; }

References iTargetCtrlTick.

Referenced by C4Network2::CheckStatusReached(), C4Network2::DrawStatus(), C4Network2::HandleStatus(), C4Network2::HandleStatusAck(), and C4Network2::OnStatusAck().

Here is the caller graph for this function:

◆ isEnabled()

bool C4Network2Status::isEnabled ( ) const
inline

Definition at line 86 of file C4Network2.h.

86 { return eState != GS_None; }

References eState, and GS_None.

Referenced by C4Network2::isEnabled().

Here is the caller graph for this function:

◆ isLobbyActive()

bool C4Network2Status::isLobbyActive ( ) const
inline

Definition at line 87 of file C4Network2.h.

87 { return eState == GS_Lobby; }

References eState, and GS_Lobby.

Referenced by C4Network2::isLobbyActive(), and C4StartupNetListEntry::SetReference().

Here is the caller graph for this function:

◆ isPastLobby()

bool C4Network2Status::isPastLobby ( ) const
inline

Definition at line 88 of file C4Network2.h.

88 { return eState > GS_Lobby; }

References eState, and GS_Lobby.

Referenced by C4StartupNetDlg::DoOK(), C4Console::In(), C4Network2::isPastLobby(), C4TeamList::RecheckPlayerInfoTeams(), and C4StartupNetListEntry::SetReference().

Here is the caller graph for this function:

◆ isPaused()

bool C4Network2Status::isPaused ( ) const
inline

Definition at line 89 of file C4Network2.h.

89 { return eState == GS_Pause; }

References eState, and GS_Pause.

Referenced by C4Network2::isPaused(), and C4Network2::isPausing().

Here is the caller graph for this function:

◆ isRunning()

bool C4Network2Status::isRunning ( ) const
inline

Definition at line 90 of file C4Network2.h.

90 { return eState == GS_Go; }

References eState, and GS_Go.

Referenced by C4Network2::isRunning().

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:

◆ Set()

void C4Network2Status::Set ( C4NetGameState  eState,
int32_t  iTargetCtrlTick 
)

Definition at line 82 of file C4Network2.cpp.

83 {
84  eState = enState; iTargetCtrlTick = inTargetTick;
85 }

References eState, and iTargetCtrlTick.

Referenced by C4Network2::ChangeGameStatus(), and C4Network2::InitHost().

Here is the caller graph for this function:

◆ SetCtrlMode()

void C4Network2Status::SetCtrlMode ( int32_t  iCtrlMode)

Definition at line 87 of file C4Network2.cpp.

88 {
89  iCtrlMode = inCtrlMode;
90 }

References iCtrlMode.

Referenced by C4Network2::ChangeGameStatus(), and C4Network2::InitHost().

Here is the caller graph for this function:

◆ SetTargetTick()

void C4Network2Status::SetTargetTick ( int32_t  iTargetCtrlTick)

Definition at line 92 of file C4Network2.cpp.

93 {
94  iTargetCtrlTick = inTargetCtrlTick;
95 }

References iTargetCtrlTick.

Referenced by C4Network2::CheckStatusReached(), and C4Network2::UpdateChaseTarget().

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.

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

◆ eState

C4NetGameState C4Network2Status::eState {GS_None}
protected

◆ iCtrlMode

int32_t C4Network2Status::iCtrlMode
protected

Definition at line 76 of file C4Network2.h.

Referenced by CompileFunc(), getCtrlMode(), and SetCtrlMode().

◆ iTargetCtrlTick

int32_t C4Network2Status::iTargetCtrlTick {-1}
protected

Definition at line 77 of file C4Network2.h.

Referenced by Clear(), CompileFunc(), getTargetCtrlTick(), Set(), and SetTargetTick().


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