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

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 504 of file C4DefList.cpp.

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

505 {
506  SkeletonLoader->ResolveIncompleteSkeletons();
507 }

Here is the caller graph for this function:

void C4DefList::BuildTable ( )

Definition at line 497 of file C4DefList.cpp.

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

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

498 {
499  table.clear();
500  for (C4Def *def = FirstDef; def; def = def->Next)
501  table.insert(std::make_pair(def->id, def));
502 }
C4Def * Next
Definition: C4Def.h:199
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 348 of file C4DefList.cpp.

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

Referenced by C4Game::InitDefs().

349 {
350  int32_t rcount=0;
351  C4Def *cdef,*prev,*next;
352  for (cdef=FirstDef,prev=nullptr; cdef; cdef=next)
353  {
354  next=cdef->Next;
355  if (CompareVersion(cdef->rC4XVer[0],cdef->rC4XVer[1],ver1,ver2) > 0)
356  {
357  if (prev) prev->Next=cdef->Next;
358  else FirstDef=cdef->Next;
359  delete cdef;
360  rcount++;
361  }
362  else prev=cdef;
363  }
364  return rcount;
365 }
int CompareVersion(int iVer1, int iVer2, int iRVer1=C4XVER1, int iRVer2=C4XVER2)
Definition: C4GameVersion.h:51
C4Def * Next
Definition: C4Def.h:199
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 367 of file C4DefList.cpp.

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

Referenced by C4Game::InitDefs().

368 {
369  int32_t rcount=0, rcount2;
370  C4Def *cdef,*prev,*next;
371  do
372  {
373  rcount2 = rcount;
374  for (cdef=FirstDef,prev=nullptr; cdef; cdef=next)
375  {
376  next=cdef->Next;
377  for (int32_t i = 0; i < cdef->RequireDef.GetNumberOfIDs(); i++)
378  if (GetIndex(cdef->RequireDef.GetID(i)) < 0)
379  {
380  (prev ? prev->Next : FirstDef) = cdef->Next;
381  delete cdef;
382  rcount++;
383  }
384  }
385  }
386  while (rcount != rcount2);
387  return rcount;
388 }
C4Def * Next
Definition: C4Def.h:199
Definition: C4Def.h:98
C4IDList RequireDef
Definition: C4Def.h:103
int32_t GetIndex(C4ID id)
Definition: C4DefList.cpp:258
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:199
Definition: C4Def.h:98
C4Def * FirstDef
Definition: C4DefList.h:35

Here is the caller graph for this function:

void C4DefList::Default ( )

Definition at line 396 of file C4DefList.cpp.

References FirstDef, LoadFailure, and table.

Referenced by C4Game::Default().

397 {
398  FirstDef=nullptr;
399  LoadFailure=false;
400  table.clear();
401 }
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 390 of file C4DefList.cpp.

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

Referenced by C4IDList::Draw().

391 {
392  C4Def *cdef = ID2Def(id);
393  if (cdef) cdef->Draw(cgo,fSelected,iColor);
394 }
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:599
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 287 of file C4DefList.cpp.

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

288 {
289  // Collect vector of all definitions
290  // Filter for those where property evaluates to true if filter_property!=nullptr
291  std::vector<C4Def*> result;
292  result.reserve(filter_property ? 32 : table.size());
293  C4Value prop_val;
294  for (C4Def *def = FirstDef; def; def = def->Next)
295  {
296  if (filter_property)
297  {
298  if (!def->GetPropertyByS(filter_property, &prop_val)) continue;
299  if (!prop_val) continue;
300  }
301  result.push_back(def);
302  }
303  return result;
304 }
C4Def * Next
Definition: C4Def.h:199
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 306 of file C4DefList.cpp.

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

Referenced by C4Game::ReloadFile().

307 {
308  // search defs
309  const char *szDefPath;
310  for (C4Def *pDef = FirstDef; pDef; pDef = pDef->Next)
311  if ((szDefPath = Config.AtRelativePath(pDef->Filename)))
312  if (SEqual2NoCase(szPath, szDefPath))
313  {
314  // the definition itself?
315  if (!szPath[SLen(szDefPath)])
316  return pDef;
317  // or a component?
318  else if (szPath[SLen(szDefPath)] == '\\')
319  if (!strchr(szPath + SLen(szDefPath) + 1, '\\'))
320  return pDef;
321  }
322  // not found
323  return nullptr;
324 }
C4Config Config
Definition: C4Config.cpp:833
C4Def * Next
Definition: C4Def.h:199
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:198
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:199
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:199
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 258 of file C4DefList.cpp.

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

Referenced by CheckRequireDef().

259 {
260  C4Def *cdef;
261  int32_t cindex;
262  for (cdef=FirstDef,cindex=0; cdef; cdef=cdef->Next,cindex++)
263  if (cdef->id==id) return cindex;
264  return -1;
265 }
C4ID id
Definition: C4Def.h:101
C4Def * Next
Definition: C4Def.h:199
Definition: C4Def.h:98
C4Def * FirstDef
Definition: C4DefList.h:35

Here is the caller graph for this function:

StdMeshSkeletonLoader & C4DefList::GetSkeletonLoader ( )

Definition at line 509 of file C4DefList.cpp.

510 {
511  return *SkeletonLoader;
512 }
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:199
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(), C4CFN_DefFiles, C4Group::Close(), C4Group::FindNextEntry(), Game, GetExtension(), GetFilename(), C4Group::GetName(), iResult, C4Def::Load(), C4Game::LoadAdditionalSystemGroup(), LoadResStr(), LogF(), C4Group::OpenAsChild(), C4Group::ResetSearch(), SEqualNoCase(), and C4Game::SetInitProgress().

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

76 {
77  int32_t iResult=0;
78  C4Def *nDef;
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  }
110  }
111  }
112 
113  // Load sub definitions
114  int i = 0;
115  hGroup.ResetSearch();
116  while (hGroup.FindNextEntry(C4CFN_DefFiles,szEntryname))
117  if (hChild.OpenAsChild(&hGroup,szEntryname))
118  {
119  // Hack: Assume that there are sixteen sub definitions to avoid unnecessary I/O
120  int iSubMinProgress = std::min(iMaxProgress, iMinProgress + ((iMaxProgress - iMinProgress) * i) / 16);
121  int iSubMaxProgress = std::min(iMaxProgress, iMinProgress + ((iMaxProgress - iMinProgress) * (i + 1)) / 16);
122  ++i;
123  iResult += Load(hChild,dwLoadWhat,szLanguage,pSoundSystem,fOverload,fSearchMessage,iSubMinProgress,iSubMaxProgress);
124  hChild.Close();
125  }
126 
127  // load additional system scripts for def groups only
128  if (!fPrimaryDef && fLoadSysGroups) Game.LoadAdditionalSystemGroup(hGroup);
129 
130  if (fThisSearchMessage) { LogF(LoadResStr("IDS_PRC_DEFSLOADED"),iResult); }
131 
132  // progress (could go down one level of recursion...)
133  if (iMinProgress != iMaxProgress) Game.SetInitProgress(float(iMaxProgress));
134 
135  return iResult;
136 }
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)
C4Game Game
Definition: C4Globals.cpp:52
bool Add(C4Def *ndef, bool fOverload)
bool SEqualNoCase(const char *szStr1, const char *szStr2, int iLen)
Definition: Standard.cpp:185
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
int iResult
Definition: C4GroupMain.cpp:39
const char * GetName() const
Definition: C4Group.cpp:1845
Definition: C4Def.h:98
bool Close()
Definition: C4Group.cpp:755
#define _MAX_FNAME
char * GetExtension(char *szFilename)
Definition: StdFile.cpp:121
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 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
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 138 of file C4DefList.cpp.

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

142 {
143  // Load from specified file
144  C4Group hGroup;
145  if (!Reloc.Open(hGroup, szFilename))
146  {
147  // Specified file not found (failure)
148  LogFatal(FormatString(LoadResStr("IDS_PRC_DEFNOTFOUND"), szFilename).getData());
149  LoadFailure=true;
150  return 0; // 0 definitions loaded
151  }
152  int32_t nDefs = Load(hGroup,dwLoadWhat,szLanguage,pSoundSystem,fOverload,true,iMinProgress,iMaxProgress);
153  hGroup.Close();
154 
155  // progress (could go down one level of recursion...)
156  if (iMinProgress != iMaxProgress) Game.SetInitProgress(float(iMaxProgress));
157 
158  return nDefs;
159 }
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:68
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 403 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().

404 {
405  // Safety
406  if (!pDef) return false;
407  // backup graphics names and pointers
408  // GfxBackup-dtor will ensure that upon loading-failure all graphics are reset to default
409  C4DefGraphicsPtrBackup GfxBackup;
410  GfxBackup.Add(&pDef->Graphics);
411  // Clear def
412  pDef->Clear(); // Assume filename is being kept
413  // Reload def
414  C4Group hGroup;
415  if (!hGroup.Open(pDef->Filename)) return false;
416  // clear all skeletons in that group, so that deleted skeletons are also deleted in the engine
417  SkeletonLoader->RemoveSkeletonsInGroup(hGroup.GetName());
418  // load the definition
419  if (!pDef->Load(hGroup, *SkeletonLoader, dwLoadWhat, szLanguage, pSoundSystem, &GfxBackup)) return false;
420  hGroup.Close();
421  // rebuild quick access table
422  BuildTable();
423  // handle skeleton appends and includes
425  // restore graphics
426  GfxBackup.AssignUpdate();
427  // Success
428  return true;
429 }
bool Load(C4Group &hGroup, StdMeshSkeletonLoader &loader, DWORD dwLoadWhat, const char *szLanguage, class C4SoundSystem *pSoundSystem=nullptr, C4DefGraphicsPtrBackup *gfx_backup=nullptr)
void BuildTable()
Definition: C4DefList.cpp:497
void Add(C4DefGraphics *pGraphics)
void Clear()
Definition: C4Def.cpp:324
void AppendAndIncludeSkeletons()
Definition: C4DefList.cpp:504
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:177
C4DefGraphics Graphics
Definition: C4Def.h:192

Here is the call graph for this function:

Here is the caller graph for this function:

void C4DefList::Remove ( C4Def def)

Definition at line 205 of file C4DefList.cpp.

References FirstDef, and C4Def::Next.

Referenced by C4Game::ReloadDef().

206 {
207  C4Def *cdef,*prev;
208  for (cdef=FirstDef,prev=nullptr; cdef; prev=cdef,cdef=cdef->Next)
209  if (cdef==def)
210  {
211  if (prev) prev->Next=cdef->Next;
212  else FirstDef=cdef->Next;
213  delete cdef;
214  return;
215  }
216 }
C4Def * Next
Definition: C4Def.h:199
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 191 of file C4DefList.cpp.

References FirstDef, and C4Def::Next.

192 {
193  C4Def *cdef,*prev;
194  for (cdef=FirstDef,prev=nullptr; cdef; prev=cdef,cdef=cdef->Next)
195  if (cdef->id==id)
196  {
197  if (prev) prev->Next=cdef->Next;
198  else FirstDef=cdef->Next;
199  delete cdef;
200  return true;
201  }
202  return false;
203 }
C4Def * Next
Definition: C4Def.h:199
Definition: C4Def.h:98
C4Def * FirstDef
Definition: C4DefList.h:35
int32_t C4DefList::RemoveTemporary ( )

Definition at line 326 of file C4DefList.cpp.

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

327 {
328  C4Def *cdef,*prev,*next;
329  int32_t removed=0;
330  for (cdef=FirstDef,prev=nullptr; cdef; cdef=next)
331  {
332  next=cdef->Next;
333  if (cdef->Temporary)
334  {
335  if (prev) prev->Next=next;
336  else FirstDef=next;
337  delete cdef;
338  removed++;
339  }
340  else
341  prev=cdef;
342  }
343  // rebuild quick access table
344  BuildTable();
345  return removed;
346 }
void BuildTable()
Definition: C4DefList.cpp:497
C4Def * Next
Definition: C4Def.h:199
bool Temporary
Definition: C4Def.h:200
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 441 of file C4DefList.cpp.

References table.

Referenced by C4Game::Synchronize().

442 {
443  for (auto & it : table)
444  it.second->Synchronize();
445 }
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().

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: