ScummVM API documentation
database.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 MADE_DATABASE_H
23#define MADE_DATABASE_H
24
25#include "common/hashmap.h"
26
27namespace Common {
28class SeekableReadStream;
29class WriteStream;
30class String;
31}
32
33namespace Made {
34
35class MadeEngine;
36
37
38/* Object */
39
40class Object {
41public:
42 Object();
43 virtual ~Object();
44
45 virtual int load(Common::SeekableReadStream &source) = 0;
46 virtual int save(Common::WriteStream &dest) const;
47
48 virtual uint16 getFlags() const;
49 virtual uint16 getClass() const = 0;
50 virtual uint16 getCount() const = 0;
51 virtual byte getKeyCount() const = 0;
52 virtual byte getValueCount() const = 0;
53 virtual const byte *getData() const = 0;
54
55 bool isByteArray() const;
56 bool isWordArray() const;
57 bool isObject() const;
58
59 bool isWritable() const;
60
61 const char *getString() const;
62 void setString(const char *str);
63
64 int16 getVectorItem(int16 index) const;
65 void setVectorItem(int16 index, int16 value);
66
67 void dump(const Common::String &filename) const;
68
69protected:
70 bool _freeData;
71 uint16 _objSize;
72 byte *_objData;
73};
74
75class ObjectV1 : public Object {
76public:
77 int load(Common::SeekableReadStream &source) override;
78 int save(Common::WriteStream &dest) const override;
79
80 uint16 getClass() const override;
81 uint16 getCount() const override;
82 byte getKeyCount() const override;
83 byte getValueCount() const override;
84 const byte *getData() const override;
85
86protected:
87 static uint16 calcSize(const byte *source);
88};
89
90class ObjectV2 : public ObjectV1 {
91public:
92 byte getValueCount() const override;
93 byte getKeyCount() const override;
94};
95
96class ObjectV3 : public Object {
97public:
98 int load(Common::SeekableReadStream &source) override;
99 int load(byte *source);
100
101 uint16 getFlags() const override;
102 uint16 getClass() const override;
103 uint16 getCount() const override;
104 byte getKeyCount() const override;
105 byte getValueCount() const override;
106 const byte *getData() const override;
107
108protected:
109 virtual uint16 calcSize(const byte *source);
110};
111
112class ObjectV3_1 : public ObjectV3 {
113protected:
114 uint16 calcSize(const byte *source) override;
115};
116
117
118/* GameDatabase */
119
121public:
122
123 GameDatabase();
124 virtual ~GameDatabase();
125
126 void open(const char *filename);
127 void openFromRed(const char *redFilename, const char *filename);
128
129 void reload();
130
131 int16 getVar(int16 index) const;
132 void setVar(int16 index, int16 value);
133
134 Object *getObject(int16 index) const;
135 uint getObjectCount() const { return _objects.size(); }
136
137 int16 getMainCodeObjectIndex() const { return _mainCodeObjectIndex; }
138
139 const char *getObjectString(int16 index) const;
140 void setObjectString(int16 index, const char *str);
141
142 virtual int16 *findObjectProperty(int16 objectIndex, int16 propertyId, int16 &propertyFlag) = 0;
143 int16 *findObjectPropertyCached(int16 objectIndex, int16 propertyId, int16 &writableFlag);
144 virtual const char *getString(uint16 offset) = 0;
145 virtual bool getSavegameDescription(const char *filename, Common::String &description, int16 version) = 0;
146 virtual int16 savegame(const char *filename, const char *description, int16 version) = 0;
147 virtual int16 loadgame(const char *filename, int16 version) = 0;
148
149 int16 getObjectProperty(int16 objectIndex, int16 propertyId);
150 int16 setObjectProperty(int16 objectIndex, int16 propertyId, int16 value);
151
152 void dumpObject(int16 index) const;
153
154protected:
155 virtual void load(Common::SeekableReadStream &sourceS) = 0;
156 virtual void reloadFromStream(Common::SeekableReadStream &sourceS) = 0;
157
158 Common::String _filename, _redFilename;
159
162 ObjectPropertyCacheMap _objectPropertyCache;
163
164 Common::Array<byte> _gameState;
165 int16 _mainCodeObjectIndex;
166};
167
169public:
170 int16 *findObjectProperty(int16 objectIndex, int16 propertyId, int16 &propertyFlag) override;
171 const char *getString(uint16 offset) override;
172 bool getSavegameDescription(const char *filename, Common::String &description, int16 version) override;
173 int16 savegame(const char *filename, const char *description, int16 version) override;
174 int16 loadgame(const char *filename, int16 version) override;
175
176protected:
177 void load(Common::SeekableReadStream &sourceS) override;
178 void reloadFromStream(Common::SeekableReadStream &sourceS) override;
179
180 Common::Array<char> _gameText;
181};
182
184protected:
185 void load(Common::SeekableReadStream &sourceS) override;
186};
187
189public:
191 virtual int16 *findObjectProperty(int16 objectIndex, int16 propertyId, int16 &propertyFlag) override;
192 const char *getString(uint16 offset) override;
193 bool getSavegameDescription(const char *filename, Common::String &description, int16 version) override;
194 int16 savegame(const char *filename, const char *description, int16 version) override;
195 int16 loadgame(const char *filename, int16 version) override;
196protected:
197 uint32 _gameStateOffs;
198 void load(Common::SeekableReadStream &sourceS) override;
199 void reloadFromStream(Common::SeekableReadStream &sourceS) override;
200};
201
203public:
204 int16 *findObjectProperty(int16 objectIndex, int16 propertyId, int16 &propertyFlag) override;
205};
206
207} // End of namespace Made
208
209#endif /* MADE_DATABASE_H */
size_type size() const
Definition: array.h:316
Definition: stream.h:745
Definition: str.h:59
Definition: stream.h:77
Definition: database.h:120
Definition: database.h:168
Definition: database.h:183
Definition: database.h:202
Definition: database.h:188
Definition: database.h:40
Definition: database.h:75
Definition: database.h:90
Definition: database.h:112
Definition: database.h:96
Definition: algorithm.h:29
Definition: console.h:27