ScummVM API documentation
room_status.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_AC_ROOM_STATUS_H
23#define AGS_ENGINE_AC_ROOM_STATUS_H
24
25#include "ags/engine/ac/room_object.h"
26#include "ags/engine/game/savegame.h"
27#include "ags/shared/game/room_struct.h"
28#include "ags/shared/game/interactions.h"
29#include "ags/shared/util/string_types.h"
30
31namespace AGS3 {
32
33// Forward declaration
34namespace AGS {
35namespace Shared {
36class Stream;
37} // namespace Shared
38} // namespace AGS
39
40using AGS::Shared::Stream;
41using AGS::Shared::Interaction;
42
44 bool Enabled = false;
45 Shared::String Name;
46
47 void ReadFromSavegame(Shared::Stream *in, int save_ver);
48 void WriteToSavegame(Shared::Stream *out) const;
49};
50
51// Savegame data format for RoomStatus
52enum RoomStatSvgVersion {
53 kRoomStatSvgVersion_Initial = 0, // [UNSUPPORTED] from 3.5.0 pre-alpha
54 // NOTE: in 3.5.0 "Room States" had lower index than "Loaded Room State" by mistake
55 kRoomStatSvgVersion_350_Mismatch = 0, // an incorrect "Room States" version from 3.5.0
56 kRoomStatSvgVersion_350 = 1, // new movelist format (along with pathfinder)
57 kRoomStatSvgVersion_36016 = 2, // hotspot and object names
58 kRoomStatSvgVersion_36025 = 3, // object animation volume
59 kRoomStatSvgVersion_36041 = 4, // room state's contentFormat
60 kRoomStatSvgVersion_36109 = 5, // removed movelists, save externally
61 kRoomStatSvgVersion_Current = kRoomStatSvgVersion_36109
62};
63
64// RoomStatus contains everything about a room that could change at runtime.
65struct RoomStatus {
66 int beenhere = 0;
67 uint32_t numobj = 0;
69 uint32_t tsdatasize = 0;
70 std::vector<char> tsdata;
71 Interaction intrHotspot[MAX_ROOM_HOTSPOTS];
72 std::vector<Interaction> intrObject;
73 Interaction intrRegion[MAX_ROOM_REGIONS];
74 Interaction intrRoom;
75
76 Shared::StringIMap roomProps;
77 Shared::StringIMap hsProps[MAX_ROOM_HOTSPOTS];
79 HotspotState hotspot[MAX_ROOM_HOTSPOTS];
80 int8 region_enabled[MAX_ROOM_REGIONS];
81 short walkbehind_base[MAX_WALK_BEHINDS];
82 int32_t interactionVariableValues[MAX_GLOBAL_VARIABLES];
83
84 // Likely pre-2.5 data
85#if defined (OBSOLETE)
86 short flagstates[MAX_LEGACY_ROOM_FLAGS]{};
87 EventBlock hscond[MAX_ROOM_HOTSPOTS];
88 EventBlock objcond[MAX_ROOM_OBJECTS];
89 EventBlock misccond;
90#endif
91
92 // A version of a save this RoomStatus was restored from.
93 // This is used as a hint when merging RoomStatus with the loaded room file (upon room enter).
94 // We need this for cases when an old format save is restored within an upgraded game
95 // (for example, game was upgraded from 3.4.0 to 3.6.0, but player tries loading 3.4.0 save),
96 // because room files are only loaded once entered, so we cannot fixup all RoomStatuses at once.
97 RoomStatSvgVersion contentFormat;
98
99 RoomStatus();
100 ~RoomStatus();
101
102 void FreeScriptData();
103 void FreeProperties();
104
105 void ReadFromSavegame_v321(Shared::Stream *in, GameDataVersion data_ver);
106 void ReadFromSavegame(Shared::Stream *in, GameDataVersion data_ver, RoomStatSvgVersion save_ver);
107 void WriteToSavegame(Shared::Stream *out, GameDataVersion data_ver) const;
108};
109
110// Replaces all accesses to the roomstats array
111RoomStatus *getRoomStatus(int room);
112// Used in places where it is only important to know whether the player
113// had previously entered the room. In this case it is not necessary
114// to initialise the status because a player can only have been in
115// a room if the status is already initialised.
116bool isRoomStatusValid(int room);
117void resetRoomStatuses();
118
119} // namespace AGS3
120
121#endif
Definition: stream.h:52
Definition: string.h:60
Definition: vector.h:39
Definition: interactions.h:154
Definition: room_status.h:43
Definition: room_status.h:65