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 ULTIMA1_DATA_SAVEGAME_H
23#define ULTIMA1_DATA_SAVEGAME_H
24
25#include "common/rect.h"
26#include "common/serializer.h"
27#include "ultima/ultima1/data/data.h"
28#include "ultima/ultima1/data/entity.h"
29#include "ultima/ultima1/data/space_map.h"
30
31namespace Ultima {
32namespace Ultima1 {
33namespace Data {
34
40 int16 _type;
41 Common::Point _position;
42 int16 _hitPoints;
43
44 void synchronize(Common::Serializer &s);
45};
46
50struct Savegame {
51private:
55 void synchronizeBasic(Common::Serializer &s);
56
60 void synchronizeExtra(Common::Serializer &s);
61
62public:
63 // Identity
64 char _name[MAX_NAME_LENGTH + 2] = {};
65 byte _race = RACE_HUMAN;
66 byte _class = CLASS_FIGHTER;
67 byte _sex = SEX_MALE;
68
69 // Attributes
70 int16 _hits = 0;
71 int16 _strength = 0;
72 int16 _agility = 0;
73 int16 _stamina = 0;
74 int16 _charisma = 0;
75 int16 _wisdom = 0;
76 int16 _intelligence = 0;
77
78 // Resources
79 int16 _coins = 0;
80 int16 _experience = 0;
81 int16 _food = 0;
82
83 // Currently equipped/readied items
84 int16 _equippedWeapon = WEAPON_NONE;
85 int16 _equippedSpell = SPELL_PRAYER;
86 int16 _equippedArmor = ARMOR_NONE;
87 int16 _transportType = TRANSPORT_FOOT;
88
89 int16 _randomSeed = 0;
90 Common::Point _overworldPos;
91 bool _soundOn = true;
92
93 // Quest completion flags, one per town/dungeon
94 int16 _questStatus[QUEST_COUNT] = {};
95
96 // Gems
97 int16 _redGems = 0;
98 int16 _greenGems = 0;
99 int16 _blueGem = 0;
100 int16 _whiteGem = 0;
101
102 // Inventory quantities owned, indexed by the enums above. Index 0 of
103 // each isn't a real item quantity
104 int16 _armor[ARMOR_COUNT] = {};
105 int16 _weapons[WEAPON_COUNT] = {};
106 int16 _spells[SPELL_COUNT] = {};
107 int16 _transports[TRANSPORT_COUNT] = {};
108
109 int16 _enemyVessels = 0;
110 int16 _signMarker = -1;
111 int16 _overworldEntityCount = 0;
112 uint32 _moveCount = 0;
113 uint16 _shipFuel = 0;
114 uint16 _shipShield = 0;
115
116 OverworldEntity _overworldEntities[OVERWORLD_ENTITY_COUNT] = {};
117
118 // Extra fields
119 int16 _mapNum = 0;
120 Common::Point _locationPosition;
121 LocationEntity _locationEntities[LOCATION_ENTITY_COUNT] = {};
122 int16 _guardsHostile = 0;
123 int16 _hasCastleKey = 0;
124 int16 _freeingPrincess = 0;
125 int16 _castleItemAllowance = 0;
126 int16 _castleKeyVal = 0;
127 uint8 _dungeonLevel = 1;
128 uint8 _dungeonDirection = 4;
129 uint16 _dungeonExitHitPoints = 0;
130
131 // Outer space state - synchronized only while _mapNum == MAP_SPACE
132 int16 _sectorX = SPACE_STATION_X;
133 int16 _sectorY = SPACE_STATION_Y;
134 int16 _shipIndex = 2;
135 SpaceMap _starmap;
136
137 bool _gemDestroyedFlag = false;
138 Common::Point _mondainPos;
139 // Set to 1 when the player first steps next to Mondain, then counts up
140 // frame by frame to drive his hit-reaction animation
141 int16 _mondainHitAnimFrame = 0;
142 // +1/-1 step direction _mondainHitAnimFrame currently bounces by,
143 // between 1 and 4
144 int16 _mondainHitAnimDir = 0;
145 // Set once combat with Mondain has been triggered (the player got
146 // adjacent to him for the first time)
147 int16 _mondainCombatFlag = 0;
148 // Which of Mondain's story-driven forms/poses is currently shown - a
149 // tile Id offset added to _mondainPhaseAnimOffset
150 int16 _mondainPhase = 2;
151 // Small cycling offset added to _mondainPhase to animate his current
152 // pose - what it cycles through depends on the current phase
153 int16 _mondainPhaseAnimOffset = 0;
154 // Drives Mondain's story-driven phase transitions (not yet ported) -
155 // destroying the gem while it happens to read 30 defeats him outright
156 int16 _mondainPhaseTimer = 20;
157 // Set once Mondain has been finally defeated
158 int16 _mondainDefeatedFlag = 0;
159 // Mondain's own hit points
160 int16 _mondainHits = 1000;
161 // Mondain's conjured-hazard flash: -1 when idle, otherwise its current
162 // animation frame (0..6). _mondainHazardPos is the cell it occupies
163 int16 _mondainHazardAnim = -1;
164 Common::Point _mondainHazardPos;
165
170
178 bool isDead() const {
179 return _hits <= 0;
180 }
181
185 int getCurrentLevel() const {
186 return _experience / 1000 + 1;
187 }
188
196 int getOverworldEntityAt(int x, int y, int startingIndex = 1) const;
197
201 void removeOverworldCreatureAt(int x, int y);
202
206 int getLocationEntityAt(int x, int y) const;
207};
208
209} // namespace Data
210} // namespace Ultima1
211} // namespace Ultima
212
213#endif
Definition: serializer.h:80
Definition: rect.h:144
Definition: savegame.h:39
Definition: savegame.h:50
void synchronize(Common::Serializer &s)
void synchronizeOriginal(Common::Serializer &s)
int getLocationEntityAt(int x, int y) const
int getCurrentLevel() const
Definition: savegame.h:185
bool isDead() const
Definition: savegame.h:178
int getOverworldEntityAt(int x, int y, int startingIndex=1) const
void removeOverworldCreatureAt(int x, int y)
Definition: space_map.h:180