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

C4Network2ResType eType {NRT_Null}
 
int32_t iID {-1}
 
int32_t iDerID {-1}
 
StdCopyStrBuf FileName
 
bool fLoadable {false}
 
uint32_t iFileSize
 
uint32_t iFileCRC
 
uint32_t iContentsCRC
 
uint8_t fHasFileSHA {false}
 
uint8_t FileSHA [SHA_DIGEST_LENGTH]
 
uint32_t iChunkSize
 

Detailed Description

Definition at line 68 of file C4Network2Res.h.

Constructor & Destructor Documentation

◆ C4Network2ResCore()

C4Network2ResCore::C4Network2ResCore ( )

Definition at line 74 of file C4Network2Res.cpp.

75  : iFileSize(~0u), iFileCRC(~0u), iContentsCRC(~0u),
77 {
78 }
const uint32_t C4NetResChunkSize
Definition: C4Network2Res.h:28
uint32_t iContentsCRC
Definition: C4Network2Res.h:78

Member Function Documentation

◆ Clear()

void C4Network2ResCore::Clear ( )

Definition at line 97 of file C4Network2Res.cpp.

98 {
99  eType = NRT_Null;
100  iID = iDerID = -1;
101  fLoadable = false;
102  FileName.Clear();
103  iFileSize = iFileCRC = iContentsCRC = ~0u;
104  fHasFileSHA = false;
105 }
@ NRT_Null
Definition: C4Network2Res.h:42
StdCopyStrBuf FileName
Definition: C4Network2Res.h:76
C4Network2ResType eType
Definition: C4Network2Res.h:74
void Clear()
Definition: StdBuf.h:466

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

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

◆ CompileFunc()

void C4Network2ResCore::CompileFunc ( StdCompiler pComp)
overridevirtual

Implements C4PacketBase.

Definition at line 109 of file C4Network2Res.cpp.

110 {
111  pComp->Value(mkNamingAdapt(mkEnumAdaptT<uint8_t>(eType, C4Network2ResType_EnumMap), "Type", NRT_Null));
112  pComp->Value(mkNamingAdapt(iID, "ID", -1));
113  pComp->Value(mkNamingAdapt(iDerID, "DerID", -1));
114  pComp->Value(mkNamingAdapt(fLoadable, "Loadable", true));
115  if (fLoadable)
116  {
117  pComp->Value(mkNamingAdapt(iFileSize, "FileSize", 0U));
118  pComp->Value(mkNamingAdapt(iFileCRC, "FileCRC", 0U));
119  pComp->Value(mkNamingAdapt(iChunkSize, "ChunkSize", C4NetResChunkSize));
120  if (!iChunkSize) pComp->excCorrupt("zero chunk size");
121  }
122  pComp->Value(mkNamingAdapt(iContentsCRC, "ContentsCRC", 0U));
123  pComp->Value(mkNamingCountAdapt(fHasFileSHA, "FileSHA"));
124  if (fHasFileSHA)
125  pComp->Value(mkNamingAdapt(mkHexAdapt(FileSHA), "FileSHA"));
126  pComp->Value(mkNamingAdapt(mkNetFilenameAdapt(FileName), "Filename", ""));
127 }
const StdEnumEntry< C4Network2ResType > C4Network2ResType_EnumMap[]
Definition: C4Network2Res.h:51
C4NetFilenameAdapt mkNetFilenameAdapt(StdStrBuf &FileName)
Definition: C4PacketBase.h:73
StdNamingCountAdapt< int_t > mkNamingCountAdapt(int_t &iCount, const char *szName)
Definition: StdAdaptors.h:1008
StdHexAdapt mkHexAdapt(void *pData, size_t iSize)
Definition: StdAdaptors.h:1037
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
uint8_t FileSHA[SHA_DIGEST_LENGTH]
Definition: C4Network2Res.h:80
void excCorrupt(const char *szMessage,...)
Definition: StdCompiler.h:249
void Value(const T &rStruct)
Definition: StdCompiler.h:161

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

Here is the call graph for this function:

◆ getChunkCnt()

uint32_t C4Network2ResCore::getChunkCnt ( ) const
inline

Definition at line 96 of file C4Network2Res.h.

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

References iChunkSize, and iFileSize.

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

Here is the caller graph for this function:

◆ getChunkSize()

uint32_t C4Network2ResCore::getChunkSize ( ) const
inline

Definition at line 95 of file C4Network2Res.h.

95 { return iChunkSize; }

References iChunkSize.

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

Here is the caller graph for this function:

◆ getContentsCRC()

uint32_t C4Network2ResCore::getContentsCRC ( ) const
inline

Definition at line 91 of file C4Network2Res.h.

91 { return iContentsCRC; }

References iContentsCRC.

Referenced by C4Network2Res::SetByCore().

Here is the caller graph for this function:

◆ getDerID()

int32_t C4Network2ResCore::getDerID ( ) const
inline

Definition at line 87 of file C4Network2Res.h.

87 { return iDerID; }

References iDerID.

Referenced by C4Network2Res::FinishDerive().

Here is the caller graph for this function:

◆ getFileCRC()

uint32_t C4Network2ResCore::getFileCRC ( ) const
inline

Definition at line 90 of file C4Network2Res.h.

90 { return iFileCRC; }

References iFileCRC.

Referenced by C4Network2Res::GetStandalone().

Here is the caller graph for this function:

◆ getFileName()

