ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
savegame_internal.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 AGS_ENGINE_GAME_SAVEGAME_INTERNAL_H
23 #define AGS_ENGINE_GAME_SAVEGAME_INTERNAL_H
24 
25 #include "common/std/memory.h"
26 #include "common/std/vector.h"
27 #include "common/std/map.h"
28 #include "ags/shared/ac/common_defines.h"
29 #include "ags/shared/game/room_struct.h"
30 #include "ags/shared/gfx/bitmap.h"
31 #include "ags/engine/media/audio/audio_defines.h"
32 
33 namespace AGS3 {
34 namespace AGS {
35 namespace Engine {
36 
37 using AGS::Shared::Bitmap;
38 using AGS::Shared::Stream;
39 
40 typedef std::shared_ptr<Bitmap> PBitmap;
41 
42 // PreservedParams keeps old values of particular gameplay
43 // parameters that are saved before the save restoration
44 // and either applied or compared to new values after
45 // loading save data
47  // Whether speech and audio packages available
48  bool SpeechVOX = false;
49  bool MusicVOX = false;
50  // Game options, to preserve ones that must not change at runtime
51  int GameOptions[GameSetupStructBase::MAX_OPTIONS]{};
52  // Script global data sizes
53  size_t GlScDataSize = 0u;
54  std::vector<size_t> ScMdDataSize;
55 
57 };
58 
59 // Audio playback state flags, used only in serialization
60 enum AudioSvgPlaybackFlags {
61  kSvgAudioPaused = 0x01
62 };
63 
64 enum GameViewCamFlags {
65  kSvgGameAutoRoomView = 0x01
66 };
67 
68 enum CameraSaveFlags {
69  kSvgCamPosLocked = 0x01
70 };
71 
72 enum ViewportSaveFlags {
73  kSvgViewportVisible = 0x01
74 };
75 
76 // RestoredData keeps certain temporary data to help with
77 // the restoration process
78 struct RestoredData {
79  int FPS;
80  // Unserialized bitmaps for dynamic surfaces
81  std::vector<std::unique_ptr<Bitmap>> DynamicSurfaces;
82  // Unserialized bitmaps for overlays (old-style saves)
84  // Scripts global data
85  struct ScriptData {
86  std::vector<char> Data;
87  size_t Len;
88 
89  ScriptData();
90  };
91  ScriptData GlobalScript;
92  std::vector<ScriptData> ScriptModules;
93  // Game state data (loaded ahead)
94  uint32_t DoOnceCount;
95  // Room data (has to be be preserved until room is loaded)
96  PBitmap RoomBkgScene[MAX_ROOM_BGFRAMES];
97  int16_t RoomLightLevels[MAX_ROOM_REGIONS];
98  int32_t RoomTintLevels[MAX_ROOM_REGIONS];
99  int16_t RoomZoomLevels1[MAX_WALK_AREAS];
100  int16_t RoomZoomLevels2[MAX_WALK_AREAS];
101  RoomVolumeMod RoomVolume;
102  // Mouse cursor parameters
103  int CursorID;
104  int CursorMode;
105  // General audio
106  struct ChannelInfo {
107  int ClipID = -1;
108  int Flags = 0;
109  int Pos = 0;
110  int Priority = 0;
111  int Repeat = 0;
112  int Vol = 0;
113  int VolAsPercent = 0;
114  int Pan = 0;
115  int Speed = 0;
116  // since version 1
117  int XSource = -1;
118  int YSource = -1;
119  int MaxDist = 0;
120  };
121  ChannelInfo AudioChans[TOTAL_AUDIO_CHANNELS];
122  // Ambient sounds
123  int DoAmbient[MAX_GAME_CHANNELS];
124  // Viewport and camera data, has to be preserved and applied only after
125  // room gets loaded, because we must clamp these to room parameters.
126  struct ViewportData {
127  int ID = -1;
128  int Flags = 0;
129  int Left = 0;
130  int Top = 0;
131  int Width = 0;
132  int Height = 0;
133  int ZOrder = 0;
134  int CamID = -1;
135  };
136  struct CameraData {
137  int ID = -1;
138  int Flags = 0;
139  int Left = 0;
140  int Top = 0;
141  int Width = 0;
142  int Height = 0;
143  };
144  std::vector<ViewportData> Viewports;
145  std::vector<CameraData> Cameras;
146  bool LegacyViewCamera = false;
147  int32_t Camera0_Flags = 0; // flags for primary camera, when data is read in legacy order
148 
149  RestoredData();
150 };
151 
152 enum PluginSvgVersion {
153  kPluginSvgVersion_Initial = 0,
154  kPluginSvgVersion_36115 = 1,
155 };
156 
157 // Runs plugin events, requesting to read save data from the given stream.
158 // NOTE: there's no error check in this function, because plugin API currently
159 // does not let plugins report any errors when restoring their saved data.
160 void ReadPluginSaveData(Stream *in, PluginSvgVersion svg_ver, soff_t max_size);
161 // Runs plugin events, requesting to write save data into the given stream.
162 void WritePluginSaveData(Stream *out);
163 
164 } // namespace Engine
165 } // namespace AGS
166 } // namespace AGS3
167 
168 #endif
Definition: achievements_tables.h:27
Definition: savegame_internal.h:136
Definition: map.h:204
Definition: savegame_internal.h:78
Definition: audio.h:36
Definition: ptr.h:159
Definition: stream.h:52
Definition: savegame_internal.h:126
Definition: engine.h:144
Definition: ags.h:40
Definition: savegame_internal.h:106
Definition: savegame_internal.h:46
Definition: savegame_internal.h:85