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

Member Function Documentation

void C4Network2Status::Clear ( )

Definition at line 96 of file C4Network2.cpp.

References eState, GS_None, and iTargetCtrlTick.

Referenced by C4Network2::Clear().

97 {
99 }
int32_t iTargetCtrlTick
Definition: C4Network2.h:77
C4NetGameState eState
Definition: C4Network2.h:75

Here is the caller graph for this function:

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

Definition at line 106 of file C4Network2.cpp.

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

Referenced by CompileFunc().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Network2Status::CompileFunc ( StdCompiler pComp)
overridevirtual

Implements C4PacketBase.

Definition at line 101 of file C4Network2.cpp.

References CompileFunc().

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

Here is the call graph for this function:

int32_t C4Network2Status::getCtrlMode ( ) const
inline

Definition at line 81 of file C4Network2.h.

References iCtrlMode.

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

81 { return iCtrlMode; }
int32_t iCtrlMode
Definition: C4Network2.h:76

Here is the caller graph for this function:

const char * C4Network2Status::getDescription ( ) const

Definition at line 68 of file C4Network2.cpp.

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

Referenced by C4StartupNetListEntry::SetReference().

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

Here is the call graph for this function:

Here is the caller graph for this function:

C4NetGameState C4Network2Status::getState ( ) const
inline
const char * C4Network2Status::getStateName ( ) const

Definition at line 55 of file C4Network2.cpp.

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().

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

Here is the caller graph for this function:

int32_t C4Network2Status::getTargetCtrlTick ( ) const
inline

Definition at line 82 of file C4Network2.h.

References iTargetCtrlTick.

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

82 { return iTargetCtrlTick; }
int32_t iTargetCtrlTick
Definition: C4Network2.h:77

Here is the caller graph for this function:

bool C4Network2Status::isEnabled ( ) const
inline

Definition at line 86 of file C4Network2.h.

References eState, and GS_None.

Referenced by C4Network2::isEnabled().

86 { return eState != GS_None; }
C4NetGameState eState
Definition: C4Network2.h:75

Here is the caller graph for this function:

bool C4Network2Status::isLobbyActive ( ) const
inline

Definition at line 87 of file C4Network2.h.

References eState, and GS_Lobby.

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

87 { return eState == GS_Lobby; }
C4NetGameState eState
Definition: C4Network2.h:75

Here is the caller graph for this function:

bool C4Network2Status::isPastLobby ( ) const
inline

Definition at line 88 of file C4Network2.h.

References eState, and GS_Lobby.

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

88 { return eState > GS_Lobby; }
C4NetGameState eState
Definition: C4Network2.h:75

Here is the caller graph for this function:

bool C4Network2Status::isPaused ( ) const
inline

Definition at line 89 of file C4Network2.h.

References eState, and GS_Pause.

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

89 { return eState == GS_Pause; }
C4NetGameState eState
Definition: C4Network2.h:75

Here is the caller graph for this function:

bool C4Network2Status::isRunning ( ) const
inline

Definition at line 90 of file C4Network2.h.

References eState, and GS_Go.

Referenced by C4Network2::isRunning().

90 { return eState == GS_Go; }
C4NetGameState eState
Definition: C4Network2.h:75

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:

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

Definition at line 81 of file C4Network2.cpp.

References eState, and iTargetCtrlTick.

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

82 {
83  eState = enState; iTargetCtrlTick = inTargetTick;
84 }
int32_t iTargetCtrlTick
Definition: C4Network2.h:77
C4NetGameState eState
Definition: C4Network2.h:75

Here is the caller graph for this function:

void C4Network2Status::SetCtrlMode ( int32_t  iCtrlMode)

Definition at line 86 of file C4Network2.cpp.

References iCtrlMode.

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

87 {
88  iCtrlMode = inCtrlMode;
89 }
int32_t iCtrlMode
Definition: C4Network2.h:76

Here is the caller graph for this function:

void C4Network2Status::SetTargetTick ( int32_t  iTargetCtrlTick)

Definition at line 91 of file C4Network2.cpp.

References iTargetCtrlTick.

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

92 {
93  iTargetCtrlTick = inTargetCtrlTick;
94 }
int32_t iTargetCtrlTick
Definition: C4Network2.h:77

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

C4NetGameState C4Network2Status::eState {GS_None}
protected
int32_t C4Network2Status::iCtrlMode
protected

Definition at line 76 of file C4Network2.h.

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

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: