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

#include <C4GameSave.h>

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

Public Member Functions

 C4GameSaveScenario (bool fForceExactLandscape, bool fSaveOrigin)
 
bool Save (const char *szFilename)
 
bool Save (C4Group &hToGroup, bool fKeepGroup)
 
bool SaveDesc (C4Group &hToGroup)
 
bool Close ()
 
C4GroupGetGroup ()
 

Protected Types

enum  SyncState { SyncNONE = 0, SyncScenario = 1, SyncSavegame = 2, SyncSynchronized = 3 }
 

Protected Member Functions

virtual bool GetSaveOrigin ()
 
virtual bool GetClearOrigin ()
 
virtual bool GetSaveDesc ()
 
virtual bool GetForceExactLandscape ()
 
virtual bool GetSaveScriptPlayers ()
 
virtual bool GetSaveScriptPlayerFiles ()
 
virtual bool GetSaveRuntimeData ()
 
virtual bool GetKeepTitle ()
 
virtual bool GetCopyScenario ()
 
virtual const char * GetSortOrder ()
 
virtual bool GetCreateSmallFile ()
 
virtual bool GetSaveUserPlayers ()
 
virtual bool GetSaveUserPlayerFiles ()
 
virtual void AdjustCore (C4Scenario &rC4S)
 
virtual bool WriteDesc (StdStrBuf &sBuf)
 
virtual bool SaveComponents ()
 
virtual bool OnSaving ()
 
bool IsExact ()
 
bool IsSynced ()
 
void WriteDescLineFeed (StdStrBuf &sBuf)
 
void WriteDescDate (StdStrBuf &sBuf, bool fRecord=false)
 
void WriteDescGameTime (StdStrBuf &sBuf)
 
void WriteDescDefinitions (StdStrBuf &sBuf)
 
void WriteDescNetworkClients (StdStrBuf &sBuf)
 
void WriteDescPlayers (StdStrBuf &sBuf, bool fByTeam, int32_t idTeam)
 
void WriteDescPlayers (StdStrBuf &sBuf)
 
void WriteDescLeague (StdStrBuf &sBuf, bool fLeague, const char *strLeagueName)
 
void WriteDescEngine (StdStrBuf &sBuf)
 

Protected Attributes

bool fForceExactLandscape
 
bool fSaveOrigin
 
C4GrouppSaveGroup
 
bool fOwnGroup
 
bool fInitial
 
enum C4GameSave::SyncState Sync
 

Detailed Description

Definition at line 112 of file C4GameSave.h.

Member Enumeration Documentation

enum C4GameSave::SyncState
protectedinherited
Enumerator
SyncNONE 
SyncScenario 
SyncSavegame 
SyncSynchronized 

Definition at line 48 of file C4GameSave.h.

49  {
50  SyncNONE = 0,
51  SyncScenario = 1, // save (eventually static) landscape and objects only to play as a separate scenario later
52  SyncSavegame = 2, // save all runtime data, so the scenario can be continued at a future date
53  SyncSynchronized = 3 // save exact runtime data to be network- or replay-save
54  } Sync; // sync is set by ctor
enum C4GameSave::SyncState Sync

Constructor & Destructor Documentation

C4GameSaveScenario::C4GameSaveScenario ( bool  fForceExactLandscape,
bool  fSaveOrigin 
)
inline

Definition at line 115 of file C4GameSave.h.

Member Function Documentation

virtual void C4GameSave::AdjustCore ( C4Scenario rC4S)
inlineprotectedvirtualinherited

Reimplemented in C4GameSaveNetwork, C4GameSaveRecord, and C4GameSaveSavegame.

Definition at line 72 of file C4GameSave.h.

72 {} // set specific C4S values
bool C4GameSave::Close ( )
inherited

Definition at line 446 of file C4GameSave.cpp.

References C4Group::Close(), C4GameSave::fOwnGroup, C4GameSave::GetSortOrder(), C4GameSave::pSaveGroup, and C4Group::Sort().

