OpenClonk
C4ObjectInfo Class Reference

#include <C4ObjectInfo.h>

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

Public Member Functions

 C4ObjectInfo ()
 
 ~C4ObjectInfo ()
 
void Default ()
 
void Clear ()
 
void Evaluate ()
 
void Retire ()
 
void Recruit ()
 
void SetBirthday ()
 
bool Save (C4Group &hGroup, bool fStoreTiny, C4DefList *pDefs)
 
bool Load (C4Group &hGroup)
 
bool Load (C4Group &hMother, const char *szEntryname)
 
bool Save (C4Group &hGroup, class C4DefList *pDefs)
 
void Default (C4ID n_id=C4ID::None, class C4DefList *pDefs=nullptr, const char *cpNames=nullptr)
 
void Promote (int32_t iRank, C4RankSystem &rRanks, bool fForceRankName)
 
bool GetNextRankInfo (C4RankSystem &rDefaultRanks, int32_t *piNextRankExp, StdStrBuf *psNextRankName)
 
void CompileFunc (StdCompiler *pComp)
 

Public Attributes

bool WasInAction
 
bool InAction
 
int32_t InActionTime
 
bool HasDied
 
int32_t ControlCount
 
class C4DefpDef
 
char Filename [_MAX_PATH_LEN]
 
C4ObjectInfoNext
 
C4ID id
 
char Name [C4MaxName+1]
 
int32_t Participation
 
int32_t Rank
 
StdStrBuf sRankName
 
StdStrBuf sNextRankName
 
int32_t NextRankExp
 
int32_t Experience
 
int32_t Rounds
 
int32_t DeathCount
 
char TypeName [C4MaxName+1+1]
 
int32_t Birthday
 
int32_t TotalPlayingTime
 
int32_t Age
 
char DeathMessage [C4MaxDeathMsg+1]
 
C4ValueMapData ExtraData
 

Protected Member Functions

bool Compile (const char *szSource)
 
bool Decompile (StdStrBuf &Buf)
 
void UpdateCustomRanks (C4DefList *pDefs)
 

Detailed Description

Definition at line 28 of file C4ObjectInfo.h.

Constructor & Destructor Documentation

◆ C4ObjectInfo()

C4ObjectInfo::C4ObjectInfo ( )

Definition at line 37 of file C4ObjectInfo.cpp.

38 {
39  Default();
40 }

References Default().

Here is the call graph for this function:

◆ ~C4ObjectInfo()

C4ObjectInfo::~C4ObjectInfo ( )

Definition at line 42 of file C4ObjectInfo.cpp.

43 {
44  Clear();
45 }

References Clear().

Here is the call graph for this function:

Member Function Documentation

◆ Clear()

void C4ObjectInfo::Clear ( )

Definition at line 189 of file C4ObjectInfo.cpp.

190 {
191  pDef = nullptr;
192 }
class C4Def * pDef
Definition: C4ObjectInfo.h:39

References pDef.

Referenced by ~C4ObjectInfo().

Here is the caller graph for this function:

◆ Compile()

bool C4ObjectInfoCore::Compile ( const char *  szSource)
protectedinherited

Definition at line 389 of file C4InfoCore.cpp.

390 {
391  bool ret = CompileFromBuf_LogWarn<StdCompilerINIRead>(
392  mkNamingAdapt(*this, "ObjectInfo"),
393  StdStrBuf(szSource),
394  "ObjectInfo");
395  // DeathMessages are not allowed to stay forever
396  if ('@' == DeathMessage[0])
397  {
398  DeathMessage[0] = ' ';
399  }
400  return ret;
401 }
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
char DeathMessage[C4MaxDeathMsg+1]
Definition: C4InfoCore.h:48

References C4ObjectInfoCore::DeathMessage, and mkNamingAdapt().

Referenced by C4ObjectInfoCore::Load().

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

◆ CompileFunc()

void C4ObjectInfoCore::CompileFunc ( StdCompiler pComp)
inherited

Definition at line 362 of file C4InfoCore.cpp.

363 {
364  C4ValueNumbers numbers;
365  pComp->Value(mkNamingAdapt(id, "id", C4ID::None));
366  pComp->Value(mkNamingAdapt(toC4CStr(Name), "Name", "Clonk"));
367  pComp->Value(mkNamingAdapt(toC4CStr(DeathMessage), "DeathMessage", ""));
368  pComp->Value(mkNamingAdapt(Rank, "Rank", 0));
369  pComp->Value(mkNamingAdapt(sRankName, "RankName", "Clonk"));
370  pComp->Value(mkNamingAdapt(sNextRankName, "NextRankName", ""));
371  pComp->Value(mkNamingAdapt(toC4CStr(TypeName), "TypeName", "Clonk"));
372  pComp->Value(mkNamingAdapt(Participation, "Participation", 1));
373  pComp->Value(mkNamingAdapt(Experience, "Experience", 0));
374  pComp->Value(mkNamingAdapt(NextRankExp, "NextRankExp", 0));
375  pComp->Value(mkNamingAdapt(Rounds, "Rounds", 0));
376  pComp->Value(mkNamingAdapt(DeathCount, "DeathCount", 0));
377  pComp->Value(mkNamingAdapt(Birthday, "Birthday", 0));
378  pComp->Value(mkNamingAdapt(TotalPlayingTime, "TotalPlayingTime", 0));
379  pComp->Value(mkNamingAdapt(Age, "Age", 0));
380  pComp->Value(mkNamingAdapt(mkParAdapt(ExtraData, &numbers), "ExtraData", C4ValueMapData()));
381  pComp->Value(mkNamingAdapt(numbers, "ExtraDataValues"));
382  if (pComp->isDeserializer())
383  {
384  numbers.Denumerate();
385  ExtraData.Denumerate(&numbers);
386  }
387 }
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:490
#define toC4CStr(szString)
Definition: StdAdaptors.h:24
static const C4ID None
Definition: C4Id.h:39
int32_t DeathCount
Definition: C4InfoCore.h:44
int32_t TotalPlayingTime
Definition: C4InfoCore.h:46
char Name[C4MaxName+1]
Definition: C4InfoCore.h:37
int32_t NextRankExp
Definition: C4InfoCore.h:42
int32_t Birthday
Definition: C4InfoCore.h:46
StdStrBuf sNextRankName
Definition: C4InfoCore.h:41
int32_t Participation
Definition: C4InfoCore.h:38
int32_t Rounds
Definition: C4InfoCore.h:43
char TypeName[C4MaxName+1+1]
Definition: C4InfoCore.h:45
StdStrBuf sRankName
Definition: C4InfoCore.h:40
int32_t Experience
Definition: C4InfoCore.h:43
C4ValueMapData ExtraData
Definition: C4InfoCore.h:49
void Denumerate(C4ValueNumbers *)
Definition: C4ValueMap.cpp:254
void Denumerate()
Definition: C4Value.cpp:281
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool isDeserializer()
Definition: StdCompiler.h:53

References C4ObjectInfoCore::Age, C4ObjectInfoCore::Birthday, C4ObjectInfoCore::DeathCount, C4ObjectInfoCore::DeathMessage, C4ValueNumbers::Denumerate(), C4ValueMapData::Denumerate(), C4ObjectInfoCore::Experience, C4ObjectInfoCore::ExtraData, StdCompiler::isDeserializer(), mkNamingAdapt(), mkParAdapt(), C4ObjectInfoCore::Name, C4ObjectInfoCore::NextRankExp, C4ID::None, C4ObjectInfoCore::Participation, C4ObjectInfoCore::Rank, C4ObjectInfoCore::Rounds, C4ObjectInfoCore::sNextRankName, C4ObjectInfoCore::sRankName, toC4CStr, C4ObjectInfoCore::TotalPlayingTime, C4ObjectInfoCore::TypeName, and StdCompiler::Value().

Here is the call graph for this function:

◆ Decompile()

bool C4ObjectInfoCore::Decompile ( StdStrBuf Buf)
protectedinherited

Definition at line 403 of file C4InfoCore.cpp.

404 {
405  if (!DecompileToBuf_Log<StdCompilerINIWrite>(
406  mkNamingAdapt(*this, "ObjectInfo"),
407  &Buf,
408  "ObjectInfo"))
409  {
410  return false;
411  }
412  return true;
413 }

References mkNamingAdapt().

Referenced by C4ObjectInfoCore::Save().

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

◆ Default() [1/2]

void C4ObjectInfo::Default ( )

Definition at line 47 of file C4ObjectInfo.cpp.

48 {
49  WasInAction = false;
50  InAction = false;
51  InActionTime = 0;
52  HasDied = false;
53  ControlCount = 0;
54  Filename[0] = 0;
55  Next = nullptr;
56  pDef = nullptr;
57 }
C4ObjectInfo * Next
Definition: C4ObjectInfo.h:41
char Filename[_MAX_PATH_LEN]
Definition: C4ObjectInfo.h:40
int32_t ControlCount
Definition: C4ObjectInfo.h:38
int32_t InActionTime
Definition: C4ObjectInfo.h:36
bool WasInAction
Definition: C4ObjectInfo.h:34

References ControlCount, Filename, HasDied, InAction, InActionTime, Next, pDef, and WasInAction.

Referenced by C4ObjectInfo().

Here is the caller graph for this function:

◆ Default() [2/2]

void C4ObjectInfoCore::Default ( C4ID  n_id = C4ID::None,
class C4DefList pDefs = nullptr,
const char *  cpNames = nullptr 
)
inherited

Definition at line 201 of file C4InfoCore.cpp.

202 {
203  // Def
204  C4Def *pDef = nullptr;
205  if (pDefs)
206  {
207  pDef = pDefs->ID2Def(n_id);
208  }
209 
210  // Defaults
211  id = n_id;
212  Participation = 1;
213  Rank = 0;
214  Experience = 0;
215  Rounds = 0;
216  DeathCount = 0;
217  Birthday = 0;
218  TotalPlayingTime = 0;
219  SCopy("Clonk", Name, C4MaxName);
220  SCopy("Clonk", TypeName, C4MaxName);
221  sRankName.Copy("Clonk");
223  NextRankExp = 0;
224  DeathMessage[0] = '\0';
225  Age = 0;
226  ExtraData.Reset();
227 
228  // Type
229  if (pDef)
230  {
231  SCopy(pDef->GetName(), TypeName, C4MaxName);
232  }
233 
234  // Name
235  if (cpNames)
236  {
237  SCopySegment(cpNames, Random(SCharCount(0x0A, cpNames)), Name, 0x0A, C4MaxName + 1);
239  SReplaceChar(Name, 0x0D, 0x00);
240  if (!Name[0])
241  {
242  SCopy("Clonk", Name, C4MaxName);
243  }
244  }
245 
246  if (pDefs)
247  {
248  UpdateCustomRanks(pDefs);
249  }
250 }
const unsigned int C4MaxName
uint32_t Random()
Definition: C4Random.cpp:43
unsigned int SCharCount(char cTarget, const char *szInStr, const char *cpUntil)
Definition: Standard.cpp:326
void SReplaceChar(char *str, char fc, char tc)
Definition: Standard.cpp:354
bool SCopySegment(const char *szString, int iSegment, char *sTarget, char cSeparator, int iMaxL, bool fSkipWhitespace)
Definition: Standard.cpp:279
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
int SClearFrontBack(char *szString, char cClear)
Definition: Standard.cpp:461
Definition: C4Def.h:99
void UpdateCustomRanks(C4DefList *pDefs)
Definition: C4InfoCore.cpp:263
const char * GetName() const override
Definition: C4PropList.cpp:243
void Copy()
Definition: StdBuf.h:467
void Clear()
Definition: StdBuf.h:466

References C4ObjectInfoCore::Age, C4ObjectInfoCore::Birthday, C4MaxName, StdStrBuf::Clear(), StdStrBuf::Copy(), C4ObjectInfoCore::DeathCount, C4ObjectInfoCore::DeathMessage, C4ObjectInfoCore::Experience, C4ObjectInfoCore::ExtraData, C4PropListStatic::GetName(), C4DefList::ID2Def(), C4ObjectInfoCore::Name, C4ObjectInfoCore::NextRankExp, C4ObjectInfoCore::Participation, Random(), C4ObjectInfoCore::Rank, C4ValueMapData::Reset(), C4ObjectInfoCore::Rounds, SCharCount(), SClearFrontBack(), SCopy(), SCopySegment(), C4ObjectInfoCore::sNextRankName, C4ObjectInfoCore::sRankName, SReplaceChar(), C4ObjectInfoCore::TotalPlayingTime, C4ObjectInfoCore::TypeName, and C4ObjectInfoCore::UpdateCustomRanks().

Referenced by C4ObjectInfoCore::C4ObjectInfoCore().

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

◆ Evaluate()

void C4ObjectInfo::Evaluate ( )

Definition at line 180 of file C4ObjectInfo.cpp.

181 {
182  Retire();
183  if (WasInAction)
184  {
185  Rounds++;
186  }
187 }

References Retire(), C4ObjectInfoCore::Rounds, and WasInAction.

Referenced by C4ObjectInfoList::Evaluate().

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

◆ GetNextRankInfo()

bool C4ObjectInfoCore::GetNextRankInfo ( C4RankSystem rDefaultRanks,
int32_t *  piNextRankExp,
StdStrBuf psNextRankName 
)
inherited

Definition at line 297 of file C4InfoCore.cpp.

298 {
299  int32_t iNextRankExp;
300  // Custom rank assigned?
301  if (NextRankExp)
302  {
303  iNextRankExp = NextRankExp;
304  if (psNextRankName)
305  {
306  psNextRankName->Copy(sNextRankName);
307  }
308  }
309  else
310  {
311  // No custom rank: Get from default set
312  StdStrBuf sRank(rDefaultRanks.GetRankName(Rank + 1, false));
313  if (sRank)
314  {
315  iNextRankExp = rDefaultRanks.Experience(Rank + 1);
316  if (psNextRankName)
317  {
318  psNextRankName->Copy(sRank);
319  }
320  }
321  else
322  {
323  // No more promotion
324  iNextRankExp = C4RankSystem::EXP_NoPromotion;
325  }
326  }
327  // Return result
328  if (piNextRankExp)
329  {
330  *piNextRankExp = iNextRankExp;
331  }
332  // Return value is whether additional promotion is possible
333  return iNextRankExp != C4RankSystem::EXP_NoPromotion;
334 }
StdStrBuf GetRankName(int iRank, bool fReturnLastIfOver)
int Experience(int iRank)

References StdStrBuf::Copy(), C4RankSystem::EXP_NoPromotion, C4RankSystem::Experience(), C4RankSystem::GetRankName(), C4ObjectInfoCore::NextRankExp, C4ObjectInfoCore::Rank, and C4ObjectInfoCore::sNextRankName.

Here is the call graph for this function:

◆ Load() [1/2]

bool C4ObjectInfo::Load ( C4Group hGroup)

Definition at line 83 of file C4ObjectInfo.cpp.

84 {
85  // Store group file name
87  // Load core
88  return C4ObjectInfoCore::Load(hGroup);
89 }
#define _MAX_FNAME
char * GetFilename(char *szPath)
Definition: StdFile.cpp:42
const char * GetName() const
Definition: C4Group.cpp:2309
bool Load(C4Group &hGroup)
Definition: C4InfoCore.cpp:336

References _MAX_FNAME, Filename, GetFilename(), C4Group::GetName(), C4ObjectInfoCore::Load(), and SCopy().

Referenced by C4ObjectInfoList::Load(), and Load().

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

◆ Load() [2/2]

bool C4ObjectInfo::Load ( C4Group hMother,
const char *  szEntryname 
)

Definition at line 59 of file C4ObjectInfo.cpp.

60 {
61  // New version
62  if (SEqualNoCase(GetExtension(szEntryname), "oci")) // TODO: Define file extensions in a static constant
63  {
64  C4Group hChild;
65  if (hChild.OpenAsChild(&hMother,szEntryname))
66  {
67  if (!C4ObjectInfo::Load(hChild))
68  {
69  hChild.Close();
70  return false;
71  }
72  // resolve definition, if possible
73  // only works in game, but is not needed in frontend or startup editing anyway
74  pDef = C4Id2Def(id);
75  hChild.Close();
76  return true;
77  }
78  }
79 
80  return false;
81 }
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:84
bool SEqualNoCase(const char *szStr1, const char *szStr2, int iLen)
Definition: Standard.cpp:213
char * GetExtension(char *szFilename)
Definition: StdFile.cpp:118
bool OpenAsChild(C4Group *mother, const char *entry_name, bool is_exclusive=false, bool do_create=false)
Definition: C4Group.cpp:1952
bool Close()
Definition: C4Group.cpp:971
bool Load(C4Group &hGroup)

References C4Id2Def(), C4Group::Close(), GetExtension(), Load(), C4Group::OpenAsChild(), pDef, and SEqualNoCase().

Here is the call graph for this function:

◆ Promote()

void C4ObjectInfoCore::Promote ( int32_t  iRank,
C4RankSystem rRanks,
bool  fForceRankName 
)
inherited

Definition at line 252 of file C4InfoCore.cpp.

253 {
254  Rank = iRank;
255  // Copy new rank name if defined only, or forced to use highest defined rank for too high info ranks
256  StdStrBuf sNewRank(rRanks.GetRankName(Rank, fForceRankName));
257  if (sNewRank)
258  {
259  sRankName.Copy(sNewRank);
260  }
261 }

References StdStrBuf::Copy(), C4RankSystem::GetRankName(), C4ObjectInfoCore::Rank, and C4ObjectInfoCore::sRankName.

Referenced by C4Object::Promote().

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

◆ Recruit()

void C4ObjectInfo::Recruit ( )

Definition at line 194 of file C4ObjectInfo.cpp.

195 {
196  // Already recruited?
197  if (InAction)
198  {
199  return;
200  }
201  WasInAction = true;
202  InAction = true;
204  // Rank name overload by def?
206  if (pDef && pDef->pRankNames)
207  {
208  StdStrBuf sRank(pDef->pRankNames->GetRankName(Rank, true));
209  if (sRank)
210  {
211  sRankName.Copy(sRank);
212  }
213  }
214 }
C4Game Game
Definition: C4Globals.cpp:52
C4DefList Definitions
Definition: C4Globals.cpp:49
C4RankSystem * pRankNames
Definition: C4Def.h:188
C4Def * ID2Def(C4ID id)
int32_t Time
Definition: C4Game.h:132

References StdStrBuf::Copy(), Definitions, Game, C4RankSystem::GetRankName(), C4DefList::ID2Def(), InAction, InActionTime, pDef, C4Def::pRankNames, C4ObjectInfoCore::Rank, C4ObjectInfoCore::sRankName, C4Game::Time, and WasInAction.

Referenced by C4ObjectInfoList::GetIdle(), and C4Object::GrabInfo().

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

◆ Retire()

void C4ObjectInfo::Retire ( )

Definition at line 216 of file C4ObjectInfo.cpp.

217 {
218  // Not recruited?
219  if (!InAction)
220  {
221  return;
222  }
223  // retire
224  InAction = false;
226 }

References Game, InAction, InActionTime, C4Game::Time, and C4ObjectInfoCore::TotalPlayingTime.

Referenced by C4Object::AssignDeath(), C4Object::AssignRemoval(), Evaluate(), C4Object::GrabInfo(), and C4Player::SetObjectCrewStatus().

Here is the caller graph for this function:

◆ Save() [1/2]

