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

#include <C4Network2Res.h>

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

Public Member Functions

 C4Network2ResCore ()
 
C4Network2ResType getType () const
 
bool isNull () const
 
int32_t getID () const
 
int32_t getDerID () const
 
bool isLoadable () const
 
uint32_t getFileSize () const
 
uint32_t getFileCRC () const
 
uint32_t getContentsCRC () const
 
bool hasFileSHA () const
 
const uint8_t * getFileSHA () const
 
const char * getFileName () const
 
uint32_t getChunkSize () const
 
uint32_t getChunkCnt () const
 
void Set (C4Network2ResType eType, int32_t iResID, const char *strFileName, uint32_t iContentsCRC)
 
void SetID (int32_t inID)
 
void SetDerived (int32_t inDerID)
 
void SetLoadable (uint32_t iSize, uint32_t iCRC)
 
void SetFileSHA (BYTE *pSHA)
 
void Clear ()
 
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

C4Network2ResType eType
 
int32_t iID
 
int32_t iDerID
 
StdCopyStrBuf FileName
 
bool fLoadable
 
uint32_t iFileSize
 
uint32_t iFileCRC
 
uint32_t iContentsCRC
 
uint8_t fHasFileSHA
 
uint8_t FileSHA [SHA_DIGEST_LENGTH]
 
uint32_t iChunkSize
 

Detailed Description

Definition at line 68 of file C4Network2Res.h.

Constructor & Destructor Documentation

C4Network2ResCore::C4Network2ResCore ( )

Definition at line 79 of file C4Network2Res.cpp.

80  : eType(NRT_Null),
81  iID(-1), iDerID(-1),
82  fLoadable(false),
83  iFileSize(~0u), iFileCRC(~0u), iContentsCRC(~0u),
84  fHasFileSHA(false),
86 {
87 }
uint32_t iContentsCRC
Definition: C4Network2Res.h:78
C4Network2ResType eType
Definition: C4Network2Res.h:74
const uint32_t C4NetResChunkSize
Definition: C4Network2Res.h:28

Member Function Documentation

void C4Network2ResCore::Clear ( )

Definition at line 106 of file C4Network2Res.cpp.

References StdStrBuf::Clear(), eType, fHasFileSHA, FileName, fLoadable, iContentsCRC, iDerID, iFileCRC, iFileSize, iID, and NRT_Null.

Referenced by C4PlayerInfo::Clear(), C4Network2Res::Clear(), C4PlayerInfo::DiscardResource(), and C4Network2::RemoveDynamic().

107 {
108  eType = NRT_Null;
109  iID = iDerID = -1;
110  fLoadable = false;
111  FileName.Clear();
113  fHasFileSHA = false;
114 }
StdCopyStrBuf FileName
Definition: C4Network2Res.h:76
uint32_t iContentsCRC
Definition: C4Network2Res.h:78
void Clear()
Definition: StdBuf.h:474
C4Network2ResType eType
Definition: C4Network2Res.h:74

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Network2ResCore::CompileFunc ( StdCompiler pComp)
virtual

Implements C4PacketBase.

Definition at line 118 of file C4Network2Res.cpp.

References C4NetResChunkSize, C4Network2ResType_EnumMap, eType, StdCompiler::excCorrupt(), fHasFileSHA, FileName, FileSHA, fLoadable, iChunkSize, iContentsCRC, iDerID, iFileCRC, iFileSize, iID, mkHexAdapt(), mkNamingAdapt(), mkNamingCountAdapt(), mkNetFilenameAdapt(), NRT_Null, and StdCompiler::Value().

119 {
120  pComp->Value(mkNamingAdapt(mkEnumAdaptT<uint8_t>(eType, C4Network2ResType_EnumMap), "Type", NRT_Null));
121  pComp->Value(mkNamingAdapt(iID, "ID", -1));
122  pComp->Value(mkNamingAdapt(iDerID, "DerID", -1));
123  pComp->Value(mkNamingAdapt(fLoadable, "Loadable", true));
124  if (fLoadable)
125  {
126  pComp->Value(mkNamingAdapt(iFileSize, "FileSize", 0U));
127  pComp->Value(mkNamingAdapt(iFileCRC, "FileCRC", 0U));
128  pComp->Value(mkNamingAdapt(iChunkSize, "ChunkSize", C4NetResChunkSize));
129  if (!iChunkSize) pComp->excCorrupt("zero chunk size");
130  }
131  pComp->Value(mkNamingAdapt(iContentsCRC, "ContentsCRC", 0U));
132  pComp->Value(mkNamingCountAdapt(fHasFileSHA, "FileSHA"));
133  if (fHasFileSHA)
134  pComp->Value(mkNamingAdapt(mkHexAdapt(FileSHA), "FileSHA"));
135  pComp->Value(mkNamingAdapt(mkNetFilenameAdapt(FileName), "Filename", ""));
136 }
StdNamingCountAdapt< int_t > mkNamingCountAdapt(int_t &iCount, const char *szName)
Definition: StdAdaptors.h:974
StdCopyStrBuf FileName
Definition: C4Network2Res.h:76
uint32_t iContentsCRC
Definition: C4Network2Res.h:78
void excCorrupt(const char *szMessage,...)
Definition: StdCompiler.h:259
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
uint8_t FileSHA[SHA_DIGEST_LENGTH]
Definition: C4Network2Res.h:80
void Value(const T &rStruct)
Definition: StdCompiler.h:171
StdHexAdapt mkHexAdapt(void *pData, size_t iSize)
Definition: StdAdaptors.h:1003
C4Network2ResType eType
Definition: C4Network2Res.h:74
C4NetFilenameAdapt mkNetFilenameAdapt(StdStrBuf &FileName)
Definition: C4PacketBase.h:73
const StdEnumEntry< C4Network2ResType > C4Network2ResType_EnumMap[]
Definition: C4Network2Res.h:51
const uint32_t C4NetResChunkSize
Definition: C4Network2Res.h:28

Here is the call graph for this function:

uint32_t C4Network2ResCore::getChunkCnt ( ) const
inline

Definition at line 96 of file C4Network2Res.h.

Referenced by C4Network2Res::FinishDerive(), C4Network2Res::GetStandalone(), C4Network2Res::SendChunk(), C4Network2Res::SetLoad(), and C4Network2Res::StartLoad().

96 { return iFileSize && iChunkSize ? (iFileSize - 1) / iChunkSize + 1 : 0; }

Here is the caller graph for this function:

uint32_t C4Network2ResCore::getChunkSize ( ) const
inline

Definition at line 95 of file C4Network2Res.h.

References iChunkSize.

Referenced by C4Network2ResChunk::AddTo(), and C4Network2ResChunk::Set().

95 { return iChunkSize; }

Here is the caller graph for this function:

uint32_t C4Network2ResCore::getContentsCRC ( ) const
inline

Definition at line 91 of file C4Network2Res.h.

References iContentsCRC.

Referenced by C4Network2Res::SetByCore().

91 { return iContentsCRC; }
uint32_t iContentsCRC
Definition: C4Network2Res.h:78

Here is the caller graph for this function:

int32_t C4Network2ResCore::getDerID ( ) const
inline

Definition at line 87 of file C4Network2Res.h.

References iDerID.

Referenced by C4Network2Res::FinishDerive().

87 { return iDerID; }

Here is the caller graph for this function:

uint32_t C4Network2ResCore::getFileCRC ( ) const
inline

Definition at line 90 of file C4Network2Res.h.

References iFileCRC.

Referenced by C4Network2Res::GetStandalone().

90 { return iFileCRC; }

Here is the caller graph for this function:

const char* C4Network2ResCore::getFileName ( ) const
inline

Definition at line 94 of file C4Network2Res.h.

References StdStrBuf::getData().

