ScummVM API documentation
savegame.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 ULTIMA4_FILESYS_SAVEGAME_H
23#define ULTIMA4_FILESYS_SAVEGAME_H
24
25#include "common/array.h"
26#include "common/rect.h"
27#include "common/stream.h"
28#include "common/serializer.h"
29#include "ultima/ultima4/core/coords.h"
30#include "ultima/ultima4/core/types.h"
31
32namespace Ultima {
33namespace Ultima4 {
34
35#define PARTY_SAV_BASE_FILENAME "party.sav"
36#define MONSTERS_SAV_BASE_FILENAME "monsters.sav"
37#define OUTMONST_SAV_BASE_FILENAME "outmonst.sav"
38
39#define MONSTERTABLE_SIZE 32
40#define MONSTERTABLE_CREATURES_SIZE 8
41#define MONSTERTABLE_OBJECTS_SIZE (MONSTERTABLE_SIZE - MONSTERTABLE_CREATURES_SIZE)
42
43class Object;
44
49enum WeaponType {
50 WEAP_HANDS,
51 WEAP_STAFF,
52 WEAP_DAGGER,
53 WEAP_SLING,
54 WEAP_MACE,
55 WEAP_AXE,
56 WEAP_SWORD,
57 WEAP_BOW,
58 WEAP_CROSSBOW,
59 WEAP_OIL,
60 WEAP_HALBERD,
61 WEAP_MAGICAXE,
62 WEAP_MAGICSWORD,
63 WEAP_MAGICBOW,
64 WEAP_MAGICWAND,
65 WEAP_MYSTICSWORD,
66 WEAP_MAX
67};
68
73enum ArmorType {
74 ARMR_NONE,
75 ARMR_CLOTH,
76 ARMR_LEATHER,
77 ARMR_CHAIN,
78 ARMR_PLATE,
79 ARMR_MAGICCHAIN,
80 ARMR_MAGICPLATE,
81 ARMR_MYSTICROBES,
82 ARMR_MAX
83};
84
89enum SexType {
90 SEX_MALE = 0xb,
91 SEX_FEMALE = 0xc
92};
93
97enum ClassType {
98 CLASS_MAGE,
99 CLASS_BARD,
100 CLASS_FIGHTER,
101 CLASS_DRUID,
102 CLASS_TINKER,
103 CLASS_PALADIN,
104 CLASS_RANGER,
105 CLASS_SHEPHERD
106};
107
112enum StatusType {
113 STAT_GOOD = 'G',
114 STAT_POISONED = 'P',
115 STAT_SLEEPING = 'S',
116 STAT_DEAD = 'D'
117};
118
119enum Virtue {
120 VIRT_HONESTY,
121 VIRT_COMPASSION,
122 VIRT_VALOR,
123 VIRT_JUSTICE,
124 VIRT_SACRIFICE,
125 VIRT_HONOR,
126 VIRT_SPIRITUALITY,
127 VIRT_HUMILITY,
128 VIRT_MAX
129};
130
131enum BaseVirtue {
132 VIRT_NONE = 0x00,
133 VIRT_TRUTH = 0x01,
134 VIRT_LOVE = 0x02,
135 VIRT_COURAGE = 0x04
136};
137
138enum Reagent {
139 REAG_ASH,
140 REAG_GINSENG,
141 REAG_GARLIC,
142 REAG_SILK,
143 REAG_MOSS,
144 REAG_PEARL,
145 REAG_NIGHTSHADE,
146 REAG_MANDRAKE,
147 REAG_MAX
148};
149
150#define SPELL_MAX 26
151
152enum Item {
153 ITEM_SKULL = 0x01,
154 ITEM_SKULL_DESTROYED = 0x02,
155 ITEM_CANDLE = 0x04,
156 ITEM_BOOK = 0x08,
157 ITEM_BELL = 0x10,
158 ITEM_KEY_C = 0x20,
159 ITEM_KEY_L = 0x40,
160 ITEM_KEY_T = 0x80,
161 ITEM_HORN = 0x100,
162 ITEM_WHEEL = 0x200,
163 ITEM_CANDLE_USED = 0x400,
164 ITEM_BOOK_USED = 0x800,
165 ITEM_BELL_USED = 0x1000
166};
167
168enum Stone {
169 STONE_BLUE = 0x01,
170 STONE_YELLOW = 0x02,
171 STONE_RED = 0x04,
172 STONE_GREEN = 0x08,
173 STONE_ORANGE = 0x10,
174 STONE_PURPLE = 0x20,
175 STONE_WHITE = 0x40,
176 STONE_BLACK = 0x80
177};
178
179enum Rune {
180 RUNE_HONESTY = 0x01,
181 RUNE_COMPASSION = 0x02,
182 RUNE_VALOR = 0x04,
183 RUNE_JUSTICE = 0x08,
184 RUNE_SACRIFICE = 0x10,
185 RUNE_HONOR = 0x20,
186 RUNE_SPIRITUALITY = 0x40,
187 RUNE_HUMILITY = 0x80
188};
189
194 void synchronize(Common::Serializer &s);
195 void init();
196
197 unsigned short _hp;
198 unsigned short _hpMax;
199 unsigned short _xp;
200 unsigned short _str, _dex, _intel;
201 unsigned short _mp;
202 unsigned short _unknown;
203 WeaponType _weapon;
204 ArmorType _armor;
205 char _name[16];
206 SexType _sex;
207 ClassType _class;
208 StatusType _status;
209};
210
215 byte _tile;
216 byte _x;
217 byte _y;
218 byte _prevTile;
219 byte _prevX;
220 byte _prevY;
221 byte _unused1;
222 byte _unused2;
223
225 clear();
226 }
227
228 void clear() {
229 _tile = _x = _y = 0;
230 _prevTile = _prevX = _prevY = 0;
231 _unused1 = _unused2 = 0;
232 }
233
234 static void synchronize(SaveGameMonsterRecord *monsterTable, Common::Serializer &s);
235};
236
237class LocationCoords : public Coords {
238public:
239 MapId _map;
240
241 LocationCoords() : Coords(), _map(0xff) {}
242 LocationCoords(MapId map, int x_, int y_, int z_) :
243 Coords(x_, y_, z_), _map(map) {}
244 LocationCoords(MapId map, const Coords &pos) :
245 Coords(pos), _map(map) {}
246
251};
252
253class LocationCoordsArray : public Common::Array<LocationCoords> {
254public:
255
259 void load();
260
265};
266
270struct SaveGame {
274 void init(const SaveGamePlayerRecord *avatarInfo);
275
280
285
290 void newGame();
291
296
297 uint _unknown1;
298 uint _moves;
299 SaveGamePlayerRecord _players[8];
300 int _food;
301 short _gold;
302 short _karma[VIRT_MAX];
303 short _torches;
304 short _gems;
305 short _keys;
306 short _sextants;
307 short _armor[ARMR_MAX];
308 short _weapons[WEAP_MAX];
309 short _reagents[REAG_MAX];
310 short _mixtures[SPELL_MAX];
311 unsigned short _items;
312 LocationCoordsArray _positions;
313 unsigned short _orientation;
314
315 byte _stones;
316 byte _runes;
317 unsigned short _members;
318 unsigned short _transport;
319 union {
320 unsigned short _balloonState;
321 unsigned short _torchDuration;
322 };
323 unsigned short _trammelPhase;
324 unsigned short _feluccaPhase;
325 unsigned short _shipHull;
326 unsigned short _lbIntro;
327 unsigned short _lastCamp;
328 unsigned short _lastReagent;
329 unsigned short _lastMeditation;
330 unsigned short _lastVirtue;
331};
332
333} // End of namespace Ultima4
334} // End of namespace Ultima
335
336#endif
Definition: array.h:52
Definition: stream.h:745
Definition: serializer.h:80
Definition: stream.h:77
Definition: coords.h:31
Definition: savegame.h:253
void synchronize(Common::Serializer &s)
Definition: savegame.h:237
void synchronize(Common::Serializer &s)
Definition: savegame.h:270
void save(Common::WriteStream *stream)
void synchronize(Common::Serializer &s)
void load(Common::SeekableReadStream *stream)
void init(const SaveGamePlayerRecord *avatarInfo)
Definition: savegame.h:214
Definition: savegame.h:193