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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  * Copyright 2020 Google
22  *
23  */
24 
25 #include "common/serializer.h"
26 
27 #include "hadesch/enums.h"
28 
29 #ifndef HADESCH_PERSISTENT_H
30 #define HADESCH_PERSISTENT_H
31 
32 namespace Hadesch {
33 
34 struct HadeschSaveDescriptor {
35 	HadeschSaveDescriptor(Common::Serializer &s, int slot);
36 
37 	int _slot;
38 	Common::U32String _heroName;
39 	Common::U32String _slotName;
40 	RoomId _room;
41 };
42 
43 struct HadeschSaveDescriptorSlotComparator {
operatorHadeschSaveDescriptorSlotComparator44 	bool operator()(const HadeschSaveDescriptor &x, const HadeschSaveDescriptor &y) const {
45 		return x._slot < y._slot;
46 	}
47 };
48 
49 static const int inventorySize = 6;
50 
51 struct Persistent {
52 	// Generic
53 	Gender _gender;
54 	Common::U32String _heroName;
55 	Common::U32String _slotDescription; // valid only in saves
56 	Quest _quest;
57 	int _powerLevel[3];
58 	RoomId _currentRoomId;
59 	RoomId _previousRoomId;
60 	bool _roomVisited[kNumRooms];
61 	bool _statuesTouched[kNumStatues];
62 	int _statuePhase[kNumStatues];
63 	bool _doQuestIntro;
64 	InventoryItem _inventory[inventorySize];
65 	bool _hintsAreEnabled;
66 
67 	// Argo
68 	bool _argoSailedInQuest[kNumRooms][kNumQuests];
69 	bool _argoSaidTroyFinally;
70 	bool _argoSaidCretePort;
71 
72 	// Crete and Minos
73 	bool _creteShowMerchant;
74 	bool _creteShowAtlantisBoat;
75 	bool _creteShowHorned;
76 	bool _creteShowHornless1;
77 	bool _creteShowHornless2;
78 	bool _creteShowHornless3;
79 	bool _creteShowHornless4;
80 	bool _creteDaedalusRoomAvailable;
81 	bool _creteMinosInstructed;
82 	bool _creteIntroMerchant;
83 	bool _cretePlayedEyeGhostTown;
84 	bool _creteTriedHornless[4];
85 	bool _creteIntroAtlantisBoat;
86 	bool _creteIntroAtlantisWood;
87 	bool _creteAlchemistExploded;
88 	enum CreteSandalsState {
89 		SANDALS_NOT_SOLVED,
90 		SANDALS_SOLVED,
91 		SANDALS_TAKEN
92 	} _creteSandalsState;
93 	enum CreteStrongBoxState {
94 	    BOX_CLOSED, BOX_OPEN,
95 	    BOX_OPEN_POTION, BOX_OPEN_NO_POTION } _creteStrongBoxState;
96 	bool _cretePlayedPhilAlchemist;
97 	bool _cretePlayedZeusCheckOutThatBox;
98 	bool _creteHadesPusnishesPainAndPanic;
99 	bool _creteVisitedAfterAlchemistIntro;
100 	bool _creteSaidHelenPermanentResident;
101 
102 	// Daedalus
103 	bool _daedalusShowedNote;
104 	bool _daedalusLabItem[4];
105 
106 	// Seriphos
107 	bool _seriphosStrawCartTaken;
108 	bool _seriphosPlayedMedusa;
109 	bool _seriphosPhilWarnedAthena;
110 	bool _seriphosPhilCurtainsItems;
111 
112 	// Athena
113 	bool _athenaPuzzleSolved;
114 	bool _athenaSwordTaken;
115 	bool _athenaShieldTaken;
116 	bool _athenaPlayedPainAndPanic;
117 	bool _athenaIntroPlayed;
118 
119 	// Medusa Island
120 	bool _medisleStoneTaken;
121 	bool _medislePlacedItems[5];
122 	bool _medislePlayedPerseusIntro;
123 	bool _medisleShowFates;
124 	bool _medisleShowFatesIntro;
125 	bool _medisleEyeballIsActive;
126 	FateId _medisleEyePosition;
127 	enum MedisleBagPuzzleState {
128 		BAG_NOT_STARTED,
129 		BAG_STARTED,
130 		BAG_SOLVED,
131 		BAG_TAKEN
132 	} _medisleBagPuzzleState;
133 	bool _medislePlayedPhilFatesDesc;
134 
135 	// Troy
136 	bool _troyPlayAttack;
137 	bool _troyWallDamaged;
138 	bool _troyShowBricks;
139 	bool _troyIsDefeated;
140 	bool _troyPlayedOdysseus;
141 	bool _troyMessageIsDelivered;
142 	enum TroyKeyAndDecreeState {
143 		KEY_AND_DECREE_NOT_GIVEN,
144 		KEY_AND_DECREE_THROWN,
145 		KEY_AND_DECREE_TAKEN
146 	} _troyKeyAndDecreeState;
147 	int _troyCatacombCounter;
148 	bool _troyCatacombsUnlocked;
149 	bool _troyPlayedOdysseusCongrats;
150 	bool _troyPlayFinish;
151 
152 	// Catacombs
153 	int _catacombVariants[3][3];
154 	CatacombsPath _catacombPaths[3][3];
155 	CatacombsLevel _catacombLevel;
156 	CatacombsPosition _catacombDecoderSkullPosition;
157 	CatacombsLevel _catacombLastLevel;
158 	bool _catacombPainAndPanic;
159 
160 	// Volcano
161 	bool _volcanoPainAndPanicIntroDone;
162 	bool _volcanoHeyKid;
163 	enum VolcanoPuzzleState {
164 		VOLCANO_NO_BOULDERS_THROWN,
165 		VOLCANO_SQUASHED_PANIC,
166 		VOLCANO_BOULDER_ON_VOLCANO,
167 		VOLCANO_HELMET_SHOWN
168 	} _volcanoPuzzleState;
169 	int _volcanoToStyxCounter;
170 
171 	// River Styx
172 	bool _styxCharonUsedPotion;
173 	bool _styxCharonUsedCoin;
174 	bool _styxAlchemistSaidIntro;
175 
176 	Persistent();
177 
178 	bool isInInventory(InventoryItem item);
179 
isRoomVisitedPersistent180 	bool isRoomVisited(RoomId id) const {
181 		return _roomVisited[id];
182 	}
183 
184 	void clearInventory();
185 
186 	bool syncGameStream(Common::Serializer &s);
187 };
188 }
189 #endif
190