ScummVM API documentation
puzzledata.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 #include "common/serializer.h"
23 #include "common/array.h"
24 #include "common/hashmap.h"
25 
26 #include "engines/nancy/commontypes.h"
27 
28 #ifndef NANCY_PUZZLEDATA_H
29 #define NANCY_PUZZLEDATA_H
30 
31 namespace Nancy {
32 
33 // The following structs contain persistent data for specific
34 // puzzle types, which is to be stored in savefiles
35 
36 struct PuzzleData {
37  PuzzleData() {}
38  virtual ~PuzzleData() {}
39 
40  virtual void synchronize(Common::Serializer &ser) = 0;
41 };
42 
43 struct SliderPuzzleData : public PuzzleData {
45  virtual ~SliderPuzzleData() {}
46 
47  static constexpr uint32 getTag() { return MKTAG('S', 'L', 'I', 'D'); }
48  virtual void synchronize(Common::Serializer &ser);
49 
50  Common::Array<Common::Array<int16>> playerTileOrder;
51  bool playerHasTriedPuzzle;
52 };
53 
56  virtual ~RippedLetterPuzzleData() {}
57 
58  static constexpr uint32 getTag() { return MKTAG('R', 'I', 'P', 'L'); }
59  virtual void synchronize(Common::Serializer &ser);
60 
61  Common::Array<int8> order;
62  Common::Array<byte> rotations;
63  bool playerHasTriedPuzzle;
64 
65  // Temporary values, do not save to file
66  int8 _pickedUpPieceID = -1;
67  byte _pickedUpPieceRot = 0;
68  int _pickedUpPieceLastPos = -1;
69 };
70 
71 struct TowerPuzzleData : public PuzzleData {
73  virtual ~TowerPuzzleData() {}
74 
75  static constexpr uint32 getTag() { return MKTAG('T', 'O', 'W', 'R'); }
76  virtual void synchronize(Common::Serializer &ser);
77 
79  bool playerHasTriedPuzzle;
80 };
81 
82 struct RiddlePuzzleData : public PuzzleData {
84  virtual ~RiddlePuzzleData() {}
85 
86  static constexpr uint32 getTag() { return MKTAG('R', 'I', 'D', 'L'); }
87  virtual void synchronize(Common::Serializer &ser);
88 
89  Common::Array<byte> solvedRiddleIDs;
90  int8 incorrectRiddleID;
91 };
92 
95  virtual ~SoundEqualizerPuzzleData() {}
96 
97  static constexpr uint32 getTag() { return MKTAG('S', 'E', 'Q', 'L'); }
98  virtual void synchronize(Common::Serializer &ser);
99 
100  Common::Array<byte> sliderValues;
101 };
102 
103 // Contains a single bool indicating whether the puzzle was solved
104 struct SimplePuzzleData : public PuzzleData {
106  virtual ~SimplePuzzleData() {}
107 
108  virtual void synchronize(Common::Serializer &ser);
109 
110  bool solvedPuzzle;
111 };
112 
114  static constexpr uint32 getTag() { return MKTAG('A', 'S', 'M', 'B'); }
115 };
116 
117 struct JournalData : public PuzzleData {
118  JournalData() {}
119  virtual ~JournalData() {}
120 
121  struct Entry {
122  Entry(const Common::String &s = Common::String(), uint16 m = 0, uint16 sc = kNoScene) : stringID(s), mark(m), sceneID(sc) {}
123 
124  Common::String stringID;
125  uint16 mark = 0;
126  uint16 sceneID = kNoScene;
127  };
128 
129  static constexpr uint32 getTag() { return MKTAG('J', 'O', 'U', 'R'); }
130  virtual void synchronize(Common::Serializer &ser);
131 
133 };
134 
135 // Contains variables that can be read and modified through action records.
136 // Mixes two separate things:
137 // - the exhibit data table in nancy6
138 // - the general variable storage in nancy8 and up
139 // The exhibit data was only ever used in nancy6, so mixing these should be ok.
140 struct TableData : public PuzzleData {
141  TableData();
142  virtual ~TableData() {}
143 
144  static constexpr uint32 getTag() { return MKTAG('T', 'A', 'B', 'L'); }
145  virtual void synchronize(Common::Serializer &ser);
146 
147  void setSingleValue(uint16 index, int16 value);
148  int16 getSingleValue(uint16 index) const;
149 
150  void setComboValue(uint16 index, float value);
151  float getComboValue(uint16 index) const;
152 
153  Common::Array<int16> singleValues;
154  Common::Array<float> comboValues;
155 };
156 
157 PuzzleData *makePuzzleData(const uint32 tag);
158 
159 } // End of namespace Nancy
160 
161 #endif // NANCY_PUZZLEDATA_H
Definition: puzzledata.h:113
Definition: str.h:59
Definition: puzzledata.h:54
Definition: array.h:52
Definition: puzzledata.h:36
Definition: puzzledata.h:104
Definition: serializer.h:79
Definition: puzzledata.h:43
Definition: puzzledata.h:140
Definition: hashmap.h:85
Definition: puzzledata.h:93
Definition: puzzledata.h:82
#define MKTAG(a0, a1, a2, a3)
Definition: endian.h:188
Definition: puzzledata.h:121
Definition: puzzledata.h:71
Definition: puzzledata.h:117
Definition: actionmanager.h:32