ScummVM API documentation
savefile.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 BLADERUNNER_SAVEFILE_H
23 #define BLADERUNNER_SAVEFILE_H
24 
25 #include "common/array.h"
26 #include "common/memstream.h"
27 #include "common/savefile.h"
28 #include "common/types.h"
29 
30 #include "graphics/surface.h"
31 
32 #include "engines/savestate.h"
33 
34 namespace Common {
35 class OutSaveFile;
36 class String;
37 struct Rect;
38 }
39 
40 namespace BladeRunner {
41 
42 class Vector2;
43 class Vector3;
44 class BoundingBox;
45 
46 
48  uint8 _version;
49  Common::String _name;
50  int _year;
51  int _month;
52  int _day;
53  int _hour;
54  int _minute;
55  uint32 _playTime;
56  Graphics::Surface *_thumbnail;
57 };
58 
60 private:
61  static const uint32 kTag = MKTAG('B', 'R', 'S', 'V');
62  // kVersion: 3 as of Feb 5th 2020 (UTC) - ScummVM development version 2.2.0git
63  // kVersion: 4 as of Apr 17th 2021 - Added full-size thumbnails
64  static const uint32 kVersion = 4;
65 
66 public:
67  // kVersion
68  // ----------
69  // 2:: max of 32 characters for the saved game name
70  // 3:: max of 41 characters for the saved game name (this matches the original game's setting)
71  static const uint32 kNameLengthV2 = 32;
72  static const uint32 kNameLength = 41;
73  static const uint32 kThumbnailSize = 9600; // 80x60x16bpp
74 
75  static SaveStateList list(const MetaEngine *metaEngine, const Common::String &target);
76  static SaveStateDescriptor queryMetaInfos(const MetaEngine *metaEngine, const Common::String &target, int slot);
77 
78  static Common::InSaveFile *openForLoading(const Common::String &target, int slot);
79  static Common::OutSaveFile *openForSaving(const Common::String &target, int slot);
80 
81  static void remove(const Common::String &target, int slot);
82 
83  static bool readHeader(Common::SeekableReadStream &in, SaveFileHeader &header, bool skipThumbnail = true);
84  static bool writeHeader(Common::WriteStream &out, SaveFileHeader &header);
85 
86 };
87 
89 private:
91 
92 public:
94 
95  uint32 write(const void *dataPtr, uint32 dataSize) override { return _s.write(dataPtr, dataSize); }
96  bool flush() override { return _s.flush(); }
97  int64 pos() const override { return _s.pos(); }
98 
99  void debug(char *p);
100 
101  void padBytes(int count);
102 
103  void writeInt(int32 v); // this writes a 4 byte int (uses writeUint32LE)
104  void writeFloat(float v);
105  void writeBool(bool v);
106  void writeStringSz(const Common::String &s, uint sz);
107  void writeVector2(const Vector2 &v);
108  void writeVector3(const Vector3 &v);
109  void writeRect(const Common::Rect &v);
110  void writeBoundingBox(const BoundingBox &v, bool serialized);
111 };
112 
114 private:
116 
117 public:
119 
120  bool eos() const override { return _s.eos(); }
121  uint32 read(void *dataPtr, uint32 dataSize) override { return _s.read(dataPtr, dataSize); }
122  int64 pos() const override { return _s.pos(); }
123  int64 size() const override { return _s.size(); }
124  bool seek(int64 offset, int whence = SEEK_SET) override { return _s.seek(offset, whence); }
125 
126  int32 readInt();
127  float readFloat();
128  bool readBool();
129  Common::String readStringSz(uint sz);
130  Vector2 readVector2();
131  Vector3 readVector3();
132  Common::Rect readRect();
133  BoundingBox readBoundingBox(bool serialized);
134 };
135 
136 } // End of namespace BladeRunner
137 
138 #endif
Definition: savefile.h:88
int64 pos() const override
Definition: savefile.h:97
Definition: metaengine.h:200
virtual int64 size() const =0
uint32 write(const void *dataPtr, uint32 dataSize) override
Definition: savefile.h:95
Definition: str.h:59
virtual int64 pos() const =0
Definition: surface.h:66
Definition: stream.h:77
Definition: savefile.h:54
virtual bool seek(int64 offset, int whence=SEEK_SET)=0
virtual bool eos() const =0
Definition: actor.h:31
Definition: savefile.h:113
bool seek(int64 offset, int whence=SEEK_SET) override
Definition: savefile.h:124
Definition: rect.h:144
bool eos() const override
Definition: savefile.h:120
Definition: stream.h:745
virtual bool flush()
Definition: stream.h:103
Definition: savestate.h:56
Definition: boundingbox.h:31
Definition: savefile.h:47
virtual int64 pos() const =0
int64 pos() const override
Definition: savefile.h:122
void debug(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
bool flush() override
Definition: savefile.h:96
Definition: vector.h:29
uint32 read(void *dataPtr, uint32 dataSize) override
Definition: savefile.h:121
Definition: algorithm.h:29
bool skipThumbnail(Common::SeekableReadStream &in)
int64 size() const override
Definition: savefile.h:123
#define MKTAG(a0, a1, a2, a3)
Definition: endian.h:188
Definition: vector.h:47
Definition: savefile.h:59
virtual uint32 write(const void *dataPtr, uint32 dataSize)=0
virtual uint32 read(void *dataPtr, uint32 dataSize)=0