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 ()
 
virtual ~C4DefList ()
 
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 ()
 
virtual bool DrawFontImage (const char *szImageTag, C4Facet &rTarget, C4DrawTransform *pTransform)
 
virtual float GetFontImageAspect (const char *szImageTag)
 

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

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

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

508 {
509  SkeletonLoader->ResolveIncompleteSkeletons();
510 }

Here is the caller graph for this function:

void C4DefList::BuildTable ( )

Definition at line 500 of file C4DefList.cpp.

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

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

501 {
502  table.clear();
503  for (C4Def *def = FirstDef; def; def = def->Next)
504  table.insert(std::make_pair(def->id, def));
505 }
C4Def * Next
Definition: C4Def.h:201
Definition: C4Def.h:100
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 351 of file C4DefList.cpp.

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

Referenced by C4Game::InitDefs().

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

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

Referenced by C4Game::InitDefs().

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

Here is the caller graph for this function:

void C4DefList::Default ( )

Definition at line 399 of file C4DefList.cpp.

References FirstDef, LoadFailure, and table.

Referenced by C4Game::Default().

400 {
401  FirstDef=nullptr;
402  LoadFailure=false;
403  table.clear();
404 }
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 393 of file C4DefList.cpp.

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

Referenced by C4IDList::Draw().

394 {
395  C4Def *cdef = ID2Def(id);
396  if (cdef) cdef->Draw(cgo,fSelected,iColor);
397 }
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:601
Definition: C4Def.h:100

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

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

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

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

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

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

Referenced by C4Game::ReloadFile().

310 {
311  // search defs
312  const char *szDefPath;
313  for (C4Def *pDef = FirstDef; pDef; pDef = pDef->Next)
314  if ((szDefPath = Config.AtRelativePath(pDef->Filename)))
315  if (SEqual2NoCase(szPath, szDefPath))
316  {
317  // the definition itself?
318  if (!szPath[SLen(szDefPath)])
319  return pDef;
320  // or a component?
321  else if (szPath[SLen(szDefPath)] == '\\')
322  if (!strchr(szPath + SLen(szDefPath) + 1, '\\'))
323  return pDef;
324  }
325  // not found
326  return nullptr;
327 }
C4Config Config
Definition: C4Config.cpp:831
C4Def * Next
Definition: C4Def.h:201
size_t SLen(const char *sptr)
Definition: Standard.h:78
Definition: C4Def.h:100
bool SEqual2NoCase(const char *szStr1, const char *szStr2, int iLen)
Definition: Standard.cpp:190
const char * AtRelativePath(const char *szFilename)
Definition: C4Config.cpp:654
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:201
Definition: C4Def.h:100
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:201
Definition: C4Def.h:100
C4Def * FirstDef
Definition: C4DefList.h:35

Here is the caller graph for this function:

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

Implements CStdFontCustomImages.

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

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

Definition at line 261 of file C4DefList.cpp.

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

Referenced by CheckRequireDef().

262 {
263  C4Def *cdef;
264  int32_t cindex;
265  for (cdef=FirstDef,cindex=0; cdef; cdef=cdef->Next,cindex++)
266  if (cdef->id==id) return cindex;
267  return -1;
268 }
C4ID id
Definition: C4Def.h:103
C4Def * Next
Definition: C4Def.h:201
Definition: C4Def.h:100
C4Def * FirstDef
Definition: C4DefList.h:35

Here is the caller graph for this function:

StdMeshSkeletonLoader & C4DefList::GetSkeletonLoader ( )

Definition at line 512 of file C4DefList.cpp.

513 {
514  return *SkeletonLoader;
515 }
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:103
C4Def * Next
Definition: C4Def.h:201
Definition: C4Def.h:100
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 74 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().

79 {
80  int32_t iResult=0;
81  C4Def *nDef;
82  char szEntryname[_MAX_FNAME+1];
83  C4Group hChild;
84  bool fPrimaryDef=false;
85  bool fThisSearchMessage=false;
86  bool can_be_primary_def = SEqualNoCase(GetExtension(hGroup.GetName()), "ocd");
87 
88  // This search message
89  if (fSearchMessage)
90  if (can_be_primary_def
91  || SEqualNoCase(GetExtension(hGroup.GetName()),"ocs")
92  || SEqualNoCase(GetExtension(hGroup.GetName()),"ocf"))
93  {
94  fThisSearchMessage=true;
95  fSearchMessage=false;
96  }
97 
98  if (fThisSearchMessage) { LogF("%s...",GetFilename(hGroup.GetName())); }
99 
100  // Load primary definition
101  if (can_be_primary_def)
102  {
103  if ((nDef = new C4Def))
104  {
105  if (nDef->Load(hGroup, *SkeletonLoader, dwLoadWhat, szLanguage, pSoundSystem) && Add(nDef, fOverload))
106  {
107  iResult++; fPrimaryDef = true;
108  }
109  else
110  {
111  delete nDef;
112  }
113  }
114  }
115 
116  // Load sub definitions
117  int i = 0;
118  hGroup.ResetSearch();
119  while (hGroup.FindNextEntry(C4CFN_DefFiles,szEntryname))
120  if (hChild.OpenAsChild(&hGroup,szEntryname))
121  {
122  // Hack: Assume that there are sixteen sub definitions to avoid unnecessary I/O
123  int iSubMinProgress = std::min(iMaxProgress, iMinProgress + ((iMaxProgress - iMinProgress) * i) / 16);
124  int iSubMaxProgress = std::min(iMaxProgress, iMinProgress + ((iMaxProgress - iMinProgress) * (i + 1)) / 16);
125  ++i;
126  iResult += Load(hChild,dwLoadWhat,szLanguage,pSoundSystem,fOverload,fSearchMessage,iSubMinProgress,iSubMaxProgress);
127  hChild.Close();
128  }
129 
130  // load additional system scripts for def groups only
131  if (!fPrimaryDef && fLoadSysGroups) Game.LoadAdditionalSystemGroup(hGroup);
132 
133  if (fThisSearchMessage) { LogF(LoadResStr("IDS_PRC_DEFSLOADED"),iResult); }
134 
135  // progress (could go down one level of recursion...)
136  if (iMinProgress != iMaxProgress) Game.SetInitProgress(float(iMaxProgress));
137 
138  return iResult;
139 }
char * GetFilename(char *szPath)
Definition: StdFile.cpp:55
void SetInitProgress(float fToProgress)
Definition: C4Game.cpp:3389
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:177
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:100
bool Close()
Definition: C4Group.cpp:755
#define _MAX_FNAME
char * GetExtension(char *szFilename)
Definition: StdFile.cpp:131
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:74
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:2888
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:253
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 141 of file C4DefList.cpp.

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

145 {
146  // Load from specified file
147  C4Group hGroup;
148  if (!Reloc.Open(hGroup, szFilename))
149  {
150  // Specified file not found (failure)
151  LogFatal(FormatString(LoadResStr("IDS_PRC_DEFNOTFOUND"), szFilename).getData());
152  LoadFailure=true;
153  return 0; // 0 definitions loaded
154  }
155  int32_t nDefs = Load(hGroup,dwLoadWhat,szLanguage,pSoundSystem,fOverload,true,iMinProgress,iMaxProgress);
156  hGroup.Close();
157 
158  // progress (could go down one level of recursion...)
159  if (iMinProgress != iMaxProgress) Game.SetInitProgress(float(iMaxProgress));
160 
161  return nDefs;
162 }
void SetInitProgress(float fToProgress)
Definition: C4Game.cpp:3389
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:69
bool LogFatal(const char *szMessage)
Definition: C4Log.cpp:230
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:74
bool LoadFailure
Definition: C4DefList.h:31
C4Reloc Reloc
Definition: C4Reloc.cpp:22
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:277

Here is the call graph for this function:

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

void C4DefList::Remove ( C4Def def)

Definition at line 208 of file C4DefList.cpp.

References FirstDef, and C4Def::Next.

Referenced by C4Game::ReloadDef().

209 {
210  C4Def *cdef,*prev;
211  for (cdef=FirstDef,prev=nullptr; cdef; prev=cdef,cdef=cdef->Next)
212  if (cdef==def)
213  {
214  if (prev) prev->Next=cdef->Next;
215  else FirstDef=cdef->Next;
216  delete cdef;
217  return;
218  }
219 }
C4Def * Next
Definition: C4Def.h:201
Definition: C4Def.h:100
C4Def * FirstDef
Definition: C4DefList.h:35

Here is the caller graph for this function:

bool C4DefList::Remove ( C4ID  id)

Definition at line 194 of file C4DefList.cpp.

References FirstDef, and C4Def::Next.

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

Definition at line 329 of file C4DefList.cpp.

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

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

References table.

Referenced by C4Game::Synchronize().

445 {
446  for (Table::iterator it = table.begin(); it != table.end(); ++it)
447  it->second->Synchronize();
448 }
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

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