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

Definition at line 26 of file C4Extra.cpp.

27 {
28 }
C4Extra::~C4Extra ( )

Definition at line 30 of file C4Extra.cpp.

31 {
32 }

Member Function Documentation

bool C4Extra::Init ( )

Definition at line 48 of file C4Extra.cpp.

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

Referenced by C4Game::Init().

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

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Extra::InitGroup ( )

Definition at line 34 of file C4Extra.cpp.

References C4Reloc::begin(), C4CFN_Extra, DirSep, C4Reloc::end(), ExtraGroups, and Reloc.

Referenced by C4Game::PreInit().

35 {
36  // register extra root into game group set
37  for(C4Reloc::iterator iter = Reloc.begin(); iter != Reloc.end(); ++iter)
38  {
39  std::unique_ptr<C4Group> pGroup(new C4Group);
40  if(pGroup->Open( ((*iter).strBuf + DirSep + C4CFN_Extra).getData()))
41  ExtraGroups.emplace_back(std::move(pGroup));
42  }
43 
44  // done, success
45  return true;
46 }
#define C4CFN_Extra
Definition: C4Components.h:31
PathList::const_iterator iterator
Definition: C4Reloc.h:38
iterator begin() const
Definition: C4Reloc.cpp:59
C4Reloc Reloc
Definition: C4Reloc.cpp:22
iterator end() const
Definition: C4Reloc.cpp:64
std::vector< std::unique_ptr< C4Group > > ExtraGroups
Definition: C4Extra.h:32
#define DirSep

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 70 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().

71 {
72  // check if file exists
73  if (!hGroup.FindEntry(szName)) return false;
74  // log that extra group is loaded
75  LogF(LoadResStr("IDS_PRC_LOADEXTRA"), hGroup.GetName(), szName);
76  // open and add group to set
77  C4Group *pGrp = new C4Group;
78  if (!pGrp->OpenAsChild(&hGroup, szName)) { Log(LoadResStr("IDS_ERR_FAILURE")); delete pGrp; return false; }
80  // done, success
81  return true;
82 }
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:90
C4Game Game
Definition: C4Globals.cpp:52
C4GroupSet GroupSet
Definition: C4Game.h:89
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:195
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:253

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: