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

#include <C4DefList.h>

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

Public Types

typedef std::map< C4ID, C4Def * > Table
 

Public Member Functions

 C4DefList ()
 
 ~C4DefList () override
 
void Default ()
 
void Clear ()
 
int32_t Load (C4Group &hGroup, DWORD dwLoadWhat, const char *szLanguage, C4SoundSystem *pSoundSystem=nullptr, bool fOverload=false, bool fSearchMessage=false, int32_t iMinProgress=0, int32_t iMaxProgress=0, bool fLoadSysGroups=true)
 
int32_t Load (const char *szFilename, DWORD dwLoadWhat, const char *szLanguage, C4SoundSystem *pSoundSystem=nullptr, bool fOverload=false, int32_t iMinProgress=0, int32_t iMaxProgress=0)
 
C4DefID2Def (C4ID id)
 
C4DefGetDef (int32_t Index)
 
std::vector< C4Def * > GetAllDefs (C4String *filter_property=nullptr) const
 
C4DefGetByPath (const char *szPath)
 
C4DefGetByName (const StdStrBuf &)
 
int32_t GetDefCount ()
 
int32_t GetIndex (C4ID id)
 
int32_t RemoveTemporary ()
 
int32_t CheckEngineVersion (int32_t ver1, int32_t ver2)
 
int32_t CheckRequireDef ()
 
void Draw (C4ID id, C4Facet &cgo, bool fSelected, int32_t iColor)
 
void Remove (C4Def *def)
 
bool Remove (C4ID id)
 
bool Reload (C4Def *pDef, DWORD dwLoadWhat, const char *szLanguage, C4SoundSystem *pSoundSystem=nullptr)
 
bool Add (C4Def *ndef, bool fOverload)
 
void BuildTable ()
 
void ResetIncludeDependencies ()
 
void CallEveryDefinition ()
 
void SortByPriority ()
 
void Synchronize ()
 
void AppendAndIncludeSkeletons ()
 
StdMeshSkeletonLoaderGetSkeletonLoader ()
 
const char * GetLocalizedGroupFolderName (const char *folder_path) const
 
bool DrawFontImage (const char *szImageTag, C4Facet &rTarget, C4DrawTransform *pTransform) override
 
float GetFontImageAspect (const char *szImageTag) override
 

Public Attributes

bool LoadFailure
 
Table table
 

Protected Attributes

C4DefFirstDef
 
std::map< StdCopyStrBuf,
StdCopyStrBuf
localized_group_folder_names
 

Detailed Description

Definition at line 25 of file C4DefList.h.

Member Typedef Documentation

typedef std::map<C4ID, C4Def*> C4DefList::Table

Definition at line 32 of file C4DefList.h.

Constructor & Destructor Documentation

C4DefList::C4DefList ( )

Definition at line 42 of file c4def-handle.cpp.

References FirstDef.

43 {
44  FirstDef = nullptr;
45 }
C4Def * FirstDef
Definition: C4DefList.h:35
C4DefList::~C4DefList ( )
override

Definition at line 47 of file c4def-handle.cpp.

References Clear().

48 {
49  Clear();
50 }
void Clear()

Here is the call graph for this function:

Member Function Documentation

bool C4DefList::Add ( C4Def ndef,
bool  fOverload 
)

Definition at line 96 of file c4def-handle.cpp.

References FirstDef, C4Def::id, ID2Def(), and C4Def::Next.

Referenced by c4_mapgen_handle_set_map_library(), and Load().

97 {
98  assert(ID2Def(def->id) == nullptr);
99 
100  def->Next = FirstDef;
101  FirstDef = def;
102 
103  return true;
104 }
C4Def * ID2Def(C4ID id)
C4Def * FirstDef
Definition: C4DefList.h:35

Here is the call graph for this function:

Here is the caller graph for this function:

void C4DefList::AppendAndIncludeSkeletons ( )

Definition at line 521 of file C4DefList.cpp.

Referenced by C4Game::InitDefs(), and Reload().

522 {
523  SkeletonLoader->ResolveIncompleteSkeletons();
524 }

Here is the caller graph for this function:

void C4DefList::BuildTable ( )

Definition at line 514 of file C4DefList.cpp.

References FirstDef, C4Def::id, and C4Def::Next.

Referenced by C4Game::InitDefs(), Reload(), and RemoveTemporary().

515 {
516  table.clear();
517  for (C4Def *def = FirstDef; def; def = def->Next)
518  table.insert(std::make_pair(def->id, def));
519 }
C4Def * Next
Definition: C4Def.h:198
Definition: C4Def.h:98
C4Def * FirstDef
Definition: C4DefList.h:35
Table table
Definition: C4DefList.h:33

Here is the caller graph for this function:

void C4DefList::CallEveryDefinition ( )

Definition at line 77 of file stub-handle.cpp.

Referenced by C4AulScriptEngine::Link().

77 {}

Here is the caller graph for this function:

int32_t C4DefList::CheckEngineVersion ( int32_t  ver1,
int32_t  ver2 
)

Definition at line 365 of file C4DefList.cpp.

References CompareVersion(), FirstDef, C4Def::Next, and C4Def::rC4XVer.

Referenced by C4Game::InitDefs().

366 {
367  int32_t rcount=0;
368  C4Def *cdef,*prev,*next;
369  for (cdef=FirstDef,prev=nullptr; cdef; cdef=next)
370  {
371  next=cdef->Next;
372  if (CompareVersion(cdef->rC4XVer[0],cdef->rC4XVer[1],ver1,ver2) > 0)
373  {
374  if (prev) prev->Next=cdef->Next;
375  else FirstDef=cdef->Next;
376  delete cdef;
377  rcount++;
378  }
379  else prev=cdef;
380  }
381  return rcount;
382 }
int CompareVersion(int iVer1, int iVer2, int iRVer1=C4XVER1, int iRVer2=C4XVER2)
Definition: C4GameVersion.h:51
C4Def * Next
Definition: C4Def.h:198
Definition: C4Def.h:98
int32_t rC4XVer[2]
Definition: C4Def.h:102
C4Def * FirstDef
Definition: C4DefList.h:35

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t C4DefList::CheckRequireDef ( )

Definition at line 384 of file C4DefList.cpp.

References FirstDef, C4IDList::GetID(), GetIndex(), C4IDList::GetNumberOfIDs(), C4Def::Next, and C4Def::RequireDef.

Referenced by C4Game::InitDefs().

385 {
386  int32_t rcount=0, rcount2;
387  C4Def *cdef,*prev,*next;
388  do
389  {
390  rcount2 = rcount;
391  for (cdef=FirstDef,prev=nullptr; cdef; cdef=next)
392  {
393  next=cdef->Next;
394  for (int32_t i = 0; i < cdef->RequireDef.GetNumberOfIDs(); i++)
395  if (GetIndex(cdef->RequireDef.GetID(i)) < 0)
396  {
397  (prev ? prev->Next : FirstDef) = cdef->Next;
398  delete cdef;
399  rcount++;
400  }
401  }
402  }
403  while (rcount != rcount2);
404  return rcount;
405 }
C4Def * Next
Definition: C4Def.h:198
Definition: C4Def.h:98
C4IDList RequireDef
Definition: C4Def.h:103
int32_t GetIndex(C4ID id)
Definition: C4DefList.cpp:275
C4ID GetID(size_t index, int32_t *ipCount=nullptr) const
Definition: C4IDList.cpp:99
int32_t GetNumberOfIDs() const
Definition: C4IDList.cpp:197
C4Def * FirstDef
Definition: C4DefList.h:35

Here is the call graph for this function:

Here is the caller graph for this function:

void C4DefList::Clear ( )

Definition at line 52 of file c4def-handle.cpp.

References FirstDef, and C4Def::Next.

Referenced by c4_mapgen_handle_set_map_library(), C4Game::Clear(), and ~C4DefList().

53 {
54  while(FirstDef)
55  {
56  C4Def* out = FirstDef;
58  delete out;
59  }
60 }
C4Def * Next
Definition: C4Def.h:198
Definition: C4Def.h:98
C4Def * FirstDef
Definition: C4DefList.h:35

Here is the caller graph for this function:

void C4DefList::Default ( )

Definition at line 413 of file C4DefList.cpp.

References FirstDef, LoadFailure, and table.

Referenced by C4Game::Default().

414 {
415  FirstDef=nullptr;
416  LoadFailure=false;
417  table.clear();
418 }
bool LoadFailure
Definition: C4DefList.h:31
C4Def * FirstDef
Definition: C4DefList.h:35
Table table
Definition: C4DefList.h:33

Here is the caller graph for this function:

void C4DefList::Draw ( C4ID  id,
C4Facet cgo,
bool  fSelected,
int32_t  iColor 
)

Definition at line 407 of file C4DefList.cpp.

References C4Def::Draw(), and ID2Def().

Referenced by C4IDList::Draw().

408 {
409  C4Def *cdef = ID2Def(id);
410  if (cdef) cdef->Draw(cgo,fSelected,iColor);
411 }
C4Def * ID2Def(C4ID id)
void Draw(C4Facet &cgo, bool fSelected=false, DWORD iColor=0, C4Object *pObj=nullptr, int32_t iPhaseX=0, int32_t iPhaseY=0, C4DrawTransform *trans=nullptr, const char *graphicsName=nullptr)
Definition: C4Def.cpp:597
Definition: C4Def.h:98

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4DefList::DrawFontImage ( const char *  szImageTag,
C4Facet rTarget,
C4DrawTransform pTransform 
)
overridevirtual

Implements CStdFontCustomImages.

Definition at line 79 of file stub-handle.cpp.

79 { return false; }
std::vector< C4Def * > C4DefList::GetAllDefs ( C4String filter_property = nullptr) const

Definition at line 304 of file C4DefList.cpp.

References FirstDef, C4PropList::GetPropertyByS(), C4Def::Next, and table.

305 {
306  // Collect vector of all definitions
307  // Filter for those where property evaluates to true if filter_property!=nullptr
308  std::vector<C4Def*> result;
309  result.reserve(filter_property ? 32 : table.size());
310  C4Value prop_val;
311  for (C4Def *def = FirstDef; def; def = def->Next)
312  {
313  if (filter_property)
314  {
315  if (!def->GetPropertyByS(filter_property, &prop_val)) continue;
316  if (!prop_val) continue;
317  }
318  result.push_back(def);
319  }
320  return result;
321 }
C4Def * Next
Definition: C4Def.h:198
Definition: C4Def.h:98
C4Def * FirstDef
Definition: C4DefList.h:35
Table table
Definition: C4DefList.h:33

Here is the call graph for this function:

C4Def * C4DefList::GetByName ( const StdStrBuf name)

Definition at line 71 of file c4def-handle.cpp.

References ID2Def().

Referenced by C4ScriptHost::ResolveAppends(), and C4ScriptHost::ResolveIncludes().

72 {
73  return ID2Def(C4ID(name));
74 }
C4Def * ID2Def(C4ID id)
Definition: C4Id.h:25

Here is the call graph for this function:

Here is the caller graph for this function:

C4Def * C4DefList::GetByPath ( const char *  szPath)

Definition at line 323 of file C4DefList.cpp.

References C4Config::AtRelativePath(), Config, C4Def::Filename, FirstDef, C4Def::Next, SEqual2NoCase(), and SLen().

Referenced by C4Game::ReloadFile().

324 {
325  // search defs
326  const char *szDefPath;
327  for (C4Def *pDef = FirstDef; pDef; pDef = pDef->Next)
328  if ((szDefPath = Config.AtRelativePath(pDef->Filename)))
329  if (SEqual2NoCase(szPath, szDefPath))
330  {
331  // the definition itself?
332  if (!szPath[SLen(szDefPath)])
333  return pDef;
334  // or a component?
335  else if (szPath[SLen(szDefPath)] == '\\')
336  if (!strchr(szPath + SLen(szDefPath) + 1, '\\'))
337  return pDef;
338  }
339  // not found
340  return nullptr;
341 }
C4Config Config
Definition: C4Config.cpp:833
C4Def * Next
Definition: C4Def.h:198
size_t SLen(const char *sptr)
Definition: Standard.h:74
Definition: C4Def.h:98
bool SEqual2NoCase(const char *szStr1, const char *szStr2, int iLen)
Definition: Standard.cpp:220
const char * AtRelativePath(const char *szFilename)
Definition: C4Config.cpp:656
C4Def * FirstDef
Definition: C4DefList.h:35

