OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4ClientCore Class Reference

#include <C4Client.h>

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

Public Member Functions

 C4ClientCore ()
 
 ~C4ClientCore () override
 
int32_t getID () const
 
bool isHost () const
 
bool isActivated () const
 
bool isObserver () const
 
bool isLobbyReady () const
 
void SetID (int32_t inID)
 
void SetName (const char *sznName)
 
void SetActivated (bool fnActivated)
 
void SetObserver (bool fnObserver)
 
void SetLobbyReady (bool fnLobbyReady)
 
const char * getName () const
 
const char * getCUID () const
 
const char * getNick () const
 
const char * getRevision () const
 
bool isRegistered () const
 
void SetLocal (int32_t iID, bool fnActivated, bool fnObserver)
 
void SetUnknown (int32_t iID)
 
int32_t getDiffLevel (const C4ClientCore &CCore2) 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

int32_t iID
 
ValidatedStdCopyStrBuf
< C4InVal::VAL_NameNoEmpty
Name
 
ValidatedStdCopyStrBuf
< C4InVal::VAL_NameNoEmpty
Nick
 
ValidatedStdCopyStrBuf
< C4InVal::VAL_NameAllowEmpty
CUID
 
ValidatedStdCopyStrBuf
< C4InVal::VAL_NameAllowEmpty
Revision
 
int iVersion [4]
 
bool fActivated {false}
 
bool fObserver {false}
 
bool fLobbyReady {false}
 

Detailed Description

Definition at line 34 of file C4Client.h.

Constructor & Destructor Documentation

C4ClientCore::C4ClientCore ( )

Definition at line 31 of file C4Client.cpp.

References CUID, Name, Nick, and StdStrBuf::Ref().

32 {
33  Name.Ref(""); CUID.Ref(""); Nick.Ref("");
34 }
ValidatedStdCopyStrBuf< C4InVal::VAL_NameNoEmpty > Nick
Definition: C4Client.h:44
ValidatedStdCopyStrBuf< C4InVal::VAL_NameAllowEmpty > CUID
Definition: C4Client.h:45
void Ref(const char *pnData)
Definition: StdBuf.h:455
ValidatedStdCopyStrBuf< C4InVal::VAL_NameNoEmpty > Name
Definition: C4Client.h:44

Here is the call graph for this function:

C4ClientCore::~C4ClientCore ( )
overridedefault

Member Function Documentation

void C4ClientCore::CompileFunc ( StdCompiler pComp)
overridevirtual

Implements C4PacketBase.

Definition at line 92 of file C4Client.cpp.

References C4ClientIDUnknown, CUID, fActivated, fLobbyReady, fObserver, iID, mkNamingAdapt(), Name, Nick, Revision, and StdCompiler::Value().

93 {
94  pComp->Value(mkNamingAdapt(iID, "ID", C4ClientIDUnknown));
95  pComp->Value(mkNamingAdapt(fActivated, "Activated", false));
96  pComp->Value(mkNamingAdapt(fObserver, "Observer", false));
97  pComp->Value(mkNamingAdapt(fLobbyReady, "Ready", false));
98  pComp->Value(mkNamingAdapt(Name, "Name", ""));
99  pComp->Value(mkNamingAdapt(CUID, "CUID", ""));
100  pComp->Value(mkNamingAdapt(Nick, "Nick", ""));
101  pComp->Value(mkNamingAdapt(Revision, "Revision", ""));
102 }
bool fObserver
Definition: C4Client.h:52
int32_t iID
Definition: C4Client.h:43
ValidatedStdCopyStrBuf< C4InVal::VAL_NameAllowEmpty > Revision
Definition: C4Client.h:46
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
ValidatedStdCopyStrBuf< C4InVal::VAL_NameNoEmpty > Nick
Definition: C4Client.h:44
void Value(const T &rStruct)
Definition: StdCompiler.h:161
const int32_t C4ClientIDUnknown
Definition: C4Client.h:24
bool fActivated
Definition: C4Client.h:52
ValidatedStdCopyStrBuf< C4InVal::VAL_NameAllowEmpty > CUID
Definition: C4Client.h:45
bool fLobbyReady
Definition: C4Client.h:52
ValidatedStdCopyStrBuf< C4InVal::VAL_NameNoEmpty > Name
Definition: C4Client.h:44

Here is the call graph for this function:

const char* C4ClientCore::getCUID ( ) const
inline

Definition at line 70 of file C4Client.h.

References StdStrBuf::getData().

Referenced by C4Client::getCUID(), and getDiffLevel().

70 { return CUID.getData(); }
const char * getData() const
Definition: StdBuf.h:442
ValidatedStdCopyStrBuf< C4InVal::VAL_NameAllowEmpty > CUID
Definition: C4Client.h:45

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t C4ClientCore::getDiffLevel ( const C4ClientCore CCore2) const

Definition at line 75 of file C4Client.cpp.

References C4ClientCoreDL_Different, C4ClientCoreDL_IDChange, C4ClientCoreDL_IDMatch, C4ClientCoreDL_None, CUID, fActivated, fLobbyReady, fObserver, getCUID(), getID(), getName(), getNick(), iID, isActivated(), isLobbyReady(), isObserver(), Name, and Nick.

Referenced by C4Network2::CheckConn(), C4Network2IO::doAutoAccept(), and C4Network2IO::RemoveAutoAccept().

76 {
77  // nick & cuid won't ever be changed
78  if (CUID != CCore2.getCUID() || Nick != CCore2.getNick())
80  // identification changed?
81  if (iID != CCore2.getID() || Name != CCore2.getName())
83  // status change?
84  if (fActivated != CCore2.isActivated() || fObserver != CCore2.isObserver() || fLobbyReady != CCore2.isLobbyReady())
86  // otherwise: identical
87  return C4ClientCoreDL_None;
88 }
bool fObserver
Definition: C4Client.h:52
int32_t iID
Definition: C4Client.h:43
const int32_t C4ClientCoreDL_None
Definition: C4Client.h:29
const int32_t C4ClientCoreDL_IDMatch
Definition: C4Client.h:30
const int32_t C4ClientCoreDL_IDChange
Definition: C4Client.h:31
const char * getCUID() const
Definition: C4Client.h:70
bool isObserver() const
Definition: C4Client.h:60
bool isActivated() const
Definition: C4Client.h:59
ValidatedStdCopyStrBuf< C4InVal::VAL_NameNoEmpty > Nick
Definition: C4Client.h:44
int32_t getID() const
Definition: C4Client.h:57
bool fActivated
Definition: C4Client.h:52
ValidatedStdCopyStrBuf< C4InVal::VAL_NameAllowEmpty > CUID
Definition: C4Client.h:45
const char * getNick() const
Definition: C4Client.h:71
bool fLobbyReady
Definition: C4Client.h:52
ValidatedStdCopyStrBuf< C4InVal::VAL_NameNoEmpty > Name
Definition: C4Client.h:44
bool isLobbyReady() const
Definition: C4Client.h:61
const char * getName() const
Definition: C4Client.h:69
const int32_t C4ClientCoreDL_Different
Definition: C4Client.h:32

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t C4ClientCore::getID ( ) const
inline

Definition at line 57 of file C4Client.h.

References iID.

Referenced by C4ClientList::Add(), C4Network2::DrawStatus(), C4Network2IOConnection::getClientID(), getDiffLevel(), C4Network2Client::getID(), C4Client::getID(), C4ClientList::getLocalID(), C4Network2::HandleConn(), C4Network2IO::HandleFwdReq(), C4Network2IO::HandlePacket(), C4Network2::Join(), and C4Network2IO::SendConnPackets().

57 { return iID; }
int32_t iID
Definition: C4Client.h:43

Here is the caller graph for this function:

const char* C4ClientCore::getName ( ) const
inline

Definition at line 69 of file C4Client.h.

References StdStrBuf::getData().

Referenced by C4Network2::DrawStatus(), getDiffLevel(), C4ClientList::getLocalName(), C4Network2Client::getName(), C4Client::getName(), C4Network2::HandleConn(), and C4Network2::Join().

69 { return Name.getData(); }
const char * getData() const
Definition: StdBuf.h:442
ValidatedStdCopyStrBuf< C4InVal::VAL_NameNoEmpty > Name
Definition: C4Client.h:44

Here is the call graph for this function:

Here is the caller graph for this function:

const char* C4ClientCore::getNick ( ) const
inline

Definition at line 71 of file C4Client.h.

References StdStrBuf::getData().

Referenced by getDiffLevel(), and C4Client::getNick().

71 { return Nick.getData(); }
const char * getData() const
Definition: StdBuf.h:442
ValidatedStdCopyStrBuf< C4InVal::VAL_NameNoEmpty > Nick
Definition: C4Client.h:44

Here is the call graph for this function:

Here is the caller graph for this function:

const char* C4ClientCore::getRevision ( ) const
inline

Definition at line 72 of file C4Client.h.

References StdStrBuf::getData().

Referenced by C4Network2::Join().

72 { return Revision.getData(); }
const char * getData() const
Definition: StdBuf.h:442
ValidatedStdCopyStrBuf< C4InVal::VAL_NameAllowEmpty > Revision
Definition: C4Client.h:46

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4ClientCore::isActivated ( ) const
inline

Definition at line 59 of file C4Client.h.

References fActivated.

Referenced by C4Network2::DrawStatus(), getDiffLevel(), C4Network2Client::isActivated(), and C4Client::isActivated().

59 { return fActivated; }
bool fActivated
Definition: C4Client.h:52

Here is the caller graph for this function:

bool C4ClientCore::isHost ( ) const
inline

Definition at line 58 of file C4Client.h.

References C4ClientIDHost, and iID.

Referenced by C4Network2::DrawStatus(), C4Network2::HostConnect(), C4Client::isHost(), and C4Network2IOConnection::isHost().

58 { return iID == C4ClientIDHost; }
int32_t iID
Definition: C4Client.h:43
const int32_t C4ClientIDHost
Definition: C4Client.h:25

Here is the caller graph for this function:

bool C4ClientCore::isLobbyReady ( ) const
inline

Definition at line 61 of file C4Client.h.

References fLobbyReady.

Referenced by getDiffLevel(), and C4Client::isLobbyReady().

61 { return fLobbyReady; }
bool fLobbyReady
Definition: C4Client.h:52

Here is the caller graph for this function:

bool C4ClientCore::isObserver ( ) const
inline

Definition at line 60 of file C4Client.h.

References fObserver.

Referenced by C4Network2::DrawStatus(), getDiffLevel(), C4Network2Client::isObserver(), and C4Client::isObserver().

60 { return fObserver; }
bool fObserver
Definition: C4Client.h:52

Here is the caller graph for this function:

bool C4ClientCore::isRegistered ( ) const
inline

Definition at line 73 of file C4Client.h.

References StdStrBuf::getLength().

Referenced by C4Client::isRegistered().

73 { return CUID.getLength()>0; }
ValidatedStdCopyStrBuf< C4InVal::VAL_NameAllowEmpty > CUID
Definition: C4Client.h:45
size_t getLength() const
Definition: StdBuf.h:445

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:

void C4ClientCore::SetActivated ( bool  fnActivated)
inline

Definition at line 64 of file C4Client.h.

References fActivated, and fObserver.

Referenced by C4Network2::Join(), and C4Client::SetActivated().

64 { fActivated = fnActivated; fObserver = false; }
bool fObserver
Definition: C4Client.h:52
bool fActivated
Definition: C4Client.h:52

Here is the caller graph for this function:

void C4ClientCore::SetID ( int32_t  inID)
inline

Definition at line 62 of file C4Client.h.

References iID.

Referenced by C4Network2::InitNetIO(), C4Network2::Join(), and C4Client::SetID().

62 { iID = inID; }
int32_t iID
Definition: C4Client.h:43

Here is the caller graph for this function:

void C4ClientCore::SetLobbyReady ( bool  fnLobbyReady)
inline

Definition at line 66 of file C4Client.h.

References fLobbyReady.

Referenced by C4Client::SetLobbyReady().

66 { fLobbyReady = fnLobbyReady; }
bool fLobbyReady
Definition: C4Client.h:52

Here is the caller graph for this function:

void C4ClientCore::SetLocal ( int32_t  iID,
bool  fnActivated,
bool  fnObserver 
)

Definition at line 38 of file C4Client.cpp.

References Application, Config, StdStrBuf::Copy(), ValidatedStdCopyStrBufBase::CopyValidated(), CUID, fActivated, fObserver, C4Config::General, StdStrBuf::getLength(), C4Config::GetRegistrationData(), C4Application::GetRevision(), iID, Name, C4Config::Network, Nick, C4ConfigNetwork::Nick, C4ConfigGeneral::Participants, and Revision.

Referenced by C4ClientList::AddLocal().

39 {
40  // status
41  iID = inID;
42  fActivated = fnActivated;
43  fObserver = fnObserver;
44  // misc
48  {
50  Nick.Copy(Name);
51  }
52  else
53  {
54  const char* position = std::strchr(Config.General.Participants, ';');
55  if (!position)
56  position = Config.General.Participants + std::strlen(Config.General.Participants);
57  if (Config.General.Participants + 4 <= position && std::strncmp(position - 4, ".ocp", 4) == 0)
58  Name.CopyValidated(std::string(Config.General.Participants, position - Config.General.Participants - 4).c_str());
59  else
60  Name.Copy("empty");
61  Nick.Copy(Name);
62  }
63 }
bool fObserver
Definition: C4Client.h:52
int32_t iID
Definition: C4Client.h:43
C4Config Config
Definition: C4Config.cpp:833
C4ConfigGeneral General
Definition: C4Config.h:251
const char * GetRevision() const
Definition: C4Application.h:72
ValidatedStdCopyStrBuf< C4InVal::VAL_NameAllowEmpty > Revision
Definition: C4Client.h:46
ValidatedStdCopyStrBuf< C4InVal::VAL_NameAllowEmpty > Nick
Definition: C4Config.h:156
const char * GetRegistrationData(const char *strField)
Definition: C4Config.h:281
char Participants[CFG_MaxString+1]
Definition: C4Config.h:38
C4ConfigNetwork Network
Definition: C4Config.h:255
ValidatedStdCopyStrBuf< C4InVal::VAL_NameNoEmpty > Nick
Definition: C4Client.h:44
bool fActivated
Definition: C4Client.h:52
ValidatedStdCopyStrBuf< C4InVal::VAL_NameAllowEmpty > CUID
Definition: C4Client.h:45
ValidatedStdCopyStrBuf< C4InVal::VAL_NameNoEmpty > Name
Definition: C4Client.h:44
size_t getLength() const
Definition: StdBuf.h:445
void Copy()
Definition: StdBuf.h:467
void CopyValidated(const char *szFromVal)
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ClientCore::SetName ( const char *  sznName)
inline

Definition at line 63 of file C4Client.h.

References ValidatedStdCopyStrBufBase::CopyValidated().

Referenced by C4Network2::Join().

63 { Name.CopyValidated(sznName); }
ValidatedStdCopyStrBuf< C4InVal::VAL_NameNoEmpty > Name
Definition: C4Client.h:44
void CopyValidated(const char *szFromVal)

Here is the call graph for this function:

Here is the caller graph for this function:

void C4ClientCore::SetObserver ( bool  fnObserver)
inline

Definition at line 65 of file C4Client.h.

References fActivated, and fObserver.

Referenced by C4Network2::Join(), and C4Client::SetObserver().

65 { fActivated &= !(fObserver = fnObserver); }
bool fObserver
Definition: C4Client.h:52
bool fActivated
Definition: C4Client.h:52

Here is the caller graph for this function:

void C4ClientCore::SetUnknown ( int32_t  iID)

Definition at line 65 of file C4Client.cpp.

References CUID, fActivated, fObserver, iID, Name, Nick, StdStrBuf::Ref(), and Revision.

66 {
67  // save id
68  iID = inID;
69  // fill everything else with default values
70  Name.Ref("unknown"); CUID.Ref("unknown"); Nick.Ref("unknown");
71  Revision.Ref("unknown");
72  fActivated = fObserver = false;
73 }
bool fObserver
Definition: C4Client.h:52
int32_t iID
Definition: C4Client.h:43
ValidatedStdCopyStrBuf< C4InVal::VAL_NameAllowEmpty > Revision
Definition: C4Client.h:46
ValidatedStdCopyStrBuf< C4InVal::VAL_NameNoEmpty > Nick
Definition: C4Client.h:44
bool fActivated
Definition: C4Client.h:52
ValidatedStdCopyStrBuf< C4InVal::VAL_NameAllowEmpty > CUID
Definition: C4Client.h:45
void Ref(const char *pnData)
Definition: StdBuf.h:455
ValidatedStdCopyStrBuf< C4InVal::VAL_NameNoEmpty > Name
Definition: C4Client.h:44

Here is the call 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

ValidatedStdCopyStrBuf<C4InVal::VAL_NameAllowEmpty> C4ClientCore::CUID
protected

Definition at line 45 of file C4Client.h.

Referenced by C4ClientCore(), CompileFunc(), getDiffLevel(), SetLocal(), and SetUnknown().

bool C4ClientCore::fActivated {false}
protected
bool C4ClientCore::fLobbyReady {false}
protected

Definition at line 52 of file C4Client.h.

Referenced by CompileFunc(), getDiffLevel(), isLobbyReady(), and SetLobbyReady().

bool C4ClientCore::fObserver {false}
protected
int32_t C4ClientCore::iID
protected

Definition at line 43 of file C4Client.h.

Referenced by CompileFunc(), getDiffLevel(), getID(), isHost(), SetID(), SetLocal(), and SetUnknown().

int C4ClientCore::iVersion[4]
protected

Definition at line 49 of file C4Client.h.

ValidatedStdCopyStrBuf<C4InVal::VAL_NameNoEmpty> C4ClientCore::Name
protected

Definition at line 44 of file C4Client.h.

Referenced by C4ClientCore(), CompileFunc(), getDiffLevel(), SetLocal(), and SetUnknown().

ValidatedStdCopyStrBuf<C4InVal::VAL_NameNoEmpty> C4ClientCore::Nick
protected

Definition at line 44 of file C4Client.h.

Referenced by C4ClientCore(), CompileFunc(), getDiffLevel(), SetLocal(), and SetUnknown().

ValidatedStdCopyStrBuf<C4InVal::VAL_NameAllowEmpty> C4ClientCore::Revision
protected

Definition at line 46 of file C4Client.h.

Referenced by CompileFunc(), SetLocal(), and SetUnknown().


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