ScummVM API documentation
saveconverter.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  * This file is dual-licensed.
22  * In addition to the GPLv3 license mentioned above, this code is also
23  * licensed under LGPL 2.1. See LICENSES/COPYING.LGPL file for the
24  * full text of the license.
25  *
26  */
27 
28 #ifndef GOB_SAVE_SAVECONVERTER_H
29 #define GOB_SAVE_SAVECONVERTER_H
30 
31 #include "common/stream.h"
32 
33 namespace Gob {
34 
35 class GobEngine;
36 class SavePartInfo;
37 class SavePartVars;
38 class SavePartMem;
39 class SavePartSprite;
40 class SaveWriter;
41 
44 public:
45  SaveConverter(GobEngine *vm, const Common::String &fileName);
46  ~SaveConverter() override;
47 
49  virtual void clear();
51  virtual void setFileName(const Common::String &fileName);
52 
54  virtual int isOldSave(Common::InSaveFile **save = 0) const = 0;
56  virtual char *getDescription(Common::SeekableReadStream &save) const = 0;
58  virtual bool load() = 0;
59 
61  char *getDescription(const Common::String &fileName);
63  char *getDescription() const;
64 
65  // Stream
66  bool err() const override;
67  void clearErr() override;
68  // ReadStream
69  bool eos() const override;
70  uint32 read(void *dataPtr, uint32 dataSize) override;
71  // SeekableReadStream
72  int64 pos() const override;
73  int64 size() const override;
74  bool seek(int64 offset, int whence = SEEK_SET) override;
75 
76 protected:
77  GobEngine *_vm;
78 
79  Common::String _fileName;
80 
81  byte *_data;
83 
84  Common::InSaveFile *openSave() const;
85 
87  virtual void displayWarning() const;
88 
89  virtual uint32 getActualSize(Common::InSaveFile **save = 0) const;
90 
91  SavePartInfo *readInfo(Common::SeekableReadStream &stream,
92  uint32 descLength, bool hasSizes = true) const;
93  SavePartVars *readVars(Common::SeekableReadStream &stream,
94  uint32 count, bool endian) const;
95  SavePartMem *readMem(Common::SeekableReadStream &stream,
96  uint32 count, bool endian) const;
97  SavePartSprite *readSprite(Common::SeekableReadStream &stream,
98  uint32 width, uint32 height, bool palette) const;
99 
100  bool createStream(SaveWriter &writer);
101 
103  static bool swapDataEndian(byte *data, const byte *sizes, uint32 count);
104 
105 private:
106  byte *readData(Common::SeekableReadStream &stream,
107  uint32 count, bool endian) const;
108 };
109 
112 public:
113  SaveConverter_Notes(GobEngine *vm, uint32 notesSize, const Common::String &fileName = "");
114  ~SaveConverter_Notes() override;
115 
116  int isOldSave(Common::InSaveFile **save = 0) const override;
117  char *getDescription(Common::SeekableReadStream &save) const override;
118 
119  bool load() override;
120 
121 private:
122  uint32 _size;
123 
124  bool loadFail(SavePartVars *vars, Common::InSaveFile *save);
125 };
126 
129 public:
130  SaveConverter_v2(GobEngine *vm, const Common::String &fileName = "");
131  ~SaveConverter_v2() override;
132 
133  int isOldSave(Common::InSaveFile **save = 0) const override;
134  char *getDescription(Common::SeekableReadStream &save) const override;
135 
136  bool load() override;
137 
138 private:
139  static const uint32 kSlotCount = 15;
140  static const uint32 kSlotNameLength = 40;
141 
142  bool loadFail(SavePartInfo *info, SavePartVars *vars,
143  Common::InSaveFile *save);
144 };
145 
148 public:
149  SaveConverter_v3(GobEngine *vm, const Common::String &fileName = "");
150  ~SaveConverter_v3() override;
151 
152  int isOldSave(Common::InSaveFile **save = 0) const override;
153  char *getDescription(Common::SeekableReadStream &save) const override;
154 
155  bool load() override;
156 
157 private:
158  static const uint32 kSlotCount = 30;
159  static const uint32 kSlotNameLength = 40;
160 
161  bool loadFail(SavePartInfo *info, SavePartVars *vars,
162  SavePartSprite *sprite, Common::InSaveFile *save);
163 
164  void getScreenShotProps(int type,
165  bool &used, uint32 &width, uint32 &height);
166 };
167 
170 public:
171  SaveConverter_v4(GobEngine *vm, const Common::String &fileName = "");
172  ~SaveConverter_v4() override;
173 
174  int isOldSave(Common::InSaveFile **save = 0) const override;
175  char *getDescription(Common::SeekableReadStream &save) const override;
176 
177  bool load() override;
178 
179 private:
180  static const uint32 kSlotCount = 60;
181  static const uint32 kSlotNameLength = 40;
182 
183  bool loadFail(SavePartInfo *info, SavePartVars *vars,
184  SavePartMem *props, Common::InSaveFile *save);
185 };
186 
187 } // End of namespace Gob
188 
189 #endif // GOB_SAVE_SAVECONVERTER_H
Definition: saveconverter.h:169
static bool swapDataEndian(byte *data, const byte *sizes, uint32 count)
uint32 read(void *dataPtr, uint32 dataSize) override
Definition: gob.h:163
int64 size() const override
Definition: str.h:59
virtual void clear()
Definition: savefile.h:340
Definition: savefile.h:108
virtual void displayWarning() const
void clearErr() override
bool err() const override
Definition: saveconverter.h:147
bool seek(int64 offset, int whence=SEEK_SET) override
Definition: savefile.h:130
virtual int isOldSave(Common::InSaveFile **save=0) const =0
Definition: saveconverter.h:128
Definition: stream.h:745
Definition: savefile.h:200
int64 pos() const override
Definition: anifile.h:40
bool eos() const override
virtual bool load()=0
Definition: saveconverter.h:111
char * getDescription() const
virtual void setFileName(const Common::String &fileName)
Definition: savefile.h:162
Definition: saveconverter.h:43