Referenced by C4Network2ResList::AddByCore(), C4Network2ResList::AddLoad(), C4Network2ResChunk::AddTo(), C4Network2Res::Derive(), C4Network2Res::FinishDerive(), C4GameRes::InitNetwork(), C4Network2Res::OnChunk(), C4Network2ResList::OnResComplete(), C4ControlJoinPlayer::PreRec(), C4GameResList::RetrieveFiles(), C4Network2::RetrieveRes(), C4Network2Res::SetByCore(), C4Network2Res::SetLoad(), and C4Network2Res::StartLoad().

94 { return FileName.getData(); }
const char * getData() const
Definition: StdBuf.h:450
StdCopyStrBuf FileName
Definition: C4Network2Res.h:76

Here is the call graph for this function:

Here is the caller graph for this function:

const uint8_t* C4Network2ResCore::getFileSHA ( ) const
inline

Definition at line 93 of file C4Network2Res.h.

References FileSHA.

93 { return FileSHA; }
uint8_t FileSHA[SHA_DIGEST_LENGTH]
Definition: C4Network2Res.h:80
uint32_t C4Network2ResCore::getFileSize ( ) const
inline

Definition at line 89 of file C4Network2Res.h.

References iFileSize.

Referenced by C4Network2ResChunk::AddTo(), C4Network2Res::GetStandalone(), and C4Network2ResChunk::Set().

89 { return iFileSize; }

Here is the caller graph for this function:

int32_t C4Network2ResCore::getID ( ) const
inline
C4Network2ResType C4Network2ResCore::getType ( ) const
inline

Definition at line 84 of file C4Network2Res.h.

References eType.

Referenced by C4GameRes::CompileFunc(), C4Network2Res::getType(), C4GameRes::InitNetwork(), C4Network2Res::OptimizeStandalone(), C4Network2Res::SetByCore(), and C4GameRes::SetResCore().

84 { return eType; }
C4Network2ResType eType
Definition: C4Network2Res.h:74

Here is the caller graph for this function:

bool C4Network2ResCore::hasFileSHA ( ) const
inline

Definition at line 92 of file C4Network2Res.h.

References fHasFileSHA.

Referenced by C4Network2Res::CalculateSHA().

92 { return !!fHasFileSHA; }

Here is the caller graph for this function:

bool C4Network2ResCore::isLoadable ( ) const
inline

Definition at line 88 of file C4Network2Res.h.

References fLoadable.

Referenced by C4Network2ResList::AddByCore(), C4Network2ResList::AddLoad(), C4Network2Res::GetStandalone(), C4GameRes::InitNetwork(), and C4Network2Res::SetLoad().

88 { return fLoadable; }

Here is the caller graph for this function:

bool C4Network2ResCore::isNull ( ) const
inline

Definition at line 85 of file C4Network2Res.h.

References NRT_Null.

Referenced by C4Network2::Execute(), C4Network2::RetrieveRes(), and C4Network2::SendJoinData().

85 { return eType == NRT_Null; }
C4Network2ResType eType
Definition: C4Network2Res.h:74

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:

void C4Network2ResCore::Set ( C4Network2ResType  eType,
int32_t  iResID,
const char *  strFileName,
uint32_t  iContentsCRC 
)

Definition at line 89 of file C4Network2Res.cpp.

References C4NetResChunkSize, StdStrBuf::Copy(), eType, FileName, fLoadable, iChunkSize, iContentsCRC, iDerID, iFileCRC, iFileSize, and iID.

Referenced by C4Network2Res::SetByFile(), C4Network2Res::SetByGroup(), and C4Network2Res::SetDerived().

90 {
91  // Initialize base data
92  eType = enType; iID = iResID; iDerID = -1;
93  fLoadable = false;
94  iFileSize = iFileCRC = ~0; iContentsCRC = inContentsCRC;
96  FileName.Copy(strFileName);
97 }
StdCopyStrBuf FileName
Definition: C4Network2Res.h:76
uint32_t iContentsCRC
Definition: C4Network2Res.h:78
C4Network2ResType eType
Definition: C4Network2Res.h:74
void Copy()
Definition: StdBuf.h:475
const uint32_t C4NetResChunkSize
Definition: C4Network2Res.h:28

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Network2ResCore::SetDerived ( int32_t  inDerID)
inline

Definition at line 100 of file C4Network2Res.h.

Referenced by C4Network2Res::FinishDerive(), and C4Network2Res::SetDerived().

100 { iDerID = inDerID; }

Here is the caller graph for this function:

void C4Network2ResCore::SetFileSHA ( BYTE pSHA)
inline

Definition at line 102 of file C4Network2Res.h.

References SHA_DIGEST_LENGTH.

Referenced by C4Network2Res::CalculateSHA().

102 { memcpy(FileSHA, pSHA, SHA_DIGEST_LENGTH); fHasFileSHA = true; }
#define SHA_DIGEST_LENGTH
uint8_t FileSHA[SHA_DIGEST_LENGTH]
Definition: C4Network2Res.h:80

Here is the caller graph for this function:

void C4Network2ResCore::SetID ( int32_t  inID)
inline

Definition at line 99 of file C4Network2Res.h.

Referenced by C4Network2Res::ChangeID().

99 { iID = inID; }

Here is the caller graph for this function:

void C4Network2ResCore::SetLoadable ( uint32_t  iSize,
uint32_t  iCRC 
)

Definition at line 99 of file C4Network2Res.cpp.

References fLoadable, iFileCRC, iFileSize, and iSize.

Referenced by C4Network2Res::GetStandalone().

100 {
101  fLoadable = true;
102  iFileSize = iSize;
103  iFileCRC = iCRC;
104 }
int iSize
Definition: TstC4NetIO.cpp:35

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

C4Network2ResType C4Network2ResCore::eType
protected

Definition at line 74 of file C4Network2Res.h.

Referenced by Clear(), CompileFunc(), getType(), and Set().

uint8_t C4Network2ResCore::fHasFileSHA
protected

Definition at line 79 of file C4Network2Res.h.

Referenced by Clear(), CompileFunc(), and hasFileSHA().

StdCopyStrBuf C4Network2ResCore::FileName
protected

Definition at line 76 of file C4Network2Res.h.

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

uint8_t C4Network2ResCore::FileSHA[SHA_DIGEST_LENGTH]
protected

Definition at line 80 of file C4Network2Res.h.

Referenced by CompileFunc(), and getFileSHA().

bool C4Network2ResCore::fLoadable
protected

Definition at line 77 of file C4Network2Res.h.

Referenced by Clear(), CompileFunc(), isLoadable(), Set(), and SetLoadable().

uint32_t C4Network2ResCore::iChunkSize
protected

Definition at line 81 of file C4Network2Res.h.

Referenced by CompileFunc(), getChunkSize(), and Set().

uint32_t C4Network2ResCore::iContentsCRC
protected

Definition at line 78 of file C4Network2Res.h.

Referenced by Clear(), CompileFunc(), getContentsCRC(), and Set().

int32_t C4Network2ResCore::iDerID
protected

Definition at line 75 of file C4Network2Res.h.

Referenced by Clear(), CompileFunc(), getDerID(), and Set().

uint32_t C4Network2ResCore::iFileCRC
protected

Definition at line 78 of file C4Network2Res.h.

Referenced by Clear(), CompileFunc(), getFileCRC(), Set(), and SetLoadable().

uint32_t C4Network2ResCore::iFileSize
protected

Definition at line 78 of file C4Network2Res.h.

Referenced by Clear(), CompileFunc(), getFileSize(), Set(), and SetLoadable().

int32_t C4Network2ResCore::iID
protected

Definition at line 75 of file C4Network2Res.h.

Referenced by Clear(), CompileFunc(), getID(), and Set().


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