Here is the call graph for this function:

Here is the caller graph for this function:

C4Def * C4DefList::GetDef ( int32_t  Index)

Definition at line 76 of file c4def-handle.cpp.

References FirstDef, and C4Def::Next.

Referenced by C4ScriptHost::ResolveAppends().

77 {
78  int counter = 0;
79  for(C4Def* cdef = FirstDef; cdef != nullptr; cdef = cdef->Next)
80  {
81  if(counter == iIndex) return cdef;
82  ++counter;
83  }
84 
85  return nullptr;
86 }
C4Def * Next
Definition: C4Def.h:198
Definition: C4Def.h:98
C4Def * FirstDef
Definition: C4DefList.h:35

Here is the caller graph for this function:

int C4DefList::GetDefCount ( )

Definition at line 88 of file c4def-handle.cpp.

References FirstDef, and C4Def::Next.

Referenced by C4ScriptHost::ResolveAppends().

89 {
90  int counter = 0;
91  for(C4Def* cdef = FirstDef; cdef != nullptr; cdef = cdef->Next)
92  ++counter;
93  return counter;
94 }
C4Def * Next
Definition: C4Def.h:198
Definition: C4Def.h:98
C4Def * FirstDef
Definition: C4DefList.h:35

Here is the caller graph for this function:

float C4DefList::GetFontImageAspect ( const char *  szImageTag)
overridevirtual

Implements CStdFontCustomImages.

Definition at line 80 of file stub-handle.cpp.

80 { return -1.0f; }
int32_t C4DefList::GetIndex ( C4ID  id)

Definition at line 275 of file C4DefList.cpp.

References FirstDef, C4Def::id, and C4Def::Next.

Referenced by CheckRequireDef().

276 {
277  C4Def *cdef;
278  int32_t cindex;
279  for (cdef=FirstDef,cindex=0; cdef; cdef=cdef->Next,cindex++)
280  if (cdef->id==id) return cindex;
281  return -1;
282 }
C4ID id
Definition: C4Def.h:101
C4Def * Next
Definition: C4Def.h:198
Definition: C4Def.h:98
C4Def * FirstDef
Definition: C4DefList.h:35

Here is the caller graph for this function:

const char * C4DefList::GetLocalizedGroupFolderName ( const char *  folder_path) const

Definition at line 531 of file C4DefList.cpp.

References localized_group_folder_names.

532 {
533  // lookup in map
534  auto iter = localized_group_folder_names.find(StdCopyStrBuf(folder_path));
535  if (iter == localized_group_folder_names.end()) return nullptr;
536  return iter->second.getData();
537 }
std::map< StdCopyStrBuf, StdCopyStrBuf > localized_group_folder_names
Definition: C4DefList.h:38
StdMeshSkeletonLoader & C4DefList::GetSkeletonLoader ( )

Definition at line 526 of file C4DefList.cpp.

527 {
528  return *SkeletonLoader;
529 }
C4Def * C4DefList::ID2Def ( C4ID  id)

Definition at line 62 of file c4def-handle.cpp.

References FirstDef, C4Def::id, and C4Def::Next.

Referenced by Add(), C4Id2Def(), C4DefGraphicsAdapt::CompileFunc(), C4Object::CompileFunc(), C4IDList::ConsolidateValids(), C4ObjectInfoCore::Default(), Draw(), C4RoundResults::EvaluateGoals(), GetByName(), C4IDList::GetCount(), C4IDList::GetID(), C4ObjectInfoList::GetIdle(), C4ObjectList::GetNameList(), C4IDList::GetNumberOfIDs(), C4Game::InitValueOverloads(), C4ObjectInfoList::New(), C4ObjectInfo::Recruit(), C4Game::ReloadDef(), C4ObjectInfo::Save(), C4IDList::SetCount(), C4ObjectInfoList::Strip(), and C4ObjectInfoCore::UpdateCustomRanks().

63 {
64  C4Def* cdef;
65  for(cdef = FirstDef; cdef != nullptr; cdef = cdef->Next)
66  if(cdef->id == id)
67  return cdef;
68  return nullptr;
69 }
C4ID id
Definition: C4Def.h:101
C4Def * Next
Definition: C4Def.h:198
Definition: C4Def.h:98
C4Def * FirstDef
Definition: C4DefList.h:35

Here is the caller graph for this function:

int32_t C4DefList::Load ( C4Group hGroup,
DWORD  dwLoadWhat,
const char *  szLanguage,
C4SoundSystem pSoundSystem = nullptr,
bool  fOverload = false,
bool  fSearchMessage = false,
int32_t  iMinProgress = 0,
int32_t  iMaxProgress = 0,
bool  fLoadSysGroups = true 
)

Definition at line 71 of file C4DefList.cpp.

References _MAX_FNAME, Add(), AltDirectorySeparator, C4CFN_DefFiles, C4CFN_Title, C4Group::Close(), Config, DirectorySeparator, C4Group::FindNextEntry(), Game, C4Config::General, GetExtension(), GetFilename(), C4Group::GetFullName(), C4ComponentHost::GetLanguageString(), C4Group::GetName(), iResult, C4ConfigGeneral::LanguageEx, C4Def::Load(), C4Game::LoadAdditionalSystemGroup(), C4Language::LoadComponentHost(), LoadResStr(), localized_group_folder_names, LogF(), C4Group::OpenAsChild(), StdStrBuf::ReplaceChar(), C4Group::ResetSearch(), SEqualNoCase(), and C4Game::SetInitProgress().

Referenced by C4Game::DropFile(), C4Game::InitDefs(), and Load().

76 {
77  int32_t iResult=0;
78  C4Def *nDef = nullptr;
79  char szEntryname[_MAX_FNAME+1];
80  C4Group hChild;
81  bool fPrimaryDef=false;
82  bool fThisSearchMessage=false;
83  bool can_be_primary_def = SEqualNoCase(GetExtension(hGroup.GetName()), "ocd");
84 
85  // This search message
86  if (fSearchMessage)
87  if (can_be_primary_def
88  || SEqualNoCase(GetExtension(hGroup.GetName()),"ocs")
89  || SEqualNoCase(GetExtension(hGroup.GetName()),"ocf"))
90  {
91  fThisSearchMessage=true;
92  fSearchMessage=false;
93  }
94 
95  if (fThisSearchMessage) { LogF("%s...",GetFilename(hGroup.GetName())); }
96 
97  // Load primary definition
98  if (can_be_primary_def)
99  {
100  if ((nDef = new C4Def))
101  {
102  if (nDef->Load(hGroup, *SkeletonLoader, dwLoadWhat, szLanguage, pSoundSystem) && Add(nDef, fOverload))
103  {
104  iResult++; fPrimaryDef = true;
105  }
106  else
107  {
108  delete nDef;
109  nDef = nullptr;
110  }
111  }
112  }
113 
114  // Remember localized name for pure definition groups
115  if (!nDef)
116  {
117  C4ComponentHost title_file;
118  StdCopyStrBuf title;
120  if (title_file.GetLanguageString(Config.General.LanguageEx, title))
121  {
122  StdCopyStrBuf group_path(hGroup.GetFullName());
124  localized_group_folder_names[group_path] = title;
125  }
126  }
127 
128  // Load sub definitions
129  int i = 0;
130  hGroup.ResetSearch();
131  while (hGroup.FindNextEntry(C4CFN_DefFiles,szEntryname))
132  if (hChild.OpenAsChild(&hGroup,szEntryname))
133  {
134  // Hack: Assume that there are sixteen sub definitions to avoid unnecessary I/O
135  int iSubMinProgress = std::min(iMaxProgress, iMinProgress + ((iMaxProgress - iMinProgress) * i) / 16);
136  int iSubMaxProgress = std::min(iMaxProgress, iMinProgress + ((iMaxProgress - iMinProgress) * (i + 1)) / 16);
137  ++i;
138  iResult += Load(hChild,dwLoadWhat,szLanguage,pSoundSystem,fOverload,fSearchMessage,iSubMinProgress,iSubMaxProgress);
139  hChild.Close();
140  }
141 
142  // load additional system scripts for def groups only
143  if (!fPrimaryDef && fLoadSysGroups) Game.LoadAdditionalSystemGroup(hGroup);
144 
145  if (fThisSearchMessage) { LogF(LoadResStr("IDS_PRC_DEFSLOADED"),iResult); }
146 
147  // progress (could go down one level of recursion...)
148  if (iMinProgress != iMaxProgress) Game.SetInitProgress(float(iMaxProgress));
149 
150  return iResult;
151 }
char * GetFilename(char *szPath)
Definition: StdFile.cpp:45
void SetInitProgress(float fToProgress)
Definition: C4Game.cpp:3385
bool Load(C4Group &hGroup, StdMeshSkeletonLoader &loader, DWORD dwLoadWhat, const char *szLanguage, class C4SoundSystem *pSoundSystem=nullptr, C4DefGraphicsPtrBackup *gfx_backup=nullptr)
C4Config Config
Definition: C4Config.cpp:833
std::map< StdCopyStrBuf, StdCopyStrBuf > localized_group_folder_names
Definition: C4DefList.h:38
C4Game Game
Definition: C4Globals.cpp:52
C4ConfigGeneral General
Definition: C4Config.h:251
bool Add(C4Def *ndef, bool fOverload)
bool SEqualNoCase(const char *szStr1, const char *szStr2, int iLen)
Definition: Standard.cpp:207
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool GetLanguageString(const char *szLanguage, StdStrBuf &rTarget)
#define AltDirectorySeparator
static bool LoadComponentHost(C4ComponentHost *host, C4Group &hGroup, const char *szFilename, const char *szLanguage)
Definition: C4Language.cpp:232
int iResult
Definition: C4GroupMain.cpp:39
#define C4CFN_Title
Definition: C4Components.h:82
const char * GetName() const
Definition: C4Group.cpp:1845
StdStrBuf GetFullName() const
Definition: C4Group.cpp:2078
Definition: C4Def.h:98
bool Close()
Definition: C4Group.cpp:755
#define _MAX_FNAME
char * GetExtension(char *szFilename)
Definition: StdFile.cpp:121
char LanguageEx[CFG_MaxString+1]
Definition: C4Config.h:37
int32_t Load(C4Group &hGroup, DWORD dwLoadWhat, const char *szLanguage, C4SoundSystem *pSoundSystem=nullptr, bool fOverload=false, bool fSearchMessage=false, int32_t iMinProgress=0, int32_t iMaxProgress=0, bool fLoadSysGroups=true)
Definition: C4DefList.cpp:71
int ReplaceChar(char cOld, char cNew)
Definition: StdBuf.cpp:336
bool FindNextEntry(const char *szWildCard, StdStrBuf *sFileName=nullptr, size_t *iSize=nullptr, bool fStartAtFilename=false)
Definition: C4Group.cpp:1780
#define C4CFN_DefFiles
Definition: C4Components.h:166
void ResetSearch(bool reload_contents=false)
Definition: C4Group.cpp:1013
bool LoadAdditionalSystemGroup(class C4Group &parent_group)
Definition: C4Game.cpp:2884
#define DirectorySeparator
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:250
bool OpenAsChild(C4Group *pMother, const char *szEntryName, bool fExclusive=false, bool fCreate=false)
Definition: C4Group.cpp:1585

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t C4DefList::Load ( const char *  szFilename,
DWORD  dwLoadWhat,
const char *  szLanguage,
C4SoundSystem pSoundSystem = nullptr,
bool  fOverload = false,
int32_t  iMinProgress = 0,
int32_t  iMaxProgress = 0 
)

Definition at line 153 of file C4DefList.cpp.

References C4Group::Close(), FormatString(), Game, Load(), LoadFailure, LoadResStr(), LogFatal(), C4Reloc::Open(), Reloc, and C4Game::SetInitProgress().

157 {
158  // Load from specified file
159  C4Group hGroup;
160  if (!Reloc.Open(hGroup, szFilename))
161  {
162  // Specified file not found (failure)
163  LogFatal(FormatString(LoadResStr("IDS_PRC_DEFNOTFOUND"), szFilename).getData());
164  LoadFailure=true;
165  return 0; // 0 definitions loaded
166  }
167  int32_t nDefs = Load(hGroup,dwLoadWhat,szLanguage,pSoundSystem,fOverload,true,iMinProgress,iMaxProgress);
168  hGroup.Close();
169 
170  // progress (could go down one level of recursion...)
171  if (iMinProgress != iMaxProgress) Game.SetInitProgress(float(iMaxProgress));
172 
173  return nDefs;
174 }
void SetInitProgress(float fToProgress)
Definition: C4Game.cpp:3385
C4Game Game
Definition: C4Globals.cpp:52
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool Close()
Definition: C4Group.cpp:755
bool Open(C4Group &hGroup, const char *filename) const
Definition: C4Reloc.cpp:82
bool LogFatal(const char *szMessage)
Definition: C4Log.cpp:227
int32_t Load(C4Group &hGroup, DWORD dwLoadWhat, const char *szLanguage, C4SoundSystem *pSoundSystem=nullptr, bool fOverload=false, bool fSearchMessage=false, int32_t iMinProgress=0, int32_t iMaxProgress=0, bool fLoadSysGroups=true)
Definition: C4DefList.cpp:71
bool LoadFailure
Definition: C4DefList.h:31
C4Reloc Reloc
Definition: C4Reloc.cpp:21
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270

Here is the call graph for this function:

bool C4DefList::Reload ( C4Def pDef,
DWORD  dwLoadWhat,
const char *  szLanguage,
C4SoundSystem pSoundSystem = nullptr 
)

Definition at line 420 of file C4DefList.cpp.

References C4DefGraphicsPtrBackup::Add(), AppendAndIncludeSkeletons(), C4DefGraphicsPtrBackup::AssignUpdate(), BuildTable(), C4Def::Clear(), C4Group::Close(), C4Def::Filename, C4Group::GetName(), C4Def::Graphics, C4Def::Load(), and C4Group::Open().

Referenced by C4Game::ReloadDef().

421 {
422  // Safety
423  if (!pDef) return false;
424  // backup graphics names and pointers
425  // GfxBackup-dtor will ensure that upon loading-failure all graphics are reset to default
426  C4DefGraphicsPtrBackup GfxBackup;
427  GfxBackup.Add(&pDef->Graphics);
428  // Clear def
429  pDef->Clear(); // Assume filename is being kept
430  // Reload def
431  C4Group hGroup;
432  if (!hGroup.Open(pDef->Filename)) return false;
433  // clear all skeletons in that group, so that deleted skeletons are also deleted in the engine
434  SkeletonLoader->RemoveSkeletonsInGroup(hGroup.GetName());
435  // load the definition
436  if (!pDef->Load(hGroup, *SkeletonLoader, dwLoadWhat, szLanguage, pSoundSystem, &GfxBackup)) return false;
437  hGroup.Close();
438  // rebuild quick access table
439  BuildTable();
440  // handle skeleton appends and includes
442  // restore graphics
443  GfxBackup.AssignUpdate();
444  // Success
445  return true;
446 }
bool Load(C4Group &hGroup, StdMeshSkeletonLoader &loader, DWORD dwLoadWhat, const char *szLanguage, class C4SoundSystem *pSoundSystem=nullptr, C4DefGraphicsPtrBackup *gfx_backup=nullptr)
void BuildTable()
Definition: C4DefList.cpp:514
void Add(C4DefGraphics *pGraphics)
void Clear()
Definition: C4Def.cpp:322
void AppendAndIncludeSkeletons()
Definition: C4DefList.cpp:521
const char * GetName() const
Definition: C4Group.cpp:1845
bool Open(const char *szGroupName, bool fCreate=false)
Definition: C4Group.cpp:514
bool Close()
Definition: C4Group.cpp:755
char Filename[_MAX_FNAME+1]
Definition: C4Def.h:176
C4DefGraphics Graphics
Definition: C4Def.h:191

Here is the call graph for this function:

Here is the caller graph for this function:

void C4DefList::Remove ( C4Def def)

Definition at line 220 of file C4DefList.cpp.

References FirstDef, and C4Def::Next.

Referenced by C4Game::ReloadDef().

221 {
222  C4Def *cdef,*prev;
223  for (cdef=FirstDef,prev=nullptr; cdef; prev=cdef,cdef=cdef->Next)
224  if (cdef==def)
225  {
226  if (prev) prev->Next=cdef->Next;
227  else FirstDef=cdef->Next;
228  delete cdef;
229  return;
230  }
231 }
C4Def * Next
Definition: C4Def.h:198
Definition: C4Def.h:98
C4Def * FirstDef
Definition: C4DefList.h:35

Here is the caller graph for this function:

bool C4DefList::Remove ( C4ID  id)

Definition at line 206 of file C4DefList.cpp.

References FirstDef, and C4Def::Next.

207 {
208  C4Def *cdef,*prev;
209  for (cdef=FirstDef,prev=nullptr; cdef; prev=cdef,cdef=cdef->Next)
210  if (cdef->id==id)
211  {
212  if (prev) prev->Next=cdef->Next;
213  else FirstDef=cdef->Next;
214  delete cdef;
215  return true;
216  }
217  return false;
218 }
C4Def * Next
Definition: C4Def.h:198
Definition: C4Def.h:98
C4Def * FirstDef
Definition: C4DefList.h:35
int32_t C4DefList::RemoveTemporary ( )

Definition at line 343 of file C4DefList.cpp.

References BuildTable(), FirstDef, C4Def::Next, and C4Def::Temporary.

344 {
345  C4Def *cdef,*prev,*next;
346  int32_t removed=0;
347  for (cdef=FirstDef,prev=nullptr; cdef; cdef=next)
348  {
349  next=cdef->Next;
350  if (cdef->Temporary)
351  {
352  if (prev) prev->Next=next;
353  else FirstDef=next;
354  delete cdef;
355  removed++;
356  }
357  else
358  prev=cdef;
359  }
360  // rebuild quick access table
361  BuildTable();
362  return removed;
363 }
void BuildTable()
Definition: C4DefList.cpp:514
C4Def * Next
Definition: C4Def.h:198
bool Temporary
Definition: C4Def.h:199
Definition: C4Def.h:98
C4Def * FirstDef
Definition: C4DefList.h:35

Here is the call graph for this function:

void C4DefList::ResetIncludeDependencies ( )

Definition at line 78 of file stub-handle.cpp.

Referenced by C4AulScriptEngine::ReLink().

78 {}

Here is the caller graph for this function:

void C4DefList::SortByPriority ( )

Definition at line 76 of file stub-handle.cpp.

Referenced by C4AulScriptEngine::Link().

76 {}

Here is the caller graph for this function:

void C4DefList::Synchronize ( )

Definition at line 458 of file C4DefList.cpp.

References table.

Referenced by C4Game::Synchronize().

459 {
460  for (auto & it : table)
461  it.second->Synchronize();
462 }
Table table
Definition: C4DefList.h:33

Here is the caller graph for this function:

Member Data Documentation

bool C4DefList::LoadFailure

Definition at line 31 of file C4DefList.h.

Referenced by Default(), C4Game::InitDefs(), and Load().

std::map<StdCopyStrBuf, StdCopyStrBuf> C4DefList::localized_group_folder_names
protected

Definition at line 38 of file C4DefList.h.

Referenced by GetLocalizedGroupFolderName(), and Load().

Table C4DefList::table

Definition at line 33 of file C4DefList.h.

Referenced by C4DefGraphicsPtrBackup::AssignUpdate(), Default(), GetAllDefs(), and Synchronize().


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