OpenClonk
C4Extra Class Reference

#include <C4Extra.h>

Public Member Functions

 C4Extra ()
 
 ~C4Extra ()
 
bool Init ()
 
bool InitGroup ()
 

Public Attributes

std::vector< std::unique_ptr< C4Group > > ExtraGroups
 

Protected Member Functions

bool LoadDef (C4Group &hGroup, const char *szName)
 

Detailed Description

Definition at line 23 of file C4Extra.h.

Constructor & Destructor Documentation

◆ C4Extra()

C4Extra::C4Extra ( )
default

◆ ~C4Extra()

C4Extra::~C4Extra ( )
default

Member Function Documentation

◆ Init()

bool C4Extra::Init ( )

Definition at line 41 of file C4Extra.cpp.

42 {
43  // no group: OK
44  if (ExtraGroups.empty()) return true;
45  // load from all definitions that are activated
46  // add first definition first, so the priority will be lowest
47  // (according to definition load/overload order)
48  char szSegment[_MAX_PATH_LEN];
49  for (int cseg=0; SCopySegment(Game.DefinitionFilenames,cseg,szSegment,';',_MAX_PATH); cseg++)
50  {
51  for(auto & ExtraGroup : ExtraGroups)
52  {
53  if(LoadDef(*ExtraGroup, GetFilename(szSegment)))
54  {
55  break;
56  }
57  }
58  }
59  // done, success
60  return true;
61 }
C4Game Game
Definition: C4Globals.cpp:52
#define _MAX_PATH
#define _MAX_PATH_LEN
bool SCopySegment(const char *szString, int iSegment, char *sTarget, char cSeparator, int iMaxL, bool fSkipWhitespace)
Definition: Standard.cpp:279
char * GetFilename(char *szPath)
Definition: StdFile.cpp:42
std::vector< std::unique_ptr< C4Group > > ExtraGroups
Definition: C4Extra.h:32
bool LoadDef(C4Group &hGroup, const char *szName)
Definition: C4Extra.cpp:63
char DefinitionFilenames[20 *_MAX_PATH_LEN]
Definition: C4Game.h:105

References _MAX_PATH, _MAX_PATH_LEN, C4Game::DefinitionFilenames, ExtraGroups, Game, GetFilename(), LoadDef(), and SCopySegment().

Referenced by C4Game::Init().

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

◆ InitGroup()

bool C4Extra::InitGroup ( )

Definition at line 27 of file C4Extra.cpp.

28 {
29  // register extra root into game group set
30  for(const auto & iter : Reloc)
31  {
32  std::unique_ptr<C4Group> pGroup(new C4Group);
33  if(pGroup->Open( (iter.strBuf + DirSep + C4CFN_Extra).getData()))
34  ExtraGroups.emplace_back(std::move(pGroup));
35  }
36 
37  // done, success
38  return true;
39 }
#define C4CFN_Extra
Definition: C4Components.h:31
C4Reloc Reloc
Definition: C4Reloc.cpp:21
#define DirSep

References C4CFN_Extra, DirSep, ExtraGroups, and Reloc.

Referenced by C4Game::PreInit().

Here is the caller graph for this function:

◆ LoadDef()

bool C4Extra::LoadDef ( C4Group hGroup,
const char *  szName 
)
protected

Definition at line 63 of file C4Extra.cpp.

64 {
65  // check if file exists
66  if (!hGroup.FindEntry(szName)) return false;
67  // log that extra group is loaded
68  LogF(LoadResStr("IDS_PRC_LOADEXTRA"), hGroup.GetName(), szName);
69  // open and add group to set
70  C4Group *pGrp = new C4Group;
71  if (!pGrp->OpenAsChild(&hGroup, szName)) { Log(LoadResStr("IDS_ERR_FAILURE")); delete pGrp; return false; }
73  // done, success
74  return true;
75 }
#define C4GSCnt_Extra
Definition: C4GroupSet.h:48
#define C4GSPrio_Extra
Definition: C4GroupSet.h:26
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool Log(const char *szMessage)
Definition: C4Log.cpp:204
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:262
C4GroupSet GroupSet
Definition: C4Game.h:87
const char * GetName() const
Definition: C4Group.cpp:2309
bool OpenAsChild(C4Group *mother, const char *entry_name, bool is_exclusive=false, bool do_create=false)
Definition: C4Group.cpp:1952
bool FindEntry(const char *wildcard, StdStrBuf *filename=nullptr, size_t *size=nullptr)
Definition: C4Group.cpp:2211
bool RegisterGroup(C4Group &rGroup, bool fOwnGrp, int32_t Priority, int32_t Contents, bool fCheckContent=true)
Definition: C4GroupSet.cpp:88

References C4GSCnt_Extra, C4GSPrio_Extra, C4Group::FindEntry(), Game, C4Group::GetName(), C4Game::GroupSet, LoadResStr(), Log(), LogF(), C4Group::OpenAsChild(), and C4GroupSet::RegisterGroup().

Referenced by Init().

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

Member Data Documentation

◆ ExtraGroups

std::vector<std::unique_ptr<C4Group> > C4Extra::ExtraGroups

Definition at line 32 of file C4Extra.h.

Referenced by Init(), and InitGroup().


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