const char* C4Network2ResCore::getFileName ( ) const
inline

Definition at line 94 of file C4Network2Res.h.

94 { return FileName.getData(); }
const char * getData() const
Definition: StdBuf.h:442

References FileName, and 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().

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

◆ getFileSHA()

const uint8_t* C4Network2ResCore::getFileSHA ( ) const
inline

Definition at line 93 of file C4Network2Res.h.

93 { return FileSHA; }

References FileSHA.

◆ getFileSize()

uint32_t C4Network2ResCore::getFileSize ( ) const
inline

Definition at line 89 of file C4Network2Res.h.

89 { return iFileSize; }

References iFileSize.

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

Here is the caller graph for this function:

◆ getID()

int32_t C4Network2ResCore::getID ( ) const
inline

◆ getType()

C4Network2ResType C4Network2ResCore::getType ( ) const
inline

Definition at line 84 of file C4Network2Res.h.

84 { return eType; }

References eType.

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

Here is the caller graph for this function:

◆ hasFileSHA()

bool C4Network2ResCore::hasFileSHA ( ) const
inline

Definition at line 92 of file C4Network2Res.h.

92 { return !!fHasFileSHA; }

References fHasFileSHA.

Referenced by C4Network2Res::CalculateSHA().

Here is the caller graph for this function:

◆ isLoadable()

bool C4Network2ResCore::isLoadable ( ) const
inline

Definition at line 88 of file C4Network2Res.h.

88 { return fLoadable; }

References fLoadable.

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

Here is the caller graph for this function:

◆ isNull()

bool C4Network2ResCore::isNull ( ) const
inline

Definition at line 85 of file C4Network2Res.h.

85 { return eType == NRT_Null; }

References eType, and NRT_Null.

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

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 C4Network2ResCore::Set ( C4Network2ResType  eType,
int32_t  iResID,
const char *  strFileName,
uint32_t  iContentsCRC 
)

Definition at line 80 of file C4Network2Res.cpp.

81 {
82  // Initialize base data
83  eType = enType; iID = iResID; iDerID = -1;
84  fLoadable = false;
85  iFileSize = iFileCRC = ~0; iContentsCRC = inContentsCRC;
87  FileName.Copy(strFileName);
88 }
void Copy()
Definition: StdBuf.h:467

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

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

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

◆ SetDerived()

void C4Network2ResCore::SetDerived ( int32_t  inDerID)
inline

Definition at line 100 of file C4Network2Res.h.

100 { iDerID = inDerID; }

References iDerID.

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

Here is the caller graph for this function:

◆ SetFileSHA()

void C4Network2ResCore::SetFileSHA ( BYTE pSHA)
inline

Definition at line 102 of file C4Network2Res.h.

102 { memcpy(FileSHA, pSHA, SHA_DIGEST_LENGTH); fHasFileSHA = true; }
#define SHA_DIGEST_LENGTH
Definition: SHA1.h:42

References fHasFileSHA, FileSHA, and SHA_DIGEST_LENGTH.

Referenced by C4Network2Res::CalculateSHA().

Here is the caller graph for this function:

◆ SetID()

void C4Network2ResCore::SetID ( int32_t  inID)
inline

Definition at line 99 of file C4Network2Res.h.

99 { iID = inID; }

References iID.

Referenced by C4Network2Res::ChangeID().

Here is the caller graph for this function:

◆ SetLoadable()

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

Definition at line 90 of file C4Network2Res.cpp.

91 {
92  fLoadable = true;
93  iFileSize = iSize;
94  iFileCRC = iCRC;
95 }
int iSize
Definition: TstC4NetIO.cpp:32

References fLoadable, iFileCRC, iFileSize, and iSize.

Referenced by C4Network2Res::GetStandalone().

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

◆ eType

C4Network2ResType C4Network2ResCore::eType {NRT_Null}
protected

Definition at line 74 of file C4Network2Res.h.

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

◆ fHasFileSHA

uint8_t C4Network2ResCore::fHasFileSHA {false}
protected

Definition at line 79 of file C4Network2Res.h.

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

◆ FileName

StdCopyStrBuf C4Network2ResCore::FileName
protected

Definition at line 76 of file C4Network2Res.h.

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

◆ FileSHA

uint8_t C4Network2ResCore::FileSHA[SHA_DIGEST_LENGTH]
protected

Definition at line 80 of file C4Network2Res.h.

Referenced by CompileFunc(), getFileSHA(), and SetFileSHA().

◆ fLoadable

bool C4Network2ResCore::fLoadable {false}
protected

Definition at line 77 of file C4Network2Res.h.

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

◆ iChunkSize

uint32_t C4Network2ResCore::iChunkSize
protected

Definition at line 81 of file C4Network2Res.h.

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

◆ iContentsCRC

uint32_t C4Network2ResCore::iContentsCRC
protected

Definition at line 78 of file C4Network2Res.h.

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

◆ iDerID

int32_t C4Network2ResCore::iDerID {-1}
protected

Definition at line 75 of file C4Network2Res.h.

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

◆ iFileCRC

uint32_t C4Network2ResCore::iFileCRC
protected

Definition at line 78 of file C4Network2Res.h.

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

◆ iFileSize

uint32_t C4Network2ResCore::iFileSize
protected

Definition at line 78 of file C4Network2Res.h.

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

◆ iID

int32_t C4Network2ResCore::iID {-1}
protected

Definition at line 75 of file C4Network2Res.h.

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


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