Referenced by C4Network2::CreateDynamic(), C4GameSave::Save(), C4Record::Start(), C4Record::StartStreaming(), and C4GameSave::~C4GameSave().

447 {
448  bool fSuccess = true;
449  // any group open?
450  if (pSaveGroup)
451  {
452  // sort group
453  const char *szSortOrder = GetSortOrder();
454  if (szSortOrder) pSaveGroup->Sort(szSortOrder);
455  // close if owned group
456  if (fOwnGroup)
457  {
458  fSuccess = !!pSaveGroup->Close();
459  delete pSaveGroup;
460  fOwnGroup = false;
461  }
462  pSaveGroup = nullptr;
463  }
464  return fSuccess;
465 }
bool fOwnGroup
Definition: C4GameSave.h:39
C4Group * pSaveGroup
Definition: C4GameSave.h:38
virtual const char * GetSortOrder()
Definition: C4GameSave.h:61
bool Close()
Definition: C4Group.cpp:755
bool Sort(const char *szSortList)
Definition: C4Group.cpp:1963

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool C4GameSaveScenario::GetClearOrigin ( )
inlineprotectedvirtual

Reimplemented from C4GameSave.

Definition at line 121 of file C4GameSave.h.

121 { return false; } // always keep existing origin
virtual bool C4GameSave::GetCopyScenario ( )
inlineprotectedvirtualinherited

Reimplemented in C4GameSaveNetwork, and C4GameSaveRecord.

Definition at line 60 of file C4GameSave.h.

60 { return true; } // return whether the savegame depends on the game scenario file
virtual bool C4GameSave::GetCreateSmallFile ( )
inlineprotectedvirtualinherited

Reimplemented in C4GameSaveNetwork, and C4GameSaveRecord.

Definition at line 62 of file C4GameSave.h.

62 { return false; } // return whether file size should be minimized
virtual bool C4GameSaveScenario::GetForceExactLandscape ( )
inlineprotectedvirtual

Reimplemented from C4GameSave.

Definition at line 123 of file C4GameSave.h.

References fForceExactLandscape, and C4GameSave::GetForceExactLandscape().

virtual bool GetForceExactLandscape()
Definition: C4GameSave.h:63

Here is the call graph for this function:

C4Group* C4GameSave::GetGroup ( )
inlineinherited

Definition at line 109 of file C4GameSave.h.

References C4GameSave::pSaveGroup.

109 { return pSaveGroup; } // get scenario saving group; only open between calls to Save() and Close()
C4Group * pSaveGroup
Definition: C4GameSave.h:38
virtual bool C4GameSave::GetKeepTitle ( )
inlineprotectedvirtualinherited

Reimplemented in C4GameSaveNetwork.

Definition at line 58 of file C4GameSave.h.

References C4GameSave::IsExact().

Referenced by C4GameSave::Save().

58 { return !IsExact(); } // whether original, localized title with image and icon shall be deleted
bool IsExact()
Definition: C4GameSave.h:78

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool C4GameSaveScenario::GetSaveDesc ( )
inlineprotectedvirtual

Reimplemented from C4GameSave.

Definition at line 122 of file C4GameSave.h.

122 { return false; } // should WriteDescData be executed in Save()-call?
virtual bool C4GameSaveScenario::GetSaveOrigin ( )
inlineprotectedvirtual

Reimplemented from C4GameSave.

Definition at line 120 of file C4GameSave.h.

References fSaveOrigin.

120 { return fSaveOrigin; }
virtual bool C4GameSave::GetSaveRuntimeData ( )
inlineprotectedvirtualinherited

Definition at line 57 of file C4GameSave.h.

References C4GameSave::fInitial.

Referenced by C4GameSave::GetForceExactLandscape(), and C4GameSave::Save().

57 { return !fInitial; } // save exact landscape, players, etc.
bool fInitial
Definition: C4GameSave.h:45

Here is the caller graph for this function:

virtual bool C4GameSaveScenario::GetSaveScriptPlayerFiles ( )
inlineprotectedvirtual

Reimplemented from C4GameSave.

Definition at line 125 of file C4GameSave.h.

125 { return true; } // script players are also saved; but user players aren't!
virtual bool C4GameSaveScenario::GetSaveScriptPlayers ( )
inlineprotectedvirtual

Reimplemented from C4GameSave.

Definition at line 124 of file C4GameSave.h.

124 { return true; } // script players are also saved; but user players aren't!
virtual bool C4GameSave::GetSaveUserPlayerFiles ( )
inlineprotectedvirtualinherited

Reimplemented in C4GameSaveSavegame.

Definition at line 68 of file C4GameSave.h.

References C4GameSave::IsExact().

68 { return IsExact(); } // return whether .ocp files of joined user players shall be put into the scenario
bool IsExact()
Definition: C4GameSave.h:78

Here is the call graph for this function:

virtual bool C4GameSave::GetSaveUserPlayers ( )
inlineprotectedvirtualinherited

Definition at line 66 of file C4GameSave.h.

References C4GameSave::IsExact().

66 { return IsExact(); } // return whether joined user players shall be saved into SavePlayerInfos
bool IsExact()
Definition: C4GameSave.h:78

Here is the call graph for this function:

virtual const char* C4GameSave::GetSortOrder ( )
inlineprotectedvirtualinherited

Definition at line 61 of file C4GameSave.h.

References C4FLS_Scenario.

Referenced by C4GameSave::Close().

61 { return C4FLS_Scenario; } // return nullptr to prevent sorting
#define C4FLS_Scenario
Definition: C4Components.h:188

Here is the caller graph for this function:

bool C4GameSave::IsExact ( )
inlineprotectedinherited

Definition at line 78 of file C4GameSave.h.

References C4GameSave::Sync, and C4GameSave::SyncSavegame.

Referenced by C4GameSave::GetForceExactLandscape(), C4GameSave::GetKeepTitle(), C4GameSave::GetSaveScriptPlayerFiles(), C4GameSave::GetSaveScriptPlayers(), C4GameSave::GetSaveUserPlayerFiles(), and C4GameSave::GetSaveUserPlayers().

78 { return Sync>=SyncSavegame; } // exact save (players, always exact landscape, etc.)
enum C4GameSave::SyncState Sync

Here is the caller graph for this function:

bool C4GameSave::IsSynced ( )
inlineprotectedinherited

Definition at line 79 of file C4GameSave.h.

References C4GameSave::Sync, and C4GameSave::SyncSynchronized.

79 { return Sync>=SyncSynchronized; } // synchronized
enum C4GameSave::SyncState Sync
virtual bool C4GameSave::OnSaving ( )
inlineprotectedvirtualinherited

Reimplemented in C4GameSaveSavegame.

Definition at line 75 of file C4GameSave.h.

Referenced by C4GameSave::Save().

75 { return true; } // callback for special actions to be performed when saving (like, add sync)

Here is the caller graph for this function:

bool C4GameSave::Save ( const char *  szFilename)
inherited

Definition at line 397 of file C4GameSave.cpp.

References C4GameSave::Close(), LoadResStr(), and LogF().

Referenced by C4Network2::CreateDynamic(), C4Game::QuickSave(), C4Console::SaveGame(), and C4Console::SaveScenario().

398 {
399  // close any previous
400  Close();
401  // create group
402  C4Group *pLSaveGroup = new C4Group();
403  if (!SaveCreateGroup(szFilename, *pLSaveGroup))
404  {
405  LogF(LoadResStr("IDS_ERR_SAVE_TARGETGRP"), szFilename ? szFilename : "nullptr!");
406  delete pLSaveGroup;
407  return false;
408  }
409  // save to it
410  return Save(*pLSaveGroup, true);
411 }
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool Close()
Definition: C4GameSave.cpp:446
bool Save(const char *szFilename)
Definition: C4GameSave.cpp:397
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:253

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GameSave::Save ( C4Group hToGroup,
bool  fKeepGroup 
)
inherited

Definition at line 413 of file C4GameSave.cpp.

References C4CFN_Info, C4CFN_PlayerFiles, C4CFN_ScenarioDesc, C4CFN_ScenarioIcon, C4CFN_ScenarioTitle, C4CFN_Titles, C4GameSave::Close(), C4Group::Delete(), FormatString(), C4GameSave::fOwnGroup, C4GameSave::GetKeepTitle(), C4GameSave::GetSaveDesc(), C4GameSave::GetSaveRuntimeData(), LoadResStr(), Log(), C4GameSave::OnSaving(), C4GameSave::pSaveGroup, C4GameSave::SaveComponents(), and C4GameSave::SaveDesc().

414 {
415  // close any previous
416  Close();
417  // set group
418  pSaveGroup = &hToGroup; fOwnGroup = fKeepGroup;
419  // PreSave-actions (virtual call)
420  if (!OnSaving()) return false;
421  // always save core
422  if (!SaveCore()) { Log(LoadResStr("IDS_ERR_SAVE_CORE")); return false; }
423  // cleanup group
425  // remove: Title text, image and icon if specified
426  if (!GetKeepTitle())
427  {
433  }
434  // save additional runtime data
435  if (GetSaveRuntimeData()) if (!SaveRuntimeData()) return false;
436  // Desc
437  if (GetSaveDesc())
438  if (!SaveDesc(*pSaveGroup))
439  Log(LoadResStr("IDS_ERR_SAVE_DESC")); /* nofail */
440  // save specialized components (virtual call)
441  if (!SaveComponents()) return false;
442  // done, success
443  return true;
444 }
bool fOwnGroup
Definition: C4GameSave.h:39
C4Group * pSaveGroup
Definition: C4GameSave.h:38
bool Delete(const char *szFiles, bool fRecursive=false)
Definition: C4Group.cpp:1334
#define C4CFN_Titles
Definition: C4Components.h:146
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
#define C4CFN_PlayerFiles
Definition: C4Components.h:167
#define C4CFN_Info
Definition: C4Components.h:70
bool SaveDesc(C4Group &hToGroup)
Definition: C4GameSave.cpp:234
bool Close()
Definition: C4GameSave.cpp:446
virtual bool GetSaveDesc()
Definition: C4GameSave.h:59
virtual bool GetKeepTitle()
Definition: C4GameSave.h:58
virtual bool GetSaveRuntimeData()
Definition: C4GameSave.h:57
virtual bool SaveComponents()
Definition: C4GameSave.h:74
#define C4CFN_ScenarioDesc
Definition: C4Components.h:88
virtual bool OnSaving()
Definition: C4GameSave.h:75
bool Log(const char *szMessage)
Definition: C4Log.cpp:195
#define C4CFN_ScenarioIcon
Definition: C4Components.h:85
#define C4CFN_ScenarioTitle
Definition: C4Components.h:84
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:277

Here is the call graph for this function:

virtual bool C4GameSave::SaveComponents ( )
inlineprotectedvirtualinherited

Reimplemented in C4GameSaveRecord, and C4GameSaveSavegame.

Definition at line 74 of file C4GameSave.h.

Referenced by C4GameSave::Save().

74 { return true; } // save (or remove) custom components for specialization

Here is the caller graph for this function:

bool C4GameSave::SaveDesc ( C4Group hToGroup)
inherited

Definition at line 234 of file C4GameSave.cpp.

References C4Group::Add(), StdStrBuf::Append(), C4CFN_ScenarioDesc, Config, StdStrBuf::Format(), Game, C4Config::General, StdStrBuf::getData(), C4ConfigGeneral::Language, LineFeed, C4Game::ScenarioTitle, SCopyUntil(), and C4GameSave::WriteDesc().

Referenced by C4GameSave::Save(), and C4Record::Stop().

235 {
236  // Unfortunately, there's no way to prealloc the buffer in an appropriate size
237  StdStrBuf sBuffer;
238 
239  // Scenario title
240  sBuffer.Append(Game.ScenarioTitle.getData());
241  sBuffer.Append(LineFeed LineFeed);
242 
243  // OK; each specializations has its own desc format
244  WriteDesc(sBuffer);
245 
246  // Generate Filename
247  StdStrBuf sFilename; char szLang[3];
248  SCopyUntil(Config.General.Language, szLang, ',', 2);
249  sFilename.Format(C4CFN_ScenarioDesc,szLang);
250 
251  // Save to file
252  return !!hToGroup.Add(sFilename.getData(),sBuffer,false,true);
253 }
const char * getData() const
Definition: StdBuf.h:450
C4Config Config
Definition: C4Config.cpp:831
C4Game Game
Definition: C4Globals.cpp:52
C4ConfigGeneral General
Definition: C4Config.h:252
StdCopyStrBuf ScenarioTitle
Definition: C4Game.h:105
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:181
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:527
char Language[CFG_MaxString+1]
Definition: C4Config.h:37
#define LineFeed
Definition: Standard.h:151
#define C4CFN_ScenarioDesc
Definition: C4Components.h:88
bool Add(const char *szFile, const char *szAddAs)
Definition: C4Group.cpp:1316
virtual bool WriteDesc(StdStrBuf &sBuf)
Definition: C4GameSave.h:73
void SCopyUntil(const char *szSource, char *sTarget, char cUntil, int iMaxL, int iIndex)
Definition: Standard.cpp:138

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool C4GameSave::WriteDesc ( StdStrBuf sBuf)
inlineprotectedvirtualinherited

Reimplemented in C4GameSaveRecord, and C4GameSaveSavegame.

Definition at line 73 of file C4GameSave.h.

Referenced by C4GameSave::SaveDesc().

73 { return true; } // write desc (contents only)

Here is the caller graph for this function:

void C4GameSave::WriteDescDate ( StdStrBuf sBuf,
bool  fRecord = false 
)
protectedinherited

Definition at line 261 of file C4GameSave.cpp.

References StdStrBuf::AppendFormat(), C4Network2::isEnabled(), LoadResStr(), Network, and C4GameSave::WriteDescLineFeed().

Referenced by C4GameSaveSavegame::WriteDesc(), and C4GameSaveRecord::WriteDesc().

