ScummVM API documentation
save_game_file.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef BAGEL_BAGLIB_SAVE_GAME_FILE_H
23 #define BAGEL_BAGLIB_SAVE_GAME_FILE_H
24 
25 #include "common/serializer.h"
26 #include "bagel/boflib/dat_file.h"
27 
28 namespace Bagel {
29 
30 #define MAX_SAVED_GAMES 40
31 #define MAX_SAVE_TITLE 128
32 #define MAX_USER_NAME 64
33 
35  char _szTitle[MAX_SAVE_TITLE] = { '\0' };
36  char _szUserName[MAX_USER_NAME] = { '\0' };
37  uint32 _bUsed = 0;
38 
39  void synchronize(Common::Serializer &s);
40  static int size() {
41  return MAX_SAVE_TITLE + MAX_USER_NAME + 4;
42  }
43 };
44 
45 #define MAX_SDEV_NAME 40
46 #define MAX_CLOSEUP_DEPTH 4
47 
48 #define MAX_VARS 1000
49 #define MAX_VAR_NAME 40
50 #define MAX_VAR_VALUE 60
51 
52 struct StVar {
53  char _szName[MAX_VAR_NAME];
54  char _szValue[MAX_VAR_VALUE];
55  uint16 _nType;
56 
57  byte _bGlobal;
58  byte _bConstant;
59  byte _bReference;
60  byte _bTimer;
61 
62  byte _bRandom;
63  byte _bNumeric;
64  byte _bAttached;
65 
66  byte _bUsed; // If this entry is used or not
67 
68  void synchronize(Common::Serializer &s);
69  void clear();
70 };
71 
72 #define MAX_OBJ_NAME 40
73 #define MAX_SDEV_NAME 40
74 #define MAX_OBJS 1000
75 
76 struct StObj {
77  char _szName[MAX_OBJ_NAME];
78  char _szSDev[MAX_SDEV_NAME];
79  uint32 _lState;
80 
81  uint32 _lProperties;
82  uint32 _lType;
83 
84  uint32 _lLoop;
85  uint32 _lSpeed;
86 
87  byte _bAttached;
88  byte _bUsed;
89 
90  uint16 _nFlags; // Flags for kicks...
91 
92  void synchronize(Common::Serializer &s);
93  void clear();
94 };
95 
96 // Flags for the st_obj structure
97 
98 #define mIsMsgWaiting 0x0001
99 
103 struct StBagelSave {
104  StVar _stVarList[MAX_VARS];
105  StObj _stObjList[MAX_OBJS];
106  StObj _stObjListEx[MAX_OBJS];
107  char _szScript[MAX_FNAME]; // Name of current world file (no path)
108  uint32 _nLocType; // TYPE_PAN, TYPE_CLOSEUP, etc...
109  char _szLocStack[MAX_CLOSEUP_DEPTH][MAX_SDEV_NAME]; // Your storage device stack
110  uint16 _nLocX; // X Location in PAN
111  uint16 _nLocY; // Y Location in PAN
112  uint16 _bUseEx;
113  uint16 _nFiller; // Make structs align
114 
115  void synchronize(Common::Serializer &s);
116  void clear();
117 
118  static int size() {
119  return 318432;
120  }
121 };
122 
128 public:
129  CBagSaveGameFile(bool isSaving);
130 
131  int32 getNumSavedGames() const {
132  return getNumberOfRecs();
133  }
134  int32 getActualNumSaves();
135  bool anySavedGames();
136 
140  ErrorCode writeSavedGame();
141 
145  ErrorCode readSavedGame(int32 slotNum);
146 
150  ErrorCode readTitle(int32 lSlot, StSavegameHeader *pSavedGame);
151 
152  ErrorCode readTitleOnly(int32 lSlot, char *pGameTitle);
153 };
154 
155 } // namespace Bagel
156 
157 #endif
Definition: dat_file.h:69
Definition: serializer.h:79
Definition: save_game_file.h:52
Definition: save_game_file.h:127
Definition: bagel.h:31
Definition: save_game_file.h:103
Definition: save_game_file.h:76
Definition: save_game_file.h:34