OpenClonk
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, StdCopyStrBuflocalized_group_folder_names
 

Detailed Description

Definition at line 25 of file C4DefList.h.

Member Typedef Documentation

◆ Table

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

Definition at line 32 of file C4DefList.h.

Constructor & Destructor Documentation

◆ C4DefList()

C4DefList::C4DefList ( )

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

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

References FirstDef.

◆ ~C4DefList()

C4DefList::~C4DefList ( )
override

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

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

References Clear().

Here is the call graph for this function:

Member Function Documentation

◆ Add()

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

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

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

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

Referenced by c4_mapgen_handle_set_map_library(), and Load().

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

◆ AppendAndIncludeSkeletons()

void C4DefList::AppendAndIncludeSkeletons ( )

Definition at line 521 of file C4DefList.cpp.

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

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

Here is the caller graph for this function:

◆ BuildTable()

void C4DefList::BuildTable ( )

Definition at line 514 of file C4DefList.cpp.

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

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

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

Here is the caller graph for this function:

◆ CallEveryDefinition()

void C4DefList::CallEveryDefinition ( )

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

77 {}

Referenced by C4AulScriptEngine::Link().

Here is the caller graph for this function:

◆ CheckEngineVersion()

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

Definition at line 365 of file C4DefList.cpp.

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:52
int32_t rC4XVer[2]
Definition: C4Def.h:102

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

Referenced by C4Game::InitDefs().

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

◆ CheckRequireDef()

int32_t C4DefList::CheckRequireDef ( )

Definition at line 384 of file C4DefList.cpp.

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 }
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:103
int32_t GetNumberOfIDs() const
Definition: C4IDList.cpp:231

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

Referenced by C4Game::InitDefs().

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

◆ Clear()

void C4DefList::Clear ( )

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

53 {
54  while(FirstDef)
55  {
56  C4Def* out = FirstDef;
58  delete out;
59  }
60 }

References FirstDef, and C4Def::Next.

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

Here is the caller graph for this function:

◆ Default()

void C4DefList::Default ( )

Definition at line 413 of file C4DefList.cpp.

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

References FirstDef, LoadFailure, and table.

Referenced by C4Game::Default().

Here is the caller graph for this function:

◆ Draw()

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

Definition at line 407 of file C4DefList.cpp.

408 {
409  C4Def *cdef = ID2Def(id);
410  if (cdef) cdef->Draw(cgo,fSelected,iColor);
411 }
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:607

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

Referenced by C4IDList::Draw().

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

◆ DrawFontImage()

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; }

◆ GetAllDefs()

std::vector< C4Def * > C4DefList::GetAllDefs ( C4String filter_property = nullptr) const

Definition at line 304 of file C4DefList.cpp.

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 }

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

Here is the call graph for this function:

◆ GetByName()

C4Def * C4DefList::GetByName ( const StdStrBuf name)

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

72 {
73  return ID2Def(C4ID(name));
74 }
Definition: C4Id.h:26

References ID2Def().

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

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

◆ GetByPath()

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

Definition at line 323 of file C4DefList.cpp.

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:930
bool SEqual2NoCase(const char *szStr1, const char *szStr2, int iLen)
Definition: Standard.cpp:226
size_t SLen(const char *sptr)
Definition: Standard.h:74
const char * AtRelativePath(const char *filename)
Definition: C4Config.cpp:741

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

Referenced by C4Game::ReloadFile().

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

◆ GetDef()

C4Def * C4DefList::GetDef ( int32_t  Index)

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

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 }

References FirstDef, and C4Def::Next.

Referenced by C4ScriptHost::ResolveAppends().

Here is the caller graph for this function:

◆ GetDefCount()

int C4DefList::GetDefCount ( )

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

89 {
90  int counter = 0;
91  for(C4Def* cdef = FirstDef; cdef != nullptr; cdef = cdef->Next)
92  ++counter;
93  return counter;
94 }

References FirstDef, and C4Def::Next.

Referenced by C4ScriptHost::ResolveAppends().

Here is the caller graph for this function:

◆ GetFontImageAspect()

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

Implements CStdFontCustomImages.

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

80 { return -1.0f; }

◆ GetIndex()

int32_t C4DefList::GetIndex ( C4ID  id)

Definition at line 275 of file C4DefList.cpp.

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

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

Referenced by CheckRequireDef().

Here is the caller graph for this function:

◆ GetLocalizedGroupFolderName()

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

Definition at line 531 of file C4DefList.cpp.

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

References localized_group_folder_names.

◆ GetSkeletonLoader()

StdMeshSkeletonLoader & C4DefList::GetSkeletonLoader ( )

Definition at line 526 of file C4DefList.cpp.

527 {
528  return *SkeletonLoader;
529 }

◆ ID2Def()

C4Def * C4DefList::ID2Def ( C4ID  id)

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

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 }

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

Here is the caller graph for this function:

◆ Load() [1/2]

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.

76 {
77  int32_t iResult=0;
78  C4Def *nDef = nullptr;
79  char szEntryname[_MAX_FNAME_LEN];
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());
123  group_path.ReplaceChar(AltDirectorySeparator, DirectorySeparator);
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: Def groups (primary def), as well as real definitions
143  if (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 }
#define C4CFN_Title
Definition: C4Components.h:82
#define C4CFN_DefFiles
Definition: C4Components.h:166
C4Game Game
Definition: C4Globals.cpp:52
int iResult
Definition: C4GroupMain.cpp:40
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:262
#define DirectorySeparator
#define AltDirectorySeparator
#define _MAX_FNAME_LEN
bool SEqualNoCase(const char *szStr1, const char *szStr2, int iLen)
Definition: Standard.cpp:213
char * GetExtension(char *szFilename)
Definition: StdFile.cpp:118
char * GetFilename(char *szPath)
Definition: StdFile.cpp:42
bool GetLanguageString(const char *szLanguage, StdStrBuf &rTarget)
char LanguageEx[CFG_MaxString+1]
Definition: C4Config.h:38
C4ConfigGeneral General
Definition: C4Config.h:255
bool Load(C4Group &hGroup, StdMeshSkeletonLoader &loader, DWORD dwLoadWhat, const char *szLanguage, class C4SoundSystem *pSoundSystem=nullptr, C4DefGraphicsPtrBackup *gfx_backup=nullptr)
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 Add(C4Def *ndef, bool fOverload)
void SetInitProgress(float to_progress)
Definition: C4Game.cpp:4207
bool LoadAdditionalSystemGroup(class C4Group &parent_group)
Definition: C4Game.cpp:3577
bool FindNextEntry(const char *wildcard, StdStrBuf *filename=nullptr, size_t *size=nullptr, bool start_at_filename=false)
Definition: C4Group.cpp:2217
const char * GetName() const
Definition: C4Group.cpp:2309
StdStrBuf GetFullName() const
Definition: C4Group.cpp:2638
bool OpenAsChild(C4Group *mother, const char *entry_name, bool is_exclusive=false, bool do_create=false)
Definition: C4Group.cpp:1952
void ResetSearch(bool reload_contents=false)
Definition: C4Group.cpp:1316
bool Close()
Definition: C4Group.cpp:971
static bool LoadComponentHost(C4ComponentHost *host, C4Group &hGroup, const char *szFilename, const char *szLanguage)
Definition: C4Language.cpp:232

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

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

◆ Load() [2/2]

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.

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 }
bool LogFatal(const char *szMessage)
Definition: C4Log.cpp:239
C4Reloc Reloc
Definition: C4Reloc.cpp:21
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
bool Open(C4Group &group, const char *filename) const
Definition: C4Reloc.cpp:156

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

Here is the call graph for this function:

◆ Reload()

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

Definition at line 420 of file C4DefList.cpp.

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 }
void Add(C4DefGraphics *pGraphics)
char Filename[_MAX_FNAME_LEN]
Definition: C4Def.h:176
C4DefGraphics Graphics
Definition: C4Def.h:191
void Clear()
Definition: C4Def.cpp:322
void BuildTable()
Definition: C4DefList.cpp:514
void AppendAndIncludeSkeletons()
Definition: C4DefList.cpp:521
bool Open(const char *group_name, bool do_create=false)
Definition: C4Group.cpp:660

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

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

◆ Remove() [1/2]

void C4DefList::Remove ( C4Def def)

Definition at line 220 of file C4DefList.cpp.

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 }

References FirstDef, and C4Def::Next.

Referenced by C4Game::ReloadDef().

Here is the caller graph for this function:

◆ Remove() [2/2]

bool C4DefList::Remove ( C4ID  id)

Definition at line 206 of file C4DefList.cpp.

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 }

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

◆ RemoveTemporary()

int32_t C4DefList::RemoveTemporary ( )

Definition at line 343 of file C4DefList.cpp.

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 }
bool Temporary
Definition: C4Def.h:199

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

Here is the call graph for this function:

◆ ResetIncludeDependencies()

void C4DefList::ResetIncludeDependencies ( )

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

78 {}

Referenced by C4AulScriptEngine::ReLink().

Here is the caller graph for this function:

◆ SortByPriority()

void C4DefList::SortByPriority ( )

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

76 {}

Referenced by C4AulScriptEngine::Link().

Here is the caller graph for this function:

◆ Synchronize()

void C4DefList::Synchronize ( )

Definition at line 458 of file C4DefList.cpp.

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

References table.

Referenced by C4Game::Synchronize().

Here is the caller graph for this function:

Member Data Documentation

◆ FirstDef

◆ LoadFailure

bool C4DefList::LoadFailure

Definition at line 31 of file C4DefList.h.

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

◆ localized_group_folder_names

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

Definition at line 38 of file C4DefList.h.

Referenced by GetLocalizedGroupFolderName(), and Load().

◆ table

Table C4DefList::table

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