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

Member Function Documentation

bool C4Extra::Init ( )

Definition at line 41 of file C4Extra.cpp.

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

Referenced by C4Game::Init().

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+1];
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 }
char * GetFilename(char *szPath)
Definition: StdFile.cpp:45
C4Game Game
Definition: C4Globals.cpp:52
bool SCopySegment(const char *szString, int iSegment, char *sTarget, char cSeparator, int iMaxL, bool fSkipWhitespace)
Definition: Standard.cpp:273
#define _MAX_PATH
char DefinitionFilenames[20 *_MAX_PATH+1]
Definition: C4Game.h:105
std::vector< std::unique_ptr< C4Group > > ExtraGroups
Definition: C4Extra.h:32
bool LoadDef(C4Group &hGroup, const char *szName)
Definition: C4Extra.cpp:63

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Extra::InitGroup ( )

Definition at line 27 of file C4Extra.cpp.

References C4CFN_Extra, DirSep, ExtraGroups, and Reloc.

Referenced by C4Game::PreInit().

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
std::vector< std::unique_ptr< C4Group > > ExtraGroups
Definition: C4Extra.h:32
#define DirSep

Here is the caller graph for this function:

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

Definition at line 63 of file C4Extra.cpp.

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

Referenced by Init().

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 }
bool FindEntry(const char *szWildCard, StdStrBuf *sFileName=nullptr, size_t *iSize=nullptr)
Definition: C4Group.cpp:1774
#define C4GSCnt_Extra
Definition: C4GroupSet.h:48
bool RegisterGroup(C4Group &rGroup, bool fOwnGrp, int32_t Priority, int32_t Contents, bool fCheckContent=true)
Definition: C4GroupSet.cpp:88
C4Game Game
Definition: C4Globals.cpp:52
C4GroupSet GroupSet
Definition: C4Game.h:87
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
const char * GetName() const
Definition: C4Group.cpp:1845
#define C4GSPrio_Extra
Definition: C4GroupSet.h:26
bool Log(const char *szMessage)
Definition: C4Log.cpp:192
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:250

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

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: