OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4GameSave.cpp
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 // game saving functionality
17 
18 #include "C4Include.h"
19 #include "control/C4GameSave.h"
20 
21 #include "c4group/C4Components.h"
22 #include "game/C4Game.h"
23 #include "lib/C4Log.h"
24 #include "landscape/C4Landscape.h"
25 #include "landscape/C4PXS.h"
26 #include "landscape/C4MassMover.h"
27 #include "player/C4PlayerList.h"
28 #include "control/C4RoundResults.h"
29 #include "control/C4Record.h"
30 #include "C4Version.h"
32 #include "script/C4Value.h"
33 #include "network/C4Network2.h"
34 
35 // *** C4GameSave main class
36 
37 bool C4GameSave::SaveCreateGroup(const char *szFilename, C4Group &hUseGroup)
38 {
39  // erase any previous item (2do: work in C4Groups?)
40  EraseItem(szFilename);
41  // copy from previous group?
42  if (GetCopyScenario())
43  if (!ItemIdentical(Game.ScenarioFilename, szFilename))
44  if (!C4Group_CopyItem(Game.ScenarioFilename, szFilename))
45  { LogF(LoadResStr("IDS_CNS_SAVEASERROR"), szFilename); return false; }
46  // open it
47  if (!hUseGroup.Open(szFilename, !GetCopyScenario()))
48  {
49  EraseItem(szFilename);
50  LogF(LoadResStr("IDS_CNS_SAVEASERROR"), szFilename);
51  return false;
52  }
53  // done, success
54  return true;
55 }
56 
57 bool C4GameSave::SaveCore()
58 {
59  // base on original, current core
60  rC4S = Game.C4S;
61  // Always mark current engine version
62  rC4S.Head.C4XVer[0]=C4XVER1; rC4S.Head.C4XVer[1]=C4XVER2;
63  // Some flags are not to be set for initial settings:
64  // They depend on whether specific runtime data is present, which may simply not be stored into initial
65  // saves, because they rely on any data present and up-to-date within the scenario!
66  if (!fInitial)
67  {
68  // NoInitialize: Marks whether object data is contained and not to be created from core
69  rC4S.Head.NoInitialize = true;
70  // the SaveGame-value, despite it's name, marks whether exact runtime data is contained
71  // the flag must not be altered for pure
73  }
74  // some values relevant for synced saves only
75  if (IsExact())
76  {
78  }
79  // reset some network flags
80  rC4S.Head.NetworkGame=0;
81  // Title in language game was started in (not: save scenarios and net references)
82  if (!GetKeepTitle())
83  {
85  }
86  // some adjustments for everything but saved scenarios
87  if (IsExact())
88  {
89  // Store used definitions
91  // Save game parameters
92  if (!Game.Parameters.Save(*pSaveGroup, &Game.C4S)) return false;
93  }
94  // clear MissionAccess in save games and records (sulai)
95  rC4S.Head.MissionAccess.clear();
96  // store origin
97  if (GetSaveOrigin())
98  {
99  // keep if assigned already (e.g., when doing a record of a savegame)
100  if (!rC4S.Head.Origin.getLength())
101  {
104  }
105  }
106  else if (GetClearOrigin())
107  rC4S.Head.Origin.Clear();
108  // adjust specific values (virtual call)
109  AdjustCore(rC4S);
110  // Save scenario core
111  return !!rC4S.Save(*pSaveGroup);
112 }
113 
114 bool C4GameSave::SaveScenarioSections()
115 {
116  // any scenario sections?
117  if (!Game.pScenarioSections) return true;
118  // prepare section filename
119  int iWildcardPos = SCharPos('*', C4CFN_ScenarioSections);
120  char fn[_MAX_FNAME+1];
121  // save all modified sections
122  for (C4ScenarioSection *pSect = Game.pScenarioSections; pSect; pSect = pSect->pNext)
123  {
124  // compose section filename
126  SDelete(fn, 1, iWildcardPos); SInsert(fn, pSect->name.getData(), iWildcardPos);
127  // do not save self, because that is implied in CurrentScenarioSection and the main landscape/object data
128  if (pSect == Game.pCurrentScenarioSection)
129  pSaveGroup->DeleteEntry(fn);
130  else if (pSect->fModified)
131  {
132  // modified section: delete current
133  pSaveGroup->DeleteEntry(fn);
134  // replace by new
135  pSaveGroup->Add(pSect->temp_filename.getData(), fn);
136  }
137  }
138  // done, success
139  return true;
140 }
141 
142 bool C4GameSave::SaveLandscape()
143 {
144  // exact?
146  {
147  C4DebugRecOff DBGRECOFF;
148  // Landscape
149  bool fSuccess;
151  fSuccess = !!::Landscape.Save(*pSaveGroup);
152  else
153  fSuccess = !!::Landscape.SaveDiff(*pSaveGroup, !IsSynced());
154  if (!fSuccess) return false;
155  DBGRECOFF.Clear();
156  // PXS
157  if (!::PXS.Save(*pSaveGroup)) return false;
158  // MassMover (create copy, may not modify running data)
159  C4MassMoverSet MassMoverSet;
160  MassMoverSet.Copy(::MassMover);
161  if (!MassMoverSet.Save(*pSaveGroup)) return false;
162  // Material enumeration
163  if (!::MaterialMap.SaveEnumeration(*pSaveGroup)) return false;
164  }
165  // static / dynamic
167  {
168  // static map
169  // remove old-style landscape.bmp
171  // save materials if not already done
172  if (!GetForceExactLandscape())
173  {
174  // save map
175  if (!::Landscape.SaveMap(*pSaveGroup)) return false;
176  // save textures (if changed)
177  if (!::Landscape.SaveTextures(*pSaveGroup)) return false;
178  }
179  }
180  else if (::Landscape.GetMode() != LandscapeMode::Exact)
181  {
182  // dynamic map by landscape.txt or scenario core: nothing to save
183  // in fact, it doesn't even make much sense to save the Objects.txt
184  // but the user pressed save after all...
185  }
186  return true;
187 }
188 
189 bool C4GameSave::SaveRuntimeData()
190 {
191  // Game.txt data (general runtime data and objects)
192  C4ValueNumbers numbers;
193  if (!Game.SaveData(*pSaveGroup, false, IsExact(), IsSynced(), &numbers))
194  { Log(LoadResStr("IDS_ERR_SAVE_RUNTIMEDATA")); return false; }
195  // scenario sections (exact only)
196  if (IsExact()) if (!SaveScenarioSections())
197  { Log(LoadResStr("IDS_ERR_SAVE_SCENSECTIONS")); return false; }
198  // landscape
199  if (!SaveLandscape()) { Log(LoadResStr("IDS_ERR_SAVE_LANDSCAPE")); return false; }
200  // Round results
202  { Log(LoadResStr("IDS_ERR_ERRORSAVINGROUNDRESULTS")); return false; }
203  // Teams
204  if (!Game.Teams.Save(*pSaveGroup))
205  { Log(LoadResStr(LoadResStr("IDS_ERR_ERRORSAVINGTEAMS"))); return false; }
207  {
208  // player infos
209  // the stored player info filenames will point into the scenario file, and no resource information
210  // will be saved. PlayerInfo must be saved first, because those will generate the storage filenames to be used by
211  // C4PlayerList
212  C4PlayerInfoList RestoreInfos;
214  if (!RestoreInfos.Save(*pSaveGroup, C4CFN_SavePlayerInfos))
215  { Log(LoadResStr("IDS_ERR_SAVE_RESTOREPLAYERINFOS")); return false; }
216  // Players
217  // this will save the player files to the savegame scenario group only
218  // synchronization to the original player files will be done in global game
219  // synchronization (via control queue)
221  {
222  if (!::Players.Save((*pSaveGroup), GetCreateSmallFile(), RestoreInfos))
223  { Log(LoadResStr("IDS_ERR_SAVE_PLAYERS")); return false; }
224  }
225  }
226  else
227  {
228  // non-exact runtime data: remove any exact files
229  // No player files
232  }
233  // done, success
234  return true;
235 }
236 
238 {
239  // Unfortunately, there's no way to prealloc the buffer in an appropriate size
240  StdStrBuf sBuffer;
241 
242  // Scenario title
243  sBuffer.Append(Game.ScenarioTitle.getData());
244  sBuffer.Append(LineFeed LineFeed);
245 
246  // OK; each specializations has its own desc format
247  WriteDesc(sBuffer);
248 
249  // Generate Filename
250  StdStrBuf sFilename; char szLang[3];
251  SCopyUntil(Config.General.Language, szLang, ',', 2);
252  sFilename.Format(C4CFN_ScenarioDesc,szLang);
253 
254  // Save to file
255  return !!hToGroup.Add(sFilename.getData(),sBuffer,false,true);
256 }
257 
259 {
260  // paragraph end + cosmetics
261  sBuf.Append(LineFeed LineFeed);
262 }
263 
264 void C4GameSave::WriteDescDate(StdStrBuf &sBuf, bool fRecord)
265 {
266  // write local time/date
267  time_t tTime; time(&tTime);
268  struct tm *pLocalTime;
269  pLocalTime=localtime(&tTime);
270  sBuf.AppendFormat(LoadResStr(fRecord ? "IDS_DESC_DATEREC" : (::Network.isEnabled() ? "IDS_DESC_DATENET" : "IDS_DESC_DATE")),
271  pLocalTime->tm_mday,
272  pLocalTime->tm_mon+1,
273  pLocalTime->tm_year+1900,
274  pLocalTime->tm_hour,
275  pLocalTime->tm_min);
276  WriteDescLineFeed(sBuf);
277 }
278 
280 {
281  // Write game duration
282  if (Game.Time)
283  {
284  sBuf.AppendFormat(LoadResStr("IDS_DESC_DURATION"),
285  Game.Time/3600,(Game.Time%3600)/60,Game.Time%60);
286  WriteDescLineFeed(sBuf);
287  }
288 }
289 
291 {
292  char ver[32]; sprintf(ver, "%d.%d", (int)C4XVER1, (int)C4XVER2);
293  sBuf.AppendFormat(LoadResStr("IDS_DESC_VERSION"), ver);
294  WriteDescLineFeed(sBuf);
295 }
296 
297 void C4GameSave::WriteDescLeague(StdStrBuf &sBuf, bool fLeague, const char *strLeagueName)
298 {
299  if (fLeague)
300  {
301  sBuf.AppendFormat(LoadResStr("IDS_PRC_LEAGUE"), strLeagueName);
302  WriteDescLineFeed(sBuf);
303  }
304 }
305 
307 {
308  // Definition specs
309  if (Game.DefinitionFilenames[0])
310  {
311  char szDef[_MAX_PATH+1];
312  // Desc
313  sBuf.Append(LoadResStr("IDS_DESC_DEFSPECS"));
314  // Get definition modules
315  for (int cnt=0; SGetModule(Game.DefinitionFilenames,cnt,szDef); cnt++)
316  {
317  // Get exe relative path
318  StdStrBuf sDefFilename;
319  sDefFilename.Copy(Config.AtRelativePath(szDef));
320  // Append comma
321  if (cnt>0) sBuf.Append(", ");
322  // Apend to desc
323  sBuf.Append(sDefFilename);
324  }
325  // End of line
326  WriteDescLineFeed(sBuf);
327  }
328 }
329 
331 {
332  // Desc
333  sBuf.Append(LoadResStr("IDS_DESC_CLIENTS"));
334  // Client names
335  for (C4Network2Client *pClient=::Network.Clients.GetNextClient(nullptr); pClient; pClient=::Network.Clients.GetNextClient(pClient))
336  { sBuf.Append(", "); sBuf.Append(pClient->getName()); }
337  // End of line
338  WriteDescLineFeed(sBuf);
339 }
340 
341 void C4GameSave::WriteDescPlayers(StdStrBuf &sBuf, bool fByTeam, int32_t idTeam)
342 {
343  // write out all players; only if they match the given team if specified
344  C4PlayerInfo *pPlr; bool fAnyPlrWritten = false;
345  for (int i = 0; (pPlr = Game.PlayerInfos.GetPlayerInfoByIndex(i)); i++)
346  if (pPlr->HasJoined() && !pPlr->IsRemoved() && !pPlr->IsInvisible())
347  {
348  if (fByTeam)
349  {
350  if (idTeam)
351  {
352  // match team
353  if (pPlr->GetTeam() != idTeam) continue;
354  }
355  else
356  {
357  // must be in no known team
358  if (Game.Teams.GetTeamByID(pPlr->GetTeam())) continue;
359  }
360  }
361  if (fAnyPlrWritten)
362  sBuf.Append(", ");
363  else if (fByTeam && idTeam)
364  {
365  C4Team *pTeam = Game.Teams.GetTeamByID(idTeam);
366  if (pTeam) sBuf.AppendFormat("%s: ", pTeam->GetName());
367  }
368  sBuf.Append(pPlr->GetName());
369  fAnyPlrWritten = true;
370  }
371  if (fAnyPlrWritten) WriteDescLineFeed(sBuf);
372 }
373 
375 {
376  // New style using Game.PlayerInfos
378  {
379  sBuf.Append(LoadResStr("IDS_DESC_PLRS"));
381  {
382  // Teams defined: Print players sorted by teams
383  WriteDescLineFeed(sBuf);
384  C4Team *pTeam; int32_t i=0;
385  while ((pTeam = Game.Teams.GetTeamByIndex(i++)))
386  {
387  WriteDescPlayers(sBuf, true, pTeam->GetID());
388  }
389  // Finally, print out players outside known teams (those can only be achieved by script using SetPlayerTeam)
390  WriteDescPlayers(sBuf, true, 0);
391  }
392  else
393  {
394  // No teams defined: Print all players that have ever joined
395  WriteDescPlayers(sBuf, false, 0);
396  }
397  }
398 }
399 
400 bool C4GameSave::Save(const char *szFilename)
401 {
402  // close any previous
403  Close();
404  // create group
405  C4Group *pLSaveGroup = new C4Group();
406  if (!SaveCreateGroup(szFilename, *pLSaveGroup))
407  {
408  LogF(LoadResStr("IDS_ERR_SAVE_TARGETGRP"), szFilename ? szFilename : "nullptr!");
409  delete pLSaveGroup;
410  return false;
411  }
412  // save to it
413  return Save(*pLSaveGroup, true);
414 }
415 
416 bool C4GameSave::Save(C4Group &hToGroup, bool fKeepGroup)
417 {
418  // close any previous
419  Close();
420  // set group
421  pSaveGroup = &hToGroup; fOwnGroup = fKeepGroup;
422  // PreSave-actions (virtual call)
423  if (!OnSaving()) return false;
424  // always save core
425  if (!SaveCore()) { Log(LoadResStr("IDS_ERR_SAVE_CORE")); return false; }
426  // cleanup group
428  // remove: Title text, image and icon if specified
429  if (!GetKeepTitle())
430  {
436  }
437  // save additional runtime data
438  if (GetSaveRuntimeData()) if (!SaveRuntimeData()) return false;
439  // Desc
440  if (GetSaveDesc())
441  if (!SaveDesc(*pSaveGroup))
442  Log(LoadResStr("IDS_ERR_SAVE_DESC")); /* nofail */
443  // save specialized components (virtual call)
444  if (!SaveComponents()) return false;
445  // done, success
446  return true;
447 }
448 
450 {
451  bool fSuccess = true;
452  // any group open?
453  if (pSaveGroup)
454  {
455  // sort group
456  const char *szSortOrder = GetSortOrder();
457  if (szSortOrder) pSaveGroup->Sort(szSortOrder);
458  // close if owned group
459  if (fOwnGroup)
460  {
461  fSuccess = !!pSaveGroup->Close();
462  delete pSaveGroup;
463  fOwnGroup = false;
464  }
465  pSaveGroup = nullptr;
466  }
467  return fSuccess;
468 }
469 
470 
471 // *** C4GameSaveSavegame
472 
474 {
475  if (!Game.IsRunning) return true;
476  // synchronization to sync player files on all clients
477  // this resets playing times and stores them in the players?
478  // but doing so would be too late when the queue is executed!
479  // TODO: remove it? (-> PeterW ;))
480  if (::Network.isEnabled())
482  else
484  // OK; save now
485  return true;
486 }
487 
489 {
490  // Determine save game index from trailing number in group file name
491  int iSaveGameIndex = GetTrailingNumber(GetFilenameOnly(pSaveGroup->GetFullName().getData()));
492  // Looks like a decent index: set numbered icon
493  if (Inside(iSaveGameIndex, 1, 10))
494  rC4S.Head.Icon = 2 + (iSaveGameIndex - 1);
495  // Else: set normal script icon
496  else
497  rC4S.Head.Icon = 29;
498 }
499 
501 {
502  // special for savegames: save a screenshot
503  if (!Game.SaveGameTitle((*pSaveGroup)))
504  Log(LoadResStr("IDS_ERR_SAVE_GAMETITLE")); /* nofail */
505  // done, success
506  return true;
507 }
508 
510 {
511  // compose savegame desc
512  WriteDescDate(sBuf);
513  WriteDescGameTime(sBuf);
514  WriteDescDefinitions(sBuf);
516  WriteDescPlayers(sBuf);
517  // done, success
518  return true;
519 }
520 
521 
522 // *** C4GameSaveRecord
523 
525 {
526  // specific recording flags
527  rC4S.Head.Replay=true;
528  if (!rC4S.Head.Film) rC4S.Head.Film=C4SFilm_Normal; /* default to film */
529  rC4S.Head.Icon=29;
530  // default record title
531  char buf[1024 + 1];
532  sprintf(buf, "%03i %s [%d.%d]", iNum, Game.ScenarioTitle.getData(), (int)C4XVER1, (int)C4XVER2);
533  rC4S.Head.Title = buf;
534 }
535 
537 {
538  // special: records need player infos even if done initially
540  // for !fInitial, player infos will be saved as regular runtime data
541  // done, success
542  return true;
543 }
544 
546 {
547  // compose record desc
548  WriteDescDate(sBuf, true);
549  WriteDescGameTime(sBuf);
550  WriteDescEngine(sBuf);
551  WriteDescDefinitions(sBuf);
552  WriteDescLeague(sBuf, fLeague, Game.Parameters.League.getData());
554  WriteDescPlayers(sBuf);
555  // done, success
556  return true;
557 }
558 
559 
560 // *** C4GameSaveNetwork
561 
563 {
564  // specific dynamic flags
565  rC4S.Head.NetworkGame=true;
567 }
void Copy(C4MassMoverSet &rSet)
const char * getData() const
Definition: StdBuf.h:450
virtual bool SaveComponents()
Definition: C4GameSave.cpp:500
StdCopyStrBuf Origin
Definition: C4Scenario.h:80
bool IsRunning
Definition: C4Game.h:141
bool SGetModule(const char *szList, int iIndex, char *sTarget, int iSize)
Definition: Standard.cpp:510
int32_t Icon
Definition: C4Scenario.h:68
virtual bool GetCopyScenario()
Definition: C4GameSave.h:60
bool NetworkRuntimeJoin
Definition: C4Scenario.h:79
int32_t GetID() const
Definition: C4Teams.h:66
virtual void AdjustCore(C4Scenario &rC4S)
Definition: C4GameSave.h:72
char ScenarioFilename[_MAX_PATH+1]
Definition: C4Game.h:104
C4Config Config
Definition: C4Config.cpp:837
int32_t RandomSeed
Definition: C4Game.h:136
const char * GetName() const
Definition: C4PlayerInfo.h:160
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
C4SDefinitions Definitions
Definition: C4Scenario.h:231
bool SynchronizeLocalFiles()
C4Network2Client * GetNextClient(C4Network2Client *pClient)
bool Save(C4Group &hGroup, bool fSaveSection=false)
Definition: C4Scenario.cpp:114
int32_t GetPlayerCount() const
bool ItemIdentical(const char *szFilename1, const char *szFilename2)
Definition: StdFile.cpp:865
C4Game Game
Definition: C4Globals.cpp:52
bool fOwnGroup
Definition: C4GameSave.h:39
bool SetAsRestoreInfos(C4PlayerInfoList &rFromPlayers, bool fSaveUserPlrs, bool fSaveScriptPlrs, bool fSetUserPlrRefToLocalGroup, bool fSetScriptPlrRefToLocalGroup)
C4Scenario C4S
Definition: C4Game.h:76
std::string MissionAccess
Definition: C4Scenario.h:76
void Clear()
Definition: StdBuf.h:474
C4ConfigGeneral General
Definition: C4Config.h:252
#define sprintf
Definition: Standard.h:171
Definition: C4Teams.h:30
StdCopyStrBuf ScenarioTitle
Definition: C4Game.h:105
bool Replay
Definition: C4Scenario.h:72
C4Group * pSaveGroup
Definition: C4GameSave.h:38
bool IsAutoGenerateTeams() const
Definition: C4Teams.h:173
StdCopyStrBuf League
void Add(C4PacketType eType, C4ControlPacket *pCtrl)
Definition: C4Control.h:82
void WriteDescNetworkClients(StdStrBuf &sBuf)
Definition: C4GameSave.cpp:330
C4PlayerInfo * GetPlayerInfoByIndex(int32_t index) const
bool IsInvisible() const
Definition: C4PlayerInfo.h:178
void Clear()
Definition: C4Record.cpp:56
void WriteDescEngine(StdStrBuf &sBuf)
Definition: C4GameSave.cpp:290
std::string Title
Definition: C4Scenario.h:64
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:181
bool IsMultiTeams() const
Definition: C4Teams.h:163
bool IsExact()
Definition: C4GameSave.h:78
bool Delete(const char *szFiles, bool fRecursive=false)
Definition: C4Group.cpp:1334
C4Team * GetTeamByID(int32_t iID) const
Definition: C4Teams.cpp:384
#define C4CFN_Titles
Definition: C4Components.h:146
#define _MAX_PATH
const char * GetFilenameOnly(const char *strFilename)
Definition: StdFile.cpp:70
void WriteDescLineFeed(StdStrBuf &sBuf)
Definition: C4GameSave.cpp:258
bool SaveData(C4Group &hGroup, bool fSaveSection, bool fSaveExact, bool fSaveSync, C4ValueNumbers *)
Definition: C4Game.cpp:1779
#define C4CFN_Landscape
Definition: C4Components.h:60
C4GameParameters & Parameters
Definition: C4Game.h:69
virtual bool GetSaveOrigin()
Definition: C4GameSave.h:64
void WriteDescGameTime(StdStrBuf &sBuf)
Definition: C4GameSave.cpp:279
bool Save(C4Group &hGroup)
Definition: C4PXS.cpp:373
C4TeamList & Teams
Definition: C4Game.h:72
bool Save(C4Group &hGroup, const char *szToFile)
virtual const char * GetSortOrder()
Definition: C4GameSave.h:61
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool SaveTextures(C4Group &hGroup) const
void AppendFormat(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:197
int GetTrailingNumber(const char *strString)
Definition: StdFile.cpp:97
#define C4CFN_PlayerFiles
Definition: C4Components.h:167
bool SaveEnumeration(C4Group &hGroup)
Definition: C4Material.cpp:571
bool SaveDiff(C4Group &hGroup, bool fSyncSave) const
bool Save(C4Group &hGroup)
Definition: C4Teams.cpp:647
void WriteDescLeague(StdStrBuf &sBuf, bool fLeague, const char *strLeagueName)
Definition: C4GameSave.cpp:297
#define C4CFN_Info
Definition: C4Components.h:70
bool SaveGame
Definition: C4Scenario.h:71
bool SaveDesc(C4Group &hToGroup)
Definition: C4GameSave.cpp:237
bool Close()
Definition: C4GameSave.cpp:449
C4Network2 Network
Definition: C4Globals.cpp:53
bool Save(const char *szFilename)
Definition: C4GameSave.cpp:400
void WriteDescDate(StdStrBuf &sBuf, bool fRecord=false)
Definition: C4GameSave.cpp:264
char UserDataPath[CFG_MaxString+1]
Definition: C4Config.h:55
StdStrBuf GetFullName() const
Definition: C4Group.cpp:2078
#define C4CFN_SavePlayerInfos
Definition: C4Components.h:125
C4Landscape Landscape
bool Save(C4Group &hGroup)
void SInsert(char *szString, const char *szInsert, int iPosition, int iMaxLen)
Definition: Standard.cpp:480
virtual bool GetSaveDesc()
Definition: C4GameSave.h:59
bool SaveGameTitle(C4Group &hGroup)
Definition: C4Game.cpp:1833
#define C4CFN_ScenarioSections
Definition: C4Components.h:38
bool Open(const char *szGroupName, bool fCreate=false)
Definition: C4Group.cpp:514
virtual void AdjustCore(C4Scenario &rC4S)
Definition: C4GameSave.cpp:562
virtual bool GetKeepTitle()
Definition: C4GameSave.h:58
int32_t C4XVer[2]
Definition: C4Scenario.h:63
virtual bool GetSaveRuntimeData()
Definition: C4GameSave.h:57
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:527
C4Team * GetTeamByIndex(int32_t iIndex) const
Definition: C4Teams.cpp:405
C4PlayerList Players
bool C4Group_CopyItem(const char *szSource, const char *szTarget1, bool fNoSort, bool fResetAttributes)
Definition: C4Group.cpp:100
bool Save(C4Group &hGroup) const
int32_t Time
Definition: C4Game.h:133
int32_t GetTeam() const
Definition: C4PlayerInfo.h:198
bool NetworkGame
Definition: C4Scenario.h:78
bool IsRemoved() const
Definition: C4PlayerInfo.h:167
bool IsSynced()
Definition: C4GameSave.h:79
C4ScenarioSection * pScenarioSections
Definition: C4Game.h:93
char SystemDataPath[CFG_MaxString+1]
Definition: C4Config.h:56
const char * GetName() const
Definition: C4Teams.h:65
bool Close()
Definition: C4Group.cpp:755
C4PXSSystem PXS
Definition: C4PXS.cpp:526
void WriteDescDefinitions(StdStrBuf &sBuf)
Definition: C4GameSave.cpp:306
#define _MAX_FNAME
virtual bool GetCreateSmallFile()
Definition: C4GameSave.h:62
bool isEnabled() const
Definition: C4Network2.h:203
virtual bool WriteDesc(StdStrBuf &sBuf)
Definition: C4GameSave.cpp:509
C4RoundResults & RoundResults
Definition: C4Game.h:75
bool Save(C4Group &hGroup, C4Scenario *pDefault)
char Language[CFG_MaxString+1]
Definition: C4Config.h:37
LandscapeMode GetMode() const
C4Control & Input
Definition: C4Game.h:84
virtual bool SaveComponents()
Definition: C4GameSave.cpp:536
#define LineFeed
Definition: Standard.h:151
void SDelete(char *szString, int iLen, int iPosition)
Definition: Standard.cpp:492
#define C4CFN_PlayerInfos
Definition: C4Components.h:124
bool DeleteEntry(const char *szFilename, bool fRecycle=false)
Definition: C4Group.cpp:1384
C4MassMoverSet MassMover
C4Network2ClientList Clients
Definition: C4Network2.h:116
C4PlayerInfoList & PlayerInfos
Definition: C4Game.h:73
virtual bool GetSaveUserPlayers()
Definition: C4GameSave.h:66
bool Save(C4Group &hGroup, const char *szFilename=C4CFN_RoundResults)
virtual bool GetSaveScriptPlayers()
Definition: C4GameSave.h:67
virtual void AdjustCore(C4Scenario &rC4S)
Definition: C4GameSave.cpp:524
virtual bool SaveComponents()
Definition: C4GameSave.h:74
virtual bool GetSaveUserPlayerFiles()
Definition: C4GameSave.h:68
bool fInitial
Definition: C4GameSave.h:45
#define C4CFN_ScenarioDesc
Definition: C4Components.h:88
bool EraseItem(const char *szItemName)
Definition: StdFile.cpp:819
void SetModules(const char *szList, const char *szRelativeToPath=nullptr, const char *szRelativeToPath2=nullptr)
Definition: C4Scenario.cpp:462
virtual bool OnSaving()
Definition: C4GameSave.h:75
void ForceRelativePath(StdStrBuf *sFilename)
Definition: C4Config.cpp:668
void WriteDescPlayers(StdStrBuf &sBuf, bool fByTeam, int32_t idTeam)
Definition: C4GameSave.cpp:341
C4MaterialMap MaterialMap
Definition: C4Material.cpp:970
bool Log(const char *szMessage)
Definition: C4Log.cpp:195
bool Add(const char *szFile, const char *szAddAs)
Definition: C4Group.cpp:1316
char DefinitionFilenames[20 *_MAX_PATH+1]
Definition: C4Game.h:107
size_t getLength() const
Definition: StdBuf.h:453
bool Sort(const char *szSortList)
Definition: C4Group.cpp:1963
int SCharPos(char cTarget, const char *szInStr, int iIndex)
Definition: Standard.cpp:210
virtual bool WriteDesc(StdStrBuf &sBuf)
Definition: C4GameSave.cpp:545
C4SHead Head
Definition: C4Scenario.h:230
const char * AtRelativePath(const char *szFilename)
Definition: C4Config.cpp:660
virtual bool OnSaving()
Definition: C4GameSave.cpp:473
bool SaveMap(C4Group &hGroup) const
virtual bool GetSaveScriptPlayerFiles()
Definition: C4GameSave.h:69
C4ScenarioSection * pNext
Definition: C4Scenario.h:264
virtual void AdjustCore(C4Scenario &rC4S)
Definition: C4GameSave.cpp:488
bool LogF(const char *strMessage,...)
Definition: C4Log.cpp:253
#define C4CFN_ScenarioIcon
Definition: C4Components.h:85
bool HasJoined() const
Definition: C4PlayerInfo.h:168
bool NoInitialize
Definition: C4Scenario.h:69
virtual bool GetClearOrigin()
Definition: C4GameSave.h:65
virtual bool WriteDesc(StdStrBuf &sBuf)
Definition: C4GameSave.h:73
void Copy()
Definition: StdBuf.h:475
bool Inside(T ival, U lbound, V rbound)
Definition: Standard.h:45
#define C4CFN_ScenarioTitle
Definition: C4Components.h:84
bool Save(bool fSaveLocalOnly)
void SCopyUntil(const char *szSource, char *sTarget, char cUntil, int iMaxL, int iIndex)
Definition: Standard.cpp:145
C4ScenarioSection * pCurrentScenarioSection
Definition: C4Game.h:93
int32_t RandomSeed
Definition: C4Scenario.h:74
int32_t Film
Definition: C4Scenario.h:73
virtual bool GetForceExactLandscape()
Definition: C4GameSave.h:63
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:277