bool C4ObjectInfo::Save ( C4Group hGroup,
bool  fStoreTiny,
C4DefList pDefs 
)

Definition at line 91 of file C4ObjectInfo.cpp.

92 {
93  // Set group file name; rename if necessary
94  char szTempGroup[_MAX_PATH_LEN];
95  SCopy(Name, szTempGroup, _MAX_PATH);
96  MakeFilenameFromTitle(szTempGroup);
97  SAppend(".oci", szTempGroup, _MAX_PATH); // TODO: File extension again, this time with a dot
98  if (!SEqualNoCase(Filename, szTempGroup))
99  {
100  if (!Filename[0])
101  {
102  // First time creation of file - make sure it's not a duplicate
103  SCopy(szTempGroup, Filename, _MAX_PATH);
104  while (hGroup.FindEntry(Filename))
105  {
106  // If a crew info of that name exists already, rename!
108  int32_t iFinNum = GetTrailingNumber(Filename);
109  int32_t iLen = SLen(Filename);
110  while (iLen && Inside(Filename[iLen-1], '0', '9'))
111  {
112  --iLen;
113  }
114  if (iLen > _MAX_PATH-22)
115  {
116  LogF("Error generating unique filename for %s(%s): Path overflow", Name, hGroup.GetFullName().getData());
117  break;
118  }
119  snprintf(Filename+iLen, 22, "%d", iFinNum+1);
120  EnforceExtension(Filename, "oci"); // TODO: File extension again
121  }
122  }
123  else
124  {
125  // Crew was renamed; file rename necessary, if the name is not blocked by another crew info
126  if (!hGroup.FindEntry(szTempGroup))
127  {
128  if (hGroup.Rename(Filename, szTempGroup))
129  {
130  SCopy(szTempGroup, Filename, _MAX_PATH);
131  }
132  else
133  {
134  // Could not rename. Not fatal; just use old file
135  LogF("Error adjusting crew info for %s into %s: Rename error from %s to %s!", Name, hGroup.GetFullName().getData(), Filename, szTempGroup);
136  }
137  }
138  }
139  }
140  // Open group
141  C4Group hTemp;
142  if (!hTemp.OpenAsChild(&hGroup, Filename, false, true))
143  {
144  return false;
145  }
146  // Custom rank image present?
147  if (pDefs && !fStoreTiny)
148  {
149  C4Def *pDef = pDefs->ID2Def(id);
150  if (pDef)
151  {
152  if (pDef->pRankSymbols)
153  {
154  C4FacetSurface fctRankSymbol;
156  {
157  fctRankSymbol.GetFace().SavePNG(hTemp, C4CFN_ClonkRank);
158  }
159  }
160  else
161  {
162  // definition does not have custom rank symbols: Remove any rank image from Clonk
163  hTemp.Delete(C4CFN_ClonkRank);
164  }
165  }
166  }
167 
168  // Save info to temp group
169  if (!C4ObjectInfoCore::Save(hTemp, pDefs))
170  {
171  hTemp.Close();
172  return false;
173  }
174  // Close temp group
175  hTemp.Close();
176  // Success
177  return true;
178 }
#define C4CFN_ClonkRank
Definition: C4Components.h:121
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:262
#define _MAX_PATH
#define _MAX_PATH_LEN
void SAppend(const char *szSource, char *szTarget, int iMaxL)
Definition: Standard.cpp:263
bool Inside(T ival, U lbound, V rbound)
Definition: Standard.h:43
size_t SLen(const char *sptr)
Definition: Standard.h:74
void MakeFilenameFromTitle(char *szTitle)
Definition: StdFile.cpp:426
void EnforceExtension(char *szFilename, const char *szExtension)
Definition: StdFile.cpp:286
void RemoveExtension(char *szFilename)
Definition: StdFile.cpp:303
int GetTrailingNumber(const char *strString)
Definition: StdFile.cpp:84
int32_t iNumRankSymbols
Definition: C4Def.h:190
C4FacetSurface * pRankSymbols
Definition: C4Def.h:189
C4Surface & GetFace()
Definition: C4FacetEx.h:52
bool Rename(const char *filename, const char *new_name)
Definition: C4Group.cpp:1735
StdStrBuf GetFullName() const
Definition: C4Group.cpp:2638
bool Delete(const char *files, bool recursive=false)
Definition: C4Group.cpp:1645
bool FindEntry(const char *wildcard, StdStrBuf *filename=nullptr, size_t *size=nullptr)
Definition: C4Group.cpp:2211
bool Save(C4Group &hGroup, class C4DefList *pDefs)
Definition: C4InfoCore.cpp:343
static bool DrawRankSymbol(C4FacetSurface *fctSymbol, int32_t iRank, C4Facet *pfctRankSymbols, int32_t iRankSymbolCount, bool fOwnSurface, int32_t iXOff=0, C4Facet *cgoDrawDirect=nullptr)
bool SavePNG(C4Group &hGroup, const char *szFilename, bool fSaveAlpha=true, bool fSaveOverlayOnly=false)
const char * getData() const
Definition: StdBuf.h:442