262 {
263  // write local time/date
264  time_t tTime; time(&tTime);
265  struct tm *pLocalTime;
266  pLocalTime=localtime(&tTime);
267  sBuf.AppendFormat(LoadResStr(fRecord ? "IDS_DESC_DATEREC" : (::Network.isEnabled() ? "IDS_DESC_DATENET" : "IDS_DESC_DATE")),
268  pLocalTime->tm_mday,
269  pLocalTime->tm_mon+1,
270  pLocalTime->tm_year+1900,
271  pLocalTime->tm_hour,
272  pLocalTime->tm_min);
273  WriteDescLineFeed(sBuf);
274 }
void WriteDescLineFeed(StdStrBuf &sBuf)
Definition: C4GameSave.cpp:255
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void AppendFormat(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:197
C4Network2 Network
Definition: C4Globals.cpp:53
bool isEnabled() const
Definition: C4Network2.h:203

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GameSave::WriteDescDefinitions ( StdStrBuf sBuf)
protectedinherited

Definition at line 303 of file C4GameSave.cpp.

References _MAX_PATH, StdStrBuf::Append(), C4Config::AtRelativePath(), Config, StdStrBuf::Copy(), C4Game::DefinitionFilenames, Game, LoadResStr(), SGetModule(), and C4GameSave::WriteDescLineFeed().

Referenced by C4GameSaveSavegame::WriteDesc(), and C4GameSaveRecord::WriteDesc().

304 {
305  // Definition specs
306  if (Game.DefinitionFilenames[0])
307  {
308  char szDef[_MAX_PATH+1];
309  // Desc
310  sBuf.Append(LoadResStr("IDS_DESC_DEFSPECS"));
311  // Get definition modules
312  for (int cnt=0; SGetModule(Game.DefinitionFilenames,cnt,szDef); cnt++)
313  {
314  // Get exe relative path
315  StdStrBuf sDefFilename;
316  sDefFilename.Copy(Config.AtRelativePath(szDef));
317  // Append comma
318  if (cnt>0) sBuf.Append(", ");
319  // Apend to desc
320  sBuf.Append(sDefFilename);
321  }
322  // End of line
323  WriteDescLineFeed(sBuf);
324  }
325 }
bool SGetModule(const char *szList, int iIndex, char *sTarget, int iSize)
Definition: Standard.cpp:503
C4Config Config
Definition: C4Config.cpp:831
C4Game Game
Definition: C4Globals.cpp:52
#define _MAX_PATH
void WriteDescLineFeed(StdStrBuf &sBuf)
Definition: C4GameSave.cpp:255
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:527
char DefinitionFilenames[20 *_MAX_PATH+1]
Definition: C4Game.h:107
const char * AtRelativePath(const char *szFilename)
Definition: C4Config.cpp:654
void Copy()
Definition: StdBuf.h:475

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GameSave::WriteDescEngine ( StdStrBuf sBuf)
protectedinherited

Definition at line 287 of file C4GameSave.cpp.

References StdStrBuf::AppendFormat(), LoadResStr(), sprintf, and C4GameSave::WriteDescLineFeed().

Referenced by C4GameSaveRecord::WriteDesc().

288 {
289  char ver[32]; sprintf(ver, "%d.%d", (int)C4XVER1, (int)C4XVER2);
290  sBuf.AppendFormat(LoadResStr("IDS_DESC_VERSION"), ver);
291  WriteDescLineFeed(sBuf);
292 }
#define sprintf
Definition: Standard.h:171
void WriteDescLineFeed(StdStrBuf &sBuf)
Definition: C4GameSave.cpp:255
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void AppendFormat(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:197

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GameSave::WriteDescGameTime ( StdStrBuf sBuf)
protectedinherited

Definition at line 276 of file C4GameSave.cpp.

References StdStrBuf::AppendFormat(), Game, LoadResStr(), C4Game::Time, and C4GameSave::WriteDescLineFeed().

Referenced by C4GameSaveSavegame::WriteDesc(), and C4GameSaveRecord::WriteDesc().

277 {
278  // Write game duration
279  if (Game.Time)
280  {
281  sBuf.AppendFormat(LoadResStr("IDS_DESC_DURATION"),
282  Game.Time/3600,(Game.Time%3600)/60,Game.Time%60);
283  WriteDescLineFeed(sBuf);
284  }
285 }
C4Game Game
Definition: C4Globals.cpp:52
void WriteDescLineFeed(StdStrBuf &sBuf)
Definition: C4GameSave.cpp:255
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void AppendFormat(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:197
int32_t Time
Definition: C4Game.h:133

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GameSave::WriteDescLeague ( StdStrBuf sBuf,
bool  fLeague,
const char *  strLeagueName 
)
protectedinherited

Definition at line 294 of file C4GameSave.cpp.

References StdStrBuf::AppendFormat(), LoadResStr(), and C4GameSave::WriteDescLineFeed().

Referenced by C4GameSaveRecord::WriteDesc().

295 {
296  if (fLeague)
297  {
298  sBuf.AppendFormat(LoadResStr("IDS_PRC_LEAGUE"), strLeagueName);
299  WriteDescLineFeed(sBuf);
300  }
301 }
void WriteDescLineFeed(StdStrBuf &sBuf)
Definition: C4GameSave.cpp:255
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void AppendFormat(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:197

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GameSave::WriteDescLineFeed ( StdStrBuf sBuf)
protectedinherited

Definition at line 255 of file C4GameSave.cpp.

References StdStrBuf::Append(), and LineFeed.

Referenced by C4GameSave::WriteDescDate(), C4GameSave::WriteDescDefinitions(), C4GameSave::WriteDescEngine(), C4GameSave::WriteDescGameTime(), C4GameSave::WriteDescLeague(), C4GameSave::WriteDescNetworkClients(), and C4GameSave::WriteDescPlayers().

256 {
257  // paragraph end + cosmetics
258  sBuf.Append(LineFeed LineFeed);
259 }
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:527
#define LineFeed
Definition: Standard.h:151

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GameSave::WriteDescNetworkClients ( StdStrBuf sBuf)
protectedinherited

Definition at line 327 of file C4GameSave.cpp.

References StdStrBuf::Append(), C4Network2::Clients, C4Network2ClientList::GetNextClient(), LoadResStr(), Network, and C4GameSave::WriteDescLineFeed().

Referenced by C4GameSaveSavegame::WriteDesc(), and C4GameSaveRecord::WriteDesc().

328 {
329  // Desc
330  sBuf.Append(LoadResStr("IDS_DESC_CLIENTS"));
331  // Client names
332  for (C4Network2Client *pClient=::Network.Clients.GetNextClient(nullptr); pClient; pClient=::Network.Clients.GetNextClient(pClient))
333  { sBuf.Append(", "); sBuf.Append(pClient->getName()); }
334  // End of line
335  WriteDescLineFeed(sBuf);
336 }
C4Network2Client * GetNextClient(C4Network2Client *pClient)
void WriteDescLineFeed(StdStrBuf &sBuf)
Definition: C4GameSave.cpp:255
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4Network2 Network
Definition: C4Globals.cpp:53
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:527
C4Network2ClientList Clients
Definition: C4Network2.h:116

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GameSave::WriteDescPlayers ( StdStrBuf sBuf,
bool  fByTeam,
int32_t  idTeam 
)
protectedinherited

Definition at line 338 of file C4GameSave.cpp.

References StdStrBuf::Append(), StdStrBuf::AppendFormat(), Game, C4Team::GetName(), C4PlayerInfo::GetName(), C4PlayerInfoList::GetPlayerInfoByIndex(), C4PlayerInfo::GetTeam(), C4TeamList::GetTeamByID(), C4PlayerInfo::HasJoined(), C4PlayerInfo::IsInvisible(), C4PlayerInfo::IsRemoved(), C4Game::PlayerInfos, C4Game::Teams, and C4GameSave::WriteDescLineFeed().

Referenced by C4GameSaveSavegame::WriteDesc(), C4GameSaveRecord::WriteDesc(), and C4GameSave::WriteDescPlayers().

339 {
340  // write out all players; only if they match the given team if specified
341  C4PlayerInfo *pPlr; bool fAnyPlrWritten = false;
342  for (int i = 0; (pPlr = Game.PlayerInfos.GetPlayerInfoByIndex(i)); i++)
343  if (pPlr->HasJoined() && !pPlr->IsRemoved() && !pPlr->IsInvisible())
344  {
345  if (fByTeam)
346  {
347  if (idTeam)
348  {
349  // match team
350  if (pPlr->GetTeam() != idTeam) continue;
351  }
352  else
353  {
354  // must be in no known team
355  if (Game.Teams.GetTeamByID(pPlr->GetTeam())) continue;
356  }
357  }
358  if (fAnyPlrWritten)
359  sBuf.Append(", ");
360  else if (fByTeam && idTeam)
361  {
362  C4Team *pTeam = Game.Teams.GetTeamByID(idTeam);
363  if (pTeam) sBuf.AppendFormat("%s: ", pTeam->GetName());
364  }
365  sBuf.Append(pPlr->GetName());
366  fAnyPlrWritten = true;
367  }
368  if (fAnyPlrWritten) WriteDescLineFeed(sBuf);
369 }
const char * GetName() const
Definition: C4PlayerInfo.h:160
C4Game Game
Definition: C4Globals.cpp:52
Definition: C4Teams.h:30
C4PlayerInfo * GetPlayerInfoByIndex(int32_t index) const
bool IsInvisible() const
Definition: C4PlayerInfo.h:178
C4Team * GetTeamByID(int32_t iID) const
Definition: C4Teams.cpp:384
void WriteDescLineFeed(StdStrBuf &sBuf)
Definition: C4GameSave.cpp:255
C4TeamList & Teams
Definition: C4Game.h:72
void AppendFormat(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:197
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:527
int32_t GetTeam() const
Definition: C4PlayerInfo.h:198
bool IsRemoved() const
Definition: C4PlayerInfo.h:167
const char * GetName() const
Definition: C4Teams.h:65
C4PlayerInfoList & PlayerInfos
Definition: C4Game.h:73
bool HasJoined() const
Definition: C4PlayerInfo.h:168

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GameSave::WriteDescPlayers ( StdStrBuf sBuf)
protectedinherited

Definition at line 371 of file C4GameSave.cpp.

References StdStrBuf::Append(), Game, C4Team::GetID(), C4PlayerInfoList::GetPlayerCount(), C4TeamList::GetTeamByIndex(), C4TeamList::IsAutoGenerateTeams(), C4TeamList::IsMultiTeams(), LoadResStr(), C4Game::PlayerInfos, C4Game::Teams, C4GameSave::WriteDescLineFeed(), and C4GameSave::WriteDescPlayers().

372 {
373  // New style using Game.PlayerInfos
375  {
376  sBuf.Append(LoadResStr("IDS_DESC_PLRS"));
378  {
379  // Teams defined: Print players sorted by teams
380  WriteDescLineFeed(sBuf);
381  C4Team *pTeam; int32_t i=0;
382  while ((pTeam = Game.Teams.GetTeamByIndex(i++)))
383  {
384  WriteDescPlayers(sBuf, true, pTeam->GetID());
385  }
386  // Finally, print out players outside known teams (those can only be achieved by script using SetPlayerTeam)
387  WriteDescPlayers(sBuf, true, 0);
388  }
389  else
390  {
391  // No teams defined: Print all players that have ever joined
392  WriteDescPlayers(sBuf, false, 0);
393  }
394  }
395 }
int32_t GetID() const
Definition: C4Teams.h:66
int32_t GetPlayerCount() const
C4Game Game
Definition: C4Globals.cpp:52
Definition: C4Teams.h:30
bool IsAutoGenerateTeams() const
Definition: C4Teams.h:173
bool IsMultiTeams() const
Definition: C4Teams.h:163
void WriteDescLineFeed(StdStrBuf &sBuf)
Definition: C4GameSave.cpp:255
C4TeamList & Teams
Definition: C4Game.h:72
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:527
C4Team * GetTeamByIndex(int32_t iIndex) const
Definition: C4Teams.cpp:405
C4PlayerInfoList & PlayerInfos
Definition: C4Game.h:73
void WriteDescPlayers(StdStrBuf &sBuf, bool fByTeam, int32_t idTeam)
Definition: C4GameSave.cpp:338

Here is the call graph for this function:

Member Data Documentation

bool C4GameSaveScenario::fForceExactLandscape
protected

Definition at line 118 of file C4GameSave.h.

Referenced by GetForceExactLandscape().

bool C4GameSave::fInitial
protectedinherited
bool C4GameSave::fOwnGroup
protectedinherited

Definition at line 39 of file C4GameSave.h.

Referenced by C4GameSave::Close(), and C4GameSave::Save().

bool C4GameSaveScenario::fSaveOrigin
protected

Definition at line 119 of file C4GameSave.h.

Referenced by GetSaveOrigin().

enum C4GameSave::SyncState C4GameSave::Sync
protectedinherited

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