References _MAX_PATH, _MAX_PATH_LEN, C4CFN_ClonkRank, C4Group::Close(), C4Group::Delete(), C4RankSystem::DrawRankSymbol(), EnforceExtension(), Filename, C4Group::FindEntry(), StdStrBuf::getData(), C4FacetSurface::GetFace(), C4Group::GetFullName(), GetTrailingNumber(), C4DefList::ID2Def(), Inside(), C4Def::iNumRankSymbols, LogF(), MakeFilenameFromTitle(), C4ObjectInfoCore::Name, C4Group::OpenAsChild(), pDef, C4Def::pRankSymbols, C4ObjectInfoCore::Rank, RemoveExtension(), C4Group::Rename(), SAppend(), C4ObjectInfoCore::Save(), C4Surface::SavePNG(), SCopy(), SEqualNoCase(), and SLen().

Referenced by C4ObjectInfoList::Save().

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

◆ Save() [2/2]

bool C4ObjectInfoCore::Save ( C4Group hGroup,
class C4DefList pDefs 
)
inherited

Definition at line 343 of file C4InfoCore.cpp.

344 {
345  // Rank overload by def: Update any NextRank-stuff
346  if (pDefs)
347  {
348  UpdateCustomRanks(pDefs);
349  }
350  StdStrBuf Buffer;
351  if (!Decompile(Buffer))
352  {
353  return false;
354  }
355  if (!hGroup.Add(C4CFN_ObjectInfoCore, Buffer, false, true))
356  {
357  return false;
358  }
359  return true;
360 }
#define C4CFN_ObjectInfoCore
Definition: C4Components.h:47
bool Add(const char *filename, const char *entry_name)
Definition: C4Group.cpp:1621
bool Decompile(StdStrBuf &Buf)
Definition: C4InfoCore.cpp:403

References C4Group::Add(), C4CFN_ObjectInfoCore, C4ObjectInfoCore::Decompile(), and C4ObjectInfoCore::UpdateCustomRanks().

Referenced by Save().

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

◆ SetBirthday()

void C4ObjectInfo::SetBirthday ( )

Definition at line 228 of file C4ObjectInfo.cpp.

229 {
230  Birthday = time(nullptr);
231 }

References C4ObjectInfoCore::Birthday.

◆ UpdateCustomRanks()

void C4ObjectInfoCore::UpdateCustomRanks ( C4DefList pDefs)
protectedinherited

Definition at line 263 of file C4InfoCore.cpp.

264 {
265  assert(pDefs);
266  C4Def *pDef = pDefs->ID2Def(id);
267  if (!pDef) return;
268  if (pDef->pRankNames)
269  {
270  StdStrBuf sRank(pDef->pRankNames->GetRankName(Rank, false));
271  if (sRank)
272  {
273  sRankName.Copy(sRank);
274  }
275  // Next rank data
276  StdStrBuf sNextRank(pDef->pRankNames->GetRankName(Rank + 1, false));
277  if (sNextRank)
278  {
279  sNextRankName.Copy(sNextRank);
280  NextRankExp = pDef->pRankNames->Experience(Rank + 1);
281  }
282  else
283  {
284  // No more promotion possible by custom rank system
287  }
288  }
289  else
290  {
291  // Definition does not have custom rank names
293  NextRankExp = 0;
294  }
295 }

References StdStrBuf::Clear(), StdStrBuf::Copy(), C4RankSystem::EXP_NoPromotion, C4RankSystem::Experience(), C4RankSystem::GetRankName(), C4DefList::ID2Def(), C4ObjectInfoCore::NextRankExp, C4Def::pRankNames, C4ObjectInfoCore::Rank, C4ObjectInfoCore::sNextRankName, and C4ObjectInfoCore::sRankName.

Referenced by C4ObjectInfoCore::Default(), and C4ObjectInfoCore::Save().

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

Member Data Documentation

◆ Age

int32_t C4ObjectInfoCore::Age
inherited

◆ Birthday

int32_t C4ObjectInfoCore::Birthday
inherited

◆ ControlCount

int32_t C4ObjectInfo::ControlCount

Definition at line 38 of file C4ObjectInfo.h.

Referenced by C4Player::CountControl(), Default(), and C4Command::Finish().

◆ DeathCount

int32_t C4ObjectInfoCore::DeathCount
inherited

◆ DeathMessage

char C4ObjectInfoCore::DeathMessage[C4MaxDeathMsg+1]
inherited

◆ Experience

int32_t C4ObjectInfoCore::Experience
inherited

◆ ExtraData

C4ValueMapData C4ObjectInfoCore::ExtraData
inherited

Definition at line 49 of file C4InfoCore.h.

Referenced by C4ObjectInfoCore::CompileFunc(), and C4ObjectInfoCore::Default().

◆ Filename

char C4ObjectInfo::Filename[_MAX_PATH_LEN]

Definition at line 40 of file C4ObjectInfo.h.

Referenced by Default(), Load(), and Save().

◆ HasDied

bool C4ObjectInfo::HasDied

Definition at line 37 of file C4ObjectInfo.h.

Referenced by C4Object::AssignDeath(), Default(), and C4ObjectInfoList::GetIdle().

◆ id

◆ InAction

bool C4ObjectInfo::InAction

Definition at line 35 of file C4ObjectInfo.h.

Referenced by Default(), C4ObjectInfoList::GetIdle(), Recruit(), and Retire().

◆ InActionTime

int32_t C4ObjectInfo::InActionTime

Definition at line 36 of file C4ObjectInfo.h.

Referenced by Default(), C4Object::ExecLife(), Recruit(), and Retire().

◆ Name

◆ Next

◆ NextRankExp

int32_t C4ObjectInfoCore::NextRankExp
inherited

◆ Participation

int32_t C4ObjectInfoCore::Participation
inherited

◆ pDef

class C4Def* C4ObjectInfo::pDef

Definition at line 39 of file C4ObjectInfo.h.

Referenced by Clear(), Default(), Load(), Recruit(), and Save().

◆ Rank

◆ Rounds

int32_t C4ObjectInfoCore::Rounds
inherited

Definition at line 43 of file C4InfoCore.h.

Referenced by C4ObjectInfoCore::CompileFunc(), C4ObjectInfoCore::Default(), and Evaluate().

◆ sNextRankName

◆ sRankName

◆ TotalPlayingTime

int32_t C4ObjectInfoCore::TotalPlayingTime
inherited

◆ TypeName

char C4ObjectInfoCore::TypeName[C4MaxName+1+1]
inherited

Definition at line 45 of file C4InfoCore.h.

Referenced by C4ObjectInfoCore::CompileFunc(), and C4ObjectInfoCore::Default().

◆ WasInAction

bool C4ObjectInfo::WasInAction

Definition at line 34 of file C4ObjectInfo.h.

Referenced by Default(), Evaluate(), and Recruit().


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