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#include "common/str-array.h"
26
27#include "engines/nancy/commontypes.h"
28#include "engines/nancy/enginedata.h"
29
30#ifndef NANCY_PUZZLEDATA_H
31#define NANCY_PUZZLEDATA_H
32
33namespace Nancy {
34
35// The following structs contain persistent data for specific
36// puzzle types, which is to be stored in savefiles
37
38struct PuzzleData {
39 PuzzleData() {}
40 virtual ~PuzzleData() {}
41
42 virtual void synchronize(Common::Serializer &ser) = 0;
43};
44
47 virtual ~SliderPuzzleData() {}
48
49 static constexpr uint32 getTag() { return MKTAG('S', 'L', 'I', 'D'); }
50 virtual void synchronize(Common::Serializer &ser);
51
53 bool playerHasTriedPuzzle;
54};
55
58 virtual ~RippedLetterPuzzleData() {}
59
60 static constexpr uint32 getTag() { return MKTAG('R', 'I', 'P', 'L'); }
61 virtual void synchronize(Common::Serializer &ser);
62
64 Common::Array<byte> rotations;
65 bool playerHasTriedPuzzle;
66 // Some games (e.g. Nancy7) have multiple instances of the same puzzle in
67 // different scenes, so we need to key the puzzle data by scene ID.
68 uint16 sceneId;
69
70 // Temporary values, do not save to file
71 int8 pickedUpPieceID = -1;
72 byte pickedUpPieceRot = 0;
73 int pickedUpPieceLastPos = -1;
74};
75
76struct TowerPuzzleData : public PuzzleData {
78 virtual ~TowerPuzzleData() {}
79
80 static constexpr uint32 getTag() { return MKTAG('T', 'O', 'W', 'R'); }
81 virtual void synchronize(Common::Serializer &ser);
82
84 bool playerHasTriedPuzzle;
85};
86
89 virtual ~RiddlePuzzleData() {}
90
91 static constexpr uint32 getTag() { return MKTAG('R', 'I', 'D', 'L'); }
92 virtual void synchronize(Common::Serializer &ser);
93
94 Common::Array<byte> solvedRiddleIDs;
95 int8 incorrectRiddleID;
96};
97
100 virtual ~SoundEqualizerPuzzleData() {}
101
102 static constexpr uint32 getTag() { return MKTAG('S', 'E', 'Q', 'L'); }
103 virtual void synchronize(Common::Serializer &ser);
104
105 Common::Array<byte> sliderValues;
106};
107
108// Contains a single bool indicating whether the puzzle was solved
111 virtual ~SimplePuzzleData() {}
112
113 virtual void synchronize(Common::Serializer &ser);
114
115 bool solvedPuzzle;
116};
117
119 static constexpr uint32 getTag() { return MKTAG('A', 'S', 'M', 'B'); }
120};
121
122// Placed bead-type ids on the thread.
123struct BeadPuzzleData : public PuzzleData {
124 BeadPuzzleData() {}
125 virtual ~BeadPuzzleData() {}
126
127 static constexpr uint32 getTag() { return MKTAG('B', 'E', 'A', 'D'); }
128 virtual void synchronize(Common::Serializer &ser);
129
130 Common::Array<int16> placedBeads;
131};
132
133// Cached current/solved tile layouts for a SortPuzzle. Each cell is encoded as
134// 4 consecutive int16s: srcRow, srcCol, value, isEmpty. The first two int16s
135// of each array are the grid rows and cols.
136struct SortPuzzleData : public PuzzleData {
137 SortPuzzleData() {}
138 virtual ~SortPuzzleData() {}
139
140 static constexpr uint32 getTag() { return MKTAG('S', 'O', 'R', 'T'); }
141 virtual void synchronize(Common::Serializer &ser);
142
143 Common::Array<int16> currentState;
144 Common::Array<int16> solvedState;
145};
146
147// Per-magnet (left, top, right, bottom, locked) packed as 5 int16s. The
148// puzzle's two scenes (3280, 3281) are the same puzzle with the same data,
149// so a single flat array suffices.
152 virtual ~MagnetMazePuzzleData() {}
153
154 static constexpr uint32 getTag() { return MKTAG('M', 'M', 'A', 'Z'); }
155 virtual void synchronize(Common::Serializer &ser);
156
157 Common::Array<int16> magnetState;
158};
159
160// Nancy10 GridMapPuzzle: per-item (inMap, inItems, mapRow, mapCol, itemsRow,
161// itemsCol) packed as 6 int16s.
162// Nancy14 LetterGridPuzzle: the marked column of each row, -1 = unmarked.
165 virtual ~GridMapPuzzleData() {}
166
167 static constexpr uint32 getTag() { return MKTAG('G', 'M', 'A', 'P'); }
168 virtual void synchronize(Common::Serializer &ser);
169
170 Common::Array<int16> itemState;
171};
172
173struct QuizPuzzleData : public PuzzleData {
174 QuizPuzzleData() {}
175 virtual ~QuizPuzzleData() {}
176
177 static constexpr uint32 getTag() { return MKTAG('Q', 'U', 'I', 'Z'); }
178 virtual void synchronize(Common::Serializer &ser);
179
180 // Keyed by solve-scene ID up to Nancy 14, so that multiple QuizPuzzle
181 // instances (e.g. a two-page Nancy 9 puzzle) each maintain their own state.
182 // Nancy 15 keys by (scene ID << 16 | record index), as the original does,
183 // since one scene can hold several quiz records sharing a solve scene.
186};
187
188struct JournalData : public PuzzleData {
189 JournalData() {}
190 virtual ~JournalData() {}
191
192 struct Entry {
193 Entry(const Common::String &s = Common::String(), uint16 m = 0, uint16 sc = kNoScene) : stringID(s), mark(m), sceneID(sc) {}
194
195 Common::String stringID;
196 uint16 mark = 0;
197 uint16 sceneID = kNoScene;
198 };
199
200 static constexpr uint32 getTag() { return MKTAG('J', 'O', 'U', 'R'); }
201 virtual void synchronize(Common::Serializer &ser);
202
203 // From Nancy15 every protagonist keeps their own journal, so entries are
204 // always reached through the active player character's slot. Earlier games
205 // have a single character and only ever touch slot 0.
206 Common::Array<Entry> &entries(uint16 surfaceID);
207 bool hasEntries(uint16 surfaceID) const;
208
209 // Hands the journal of one character to another. Nancy15 seeds a Hardy
210 // boy's journal from his brother's the first time he is played.
211 void inheritEntries(uint from, uint to);
212
213 Common::HashMap<uint16, Common::Array<Entry>> journalEntries[kMaxPlayerCharacters];
214
215private:
216 static void syncOneJournal(Common::Serializer &ser, Common::HashMap<uint16, Common::Array<Entry>> &journal);
217};
218
219// Nancy16: the entries of the task list the player has checked off
220struct TasklistData : public PuzzleData {
221 TasklistData() {}
222 virtual ~TasklistData() {}
223
224 static constexpr uint32 getTag() { return MKTAG('T', 'L', 'S', 'T'); }
225 virtual void synchronize(Common::Serializer &ser);
226
227 Common::Array<Common::String> checkedEntries;
228};
229
230// Nancy16: how the panels and controls of the UI differ from the state they start in,
231// as the actions that bring them there, e.g. a meter a scene has shown or disabled
232struct UIStateData : public PuzzleData {
233 UIStateData() {}
234 virtual ~UIStateData() {}
235
236 struct Change {
237 Common::String name;
238 int32 action = 0;
239 };
240
241 static constexpr uint32 getTag() { return MKTAG('U', 'I', 'S', 'T'); }
242 virtual void synchronize(Common::Serializer &ser);
243
244 Common::Array<Change> changes;
245};
246
247// Contains variables that can be read and modified through action records.
248// Mixes two separate things:
249// - the exhibit data table in nancy6
250// - the general variable storage in nancy8 and up
251// The exhibit data was only ever used in nancy6, so mixing these should be ok.
252struct TableData : public PuzzleData {
253 TableData();
254 virtual ~TableData() {}
255
256 static constexpr uint32 getTag() { return MKTAG('T', 'A', 'B', 'L'); }
257 virtual void synchronize(Common::Serializer &ser);
258
259 void setSingleValue(uint16 index, int16 value);
260 int16 getSingleValue(uint16 index) const;
261
262 void setComboValue(uint16 index, float value);
263 float getComboValue(uint16 index) const;
264
265 // The number of single (non-combo) values, i.e. the boundary between the
266 // single-value and combo-value index ranges.
267 uint getNumSingleValues() const;
268 uint getNumComboValues() const;
269
270 // Index markers used inside SetValueCombo and ValueTest records: an entry
271 // to skip, and an entry whose payload is used as a literal number.
272 byte getNoIndex() const;
273 byte getLiteralIndex() const;
274
275 // Reads a value by its combined index (single values come first, then combos).
276 // Combo (float) values are rounded to the nearest integer.
277 int16 getValue(uint16 index) const;
278 void setValue(uint16 index, int16 value);
279
280 // Nancy16 reads a value that was never set as 0
281 int16 getValueOrZero(uint16 index) const;
282
283 // How Nancy14+ value tests compare a value against another
284 enum Comparison {
285 kEqual = 0,
286 kGreater = 1,
287 kGreaterOrEqual = 2,
288 kLess = 3,
289 kLessOrEqual = 4,
290 kNotEqual = 5 // Nancy16+
291 };
292
293 static bool compare(int32 value, int32 other, uint16 comparison);
294
295 Common::Array<int16> singleValues;
296 Common::Array<float> comboValues;
297};
298
299// Nancy 10+ cellphone state mutated by the ChangeCellPhoneInfo,
300// SetCellPhoneBatteryAndSignal and AddSearchLink action records,
301// persisted between saves.
302struct CellPhoneData : public PuzzleData {
303 CellPhoneData() {}
304 virtual ~CellPhoneData() {}
305
306 static constexpr uint32 getTag() { return MKTAG('C', 'E', 'L', 'L'); }
307 virtual void synchronize(Common::Serializer &ser);
308
309 // Everything one handset holds. From Nancy15 each protagonist carries
310 // their own phone, with their own contacts, mail and reception, so the
311 // state is kept per player character. Earlier games have a single
312 // character and only ever touch slot 0.
313 struct Phone {
314 bool noSignal = false;
315 bool batteryLow = false;
316 // Set to true once the popup has seeded the contact list from the
317 // UICL chunk; we then own it as runtime data.
318 bool seeded = false;
320
321 // Populated by AR 131 (AddSearchLink). Mode 0 → emailMessages (each
322 // with a body-text CVTX key + read flag); any non-zero mode →
323 // searchLinks (web search topics).
324 Common::Array<SearchLink> emailMessages;
325 Common::Array<SearchLink> searchLinks;
326 };
327
328 // The phone belonging to the character currently being played.
329 Phone &active();
330 const Phone &active() const;
331
332 Phone phones[kMaxPlayerCharacters];
333
334private:
335 static void syncPhone(Common::Serializer &ser, Phone &phone);
336 static void syncLinkArray(Common::Serializer &ser, Common::Array<SearchLink> &arr);
337};
338
339// A cell-phone camera snapshot (Nancy 13). Stored as raw BGRA32 pixels so it
340// survives save/load independently of the scene it was taken from.
342 uint16 width = 0;
343 uint16 height = 0;
344 Common::Array<byte> pixels; // width * height * 4, BGRA32
345 bool sent = false; // true once the player has "sent" it
346
347 // Indices into UICL::cameraSubjects that were inside the viewfinder.
348 Common::Array<int16> subjects;
349};
350
351// Nancy 13 camera snapshots. Kept in its own lazily-created PuzzleData chunk so
352// existing saves and the CELL chunk are untouched (no save-version bump).
355 virtual ~CellPhonePictureData() {}
356
357 static constexpr uint32 getTag() { return MKTAG('C', 'P', 'I', 'C'); }
358 virtual void synchronize(Common::Serializer &ser);
359
361};
362
363// Nancy 11+ AR 69 (TimerControl). 10 software timers, each counting up from
364// zero. In Nancy 11 a "configured" timer (state 5/6) fires a set of event flags,
365// plays an optional sound and shows an optional caption once its target duration
366// elapses. From Nancy 12 a running timer instead carries up to kNumTriggers
367// independent triggers (see ResetAndStartTimer), each firing its own flags and
368// sound. Started/stopped via ResetAndStartTimer (104) and StopTimer (105), which
369// in Nancy 11 carry a timer-slot index.
370struct TimerData : public PuzzleData {
371 // Nancy 12+ per-timer trigger: fires its flags and sound once its target
372 // duration is reached. A one-shot trigger clears the whole timer when it
373 // fires; a repeating one leaves the timer counting.
374 struct Trigger {
375 enum Type { kOneShot = 1, kRepeating = 2 };
376
377 int32 type = kOneShot;
378 uint32 durationMs = 0;
379 bool hasFired = false;
380 SoundDescription sound;
381 FlagDescription flags[10];
382 };
383
384 struct Timer {
385 enum State { kIdle = 0, kRunning = 1, kPaused = 2, kOneShot = 5, kRepeating = 6 };
386
387 int32 state = kIdle;
388 uint32 currentTimeMs = 0;
389 uint32 durationMs = 0;
390 bool hasFired = false;
391 SoundDescription sound;
392 Common::String autotextKey;
393 Common::String caption;
394 FlagDescription flags[10];
395 Common::Array<Trigger> triggers; // Nancy 12+
396
397 void reset() { *this = Timer(); }
398 };
399
400 // Nancy11-13 have 10 timers, and Nancy14+ have 20. However, only Nancy15+
401 // save all 20: Nancy14 has 20 timers, but its scripts never use any past
402 // the first 10, so its saves keep storing 10 timers. Since the TimerData chunk isn't
403 // length-prefixed, storing more timers for Nancy14 would break existing
404 // saves unless the savegame version is bumped.
405 static const uint kNumTimers = 20;
406 static const uint kNumSavedTimers = 10; // Timers stored in saves before Nancy15
407 static const uint kNumTriggers = 20;
408
409 TimerData() {}
410 virtual ~TimerData() {}
411
412 static constexpr uint32 getTag() { return MKTAG('T', 'M', 'R', 'S'); }
413 virtual void synchronize(Common::Serializer &ser);
414
415 Timer timers[kNumTimers];
416};
417
418// Nancy 12+ UI resource values (from the UIRC boot chunk), e.g. resource 0 is
419// the coin purse amount in cents. Seeded from UIRC on first use, mutated by AR
420// 132 (ResourceUse), and persisted between saves.
421struct UIResourceData : public PuzzleData {
422 UIResourceData() {}
423 virtual ~UIResourceData() {}
424
425 static constexpr uint32 getTag() { return MKTAG('U', 'R', 'E', 'S'); }
426 virtual void synchronize(Common::Serializer &ser);
427
428 // Set true once seeded from UIRC, so a loaded save isn't re-seeded.
429 bool seeded = false;
431
432 // Nancy15+ gives every protagonist their own resources, seeded from their
433 // own UIRC. `values` holds the active character's; these are the others'.
434 // An empty entry means that character has never been played.
435 Common::Array<Common::Array<int32>> characterValues;
436
437 // Grows the array as needed
438 Common::Array<int32> &getCharacterValues(uint character);
439};
440
441// Nancy 10+ taskbar button-disable overrides, set by AR 29 (ControlUIItems).
442// A disable can span a range of scenes set from an earlier scene's AR, so the
443// override has to persist across saves for the button to stay disabled after a
444// load into a scene that doesn't itself re-run the AR.
445struct TaskbarData : public PuzzleData {
446 static const uint kNumButtons = 6;
447 static const uint kNumNotificationSubCategories = 3;
448
449 struct Override {
450 bool active = false;
451 int16 startScene = -1;
452 int16 endScene = -1;
453 uint16 clickSoundMode = 0;
454 };
455
456 TaskbarData() {}
457 virtual ~TaskbarData() {}
458
459 static constexpr uint32 getTag() { return MKTAG('T', 'S', 'K', 'B'); }
460 virtual void synchronize(Common::Serializer &ser);
461
462 Override overrides[kNumButtons];
463 // Notification badge flags, mirrored from the Taskbar so they survive a
464 // load. Set by AR triggers (inventory add, ModifyListEntryAdd, etc.) that
465 // won't re-run when loading into a later scene.
466 bool notifications[kNumButtons][kNumNotificationSubCategories] = {};
467};
468
469// Nancy15+ active player character (Nancy / Frank / Joe), selected by AR 134.
470// The whole popup UI is rebuilt from the character's own data files, so the
471// selection has to survive a save/load for the right UI to come back.
472// Every character also carries their own inventory: the active character's is
473// the live one inside Scene, while the other characters' are parked here.
475 struct Inventory {
476 bool isValid = false; // False until the character has been played
477 int16 heldItem = -1;
479 Common::Array<byte> disabledItems;
480 Common::Array<int16> order; // Display order of the inventory popup
481 };
482
484 virtual ~PlayerCharacterData() {}
485
486 static constexpr uint32 getTag() { return MKTAG('P', 'C', 'H', 'R'); }
487 virtual void synchronize(Common::Serializer &ser);
488
489 // Grows the array as needed, so a character that has never been played
490 // still gets an (empty) inventory
491 Inventory &getInventory(uint character);
492
493 uint16 characterIndex = 0;
494 Common::Array<Inventory> inventories;
495 // The look each character wears, chosen on the Design Select screen.
496 // Empty means their PCUI default.
497 Common::String designs[kMaxPlayerCharacters];
498};
499
500// Inventory "can't" sound overrides, installed by AR 123 (InventorySoundOverride).
501// An override stays in place until another record replaces or removes it, so it
502// has to survive both scene changes and a save/load. One set per player character;
503// everything before Nancy15 only ever touches the first.
505 struct Override {
506 bool isDefault = false; // When true, other fields are ignored
507 SoundDescription sound;
508 Common::String caption;
509 };
510
512 virtual ~InventorySoundOverrideData() {}
513
514 static constexpr uint32 getTag() { return MKTAG('I', 'S', 'N', 'D'); }
515 virtual void synchronize(Common::Serializer &ser);
516
517 Common::HashMap<uint16, Override> overrides[kMaxPlayerCharacters];
518
519private:
520 static void syncOverride(Common::Serializer &ser, Override &override);
521};
522
523// Nancy13+ WordFindPuzzle (AR 170). The puzzle is solved one word at a time across
524// several scene visits; this remembers which word is currently active so progress
525// survives leaving and re-entering the scene (and saving/loading).
528 virtual ~WordFindPuzzleData() {}
529
530 static constexpr uint32 getTag() { return MKTAG('W', 'F', 'N', 'D'); }
531 virtual void synchronize(Common::Serializer &ser);
532
533 int16 currentWord = 0;
534};
535
536// Nancy14+ HangmanPuzzle (AR 177). Remembers which words have already been used
537// so a fresh visit picks a new one; once every word has been used the set is
538// cleared and words become available again (matching the original's word-reuse
539// bitmap). Persisted so progress survives leaving the scene and saving.
540struct HangmanData : public PuzzleData {
541 HangmanData() {}
542 virtual ~HangmanData() {}
543
544 static constexpr uint32 getTag() { return MKTAG('H', 'A', 'N', 'G'); }
545 virtual void synchronize(Common::Serializer &ser);
546
548};
549
550// Nancy14+ DecoderPuzzle (AR 182). The decoded line typed so far, plus the scene
551// it belongs to. A scene's two records (with and without the substitution table)
552// hand the line to each other through here; other scenes start empty.
553struct DecoderData : public PuzzleData {
554 DecoderData() {}
555 virtual ~DecoderData() {}
556
557 static constexpr uint32 getTag() { return MKTAG('D', 'C', 'D', 'R'); }
558 virtual void synchronize(Common::Serializer &ser);
559
560 uint16 sceneID = kNoScene;
561 Common::String text;
562};
563
564// Nancy12 DrivingPuzzle (AR 160). The car's position, heading and tire state persist
565// across visits to the driving map (driving into a location, then coming back), matching
566// the original's retainState mechanism, which saves the car to globals every frame and
567// restores it on setup. `valid` is false until the car has been driven, so the first
568// visit starts from the header's start position.
569struct DrivingData : public PuzzleData {
570 DrivingData() {}
571 virtual ~DrivingData() {}
572
573 static constexpr uint32 getTag() { return MKTAG('D', 'R', 'V', 'G'); }
574 virtual void synchronize(Common::Serializer &ser);
575
576 bool valid = false;
577 int32 carX = 0;
578 int32 carY = 0;
579 double heading = 0.0;
580 int32 tireDamage = 0;
581 bool flatTire = false;
582 double fuelBurnAccum = 0.0; // fractional fuel drained but not yet a whole unit
583 bool infiniteFuel = false; // cheat toggle, kept across building visits
584};
585
586// Nancy12 MirrorLightPuzzle (AR 163). The angle of each mirror, so a mirror stays
587// where the player turned it when the puzzle scene is left and re-entered.
588// An angle of -1 marks a mirror that was never saved, which keeps its initial angle.
590 MirrorLightData() {}
591 virtual ~MirrorLightData() {}
592
593 static constexpr uint32 getTag() { return MKTAG('M', 'I', 'R', 'L'); }
594 virtual void synchronize(Common::Serializer &ser);
595
596 Common::Array<double> angles; // radians, indexed by mirror
597};
598
599// Nancy10 MultiBuildPuzzle (AR 235). How many times each ingredient went in when
600// the puzzle was last left. A record with its retain byte set picks the counts
601// back up when it runs in the same scene (cake mixing, after "add more
602// ingredients"); any other record starts over.
604 static constexpr uint32 getTag() { return MKTAG('M', 'B', 'L', 'D'); }
605 virtual void synchronize(Common::Serializer &ser);
606
607 uint16 sceneID = kNoScene;
608 Common::Array<int16> placeCounts;
609};
610
611// Nancy14 BuildPuzzle (AR 166). The board as it was after the last drop. A puzzle
612// scene that re-runs picks it back up, as long as it is still the last build
613// puzzle entered and its resume flag is set; otherwise the puzzle starts over.
615 BuildPuzzleData() {}
616 virtual ~BuildPuzzleData() {}
617
618 static constexpr uint32 getTag() { return MKTAG('B', 'L', 'D', 'P'); }
619 virtual void synchronize(Common::Serializer &ser);
620
621 uint16 sceneID = kNoScene;
622 int16 placedCount = 0;
623 bool solved = false;
624 bool wrongIngredient = false;
625 Common::Array<int16> pieces; // 6 per piece: sourceID, assignedZone, left, top, right, bottom
626 Common::Array<int16> zones; // per zone: numWrong, then one count per ingredient
627};
628
629// Nancy17 BuildPuzzle. The boards the puzzles were left with, by the name each
630// puzzle keeps its board under. GoldbergPuzzle looks at what was built.
631struct BuildBoardData : public PuzzleData {
632 struct Piece {
633 int16 sourceID = -1; // index of the piece in the puzzle's record
634 int16 zoneID = -1; // -1 when the piece is not in a zone
635 Common::Rect rect; // where the piece sits
636 bool isLocked = false;
637 };
638
639 struct Board {
640 int16 placedCount = 0;
641 int16 heldPiece = -1;
643
644 // The sourceID of the piece in a zone, -1 when the zone is empty
645 int16 getPieceInZone(int16 zoneID) const;
646 };
647
648 static constexpr uint32 getTag() { return MKTAG('B', 'L', 'D', 'B'); }
649 virtual void synchronize(Common::Serializer &ser);
650
652};
653
654// Nancy17 DragSurfacePuzzle. The part of each picture that was last looked at,
655// by the name the puzzle keeps it under.
657 static constexpr uint32 getTag() { return MKTAG('D', 'R', 'G', 'S'); }
658 virtual void synchronize(Common::Serializer &ser);
659
661};
662
663// Nancy17. The scenes that run in streams next to the main one, so they can be
664// started again after loading
665struct StreamData : public PuzzleData {
666 struct Child {
667 Common::String name;
668 byte lifetime = 0;
669 bool restartsParent = false; // Resorting to Danger: the parent starts its scene over when the child ends
670 };
671
672 struct Stream {
673 bool isMainStream = false;
674 Common::String name;
675 byte lifetime = 0;
676 bool capturesInput = false;
677 bool runsFirst = false;
678 int32 zOffset = 0;
679 Common::String sceneName;
680 uint16 frameID = 0;
681 Common::Array<Child> children;
682 };
683
684 static constexpr uint32 getTag() { return MKTAG('S', 'T', 'R', 'M'); }
685 virtual void synchronize(Common::Serializer &ser);
686
687 Common::Array<Stream> streams;
688};
689
690// Nancy17. Named lists of numbers that the scenes fill and check, e.g. the
691// buttons the player pressed so far. Nancy18 also has lists of names.
692struct CollectionData : public PuzzleData {
693 struct Values {
694 Common::Array<double> numbers;
696
697 void clear() { numbers.clear(); names.clear(); }
698 };
699
700 struct Collection {
701 uint32 maxSize = 0;
702 Values values;
703 };
704
705 static constexpr uint32 getTag() { return MKTAG('C', 'O', 'L', 'L'); }
706 virtual void synchronize(Common::Serializer &ser);
707
709};
710
711// Nancy18. What puzzles keep under a name of their own, like where the player
712// stands in each of the sentry rooms, or a card game that was left unfinished.
713// The scenes can throw away what a name holds.
714struct SavedStateData : public PuzzleData {
715 static constexpr uint32 getTag() { return MKTAG('S', 'V', 'S', 'T'); }
716 virtual void synchronize(Common::Serializer &ser);
717
719};
720
721// Nancy19. The values the scripts keep by name, which take the place of the
722// numbered ones of the table
724 static constexpr uint32 getTag() { return MKTAG('S', 'C', 'V', 'L'); }
725 virtual void synchronize(Common::Serializer &ser);
726
728};
729
730// Nancy1New. The texts the scripts keep by name, next to the values
731struct ScriptTextData : public PuzzleData {
732 static constexpr uint32 getTag() { return MKTAG('S', 'C', 'S', 'T'); }
733 virtual void synchronize(Common::Serializer &ser);
734
736};
737
738// Nancy19. What the scripts ask to have kept under a name: a number, a text,
739// or a table of those, already packed into bytes
741 static constexpr uint32 getTag() { return MKTAG('S', 'C', 'S', 'D'); }
742 virtual void synchronize(Common::Serializer &ser);
743
745};
746
747// Nancy27. The results of the conditions of the Brain that are only worked out
748// again when the scripts ask for it, and from Nancy28 on the flags of the Brain
749// the scripts set
750struct BrainData : public PuzzleData {
751 static constexpr uint32 getTag() { return MKTAG('B', 'R', 'N', 'S'); }
752 virtual void synchronize(Common::Serializer &ser);
753
755};
756
757// Nancy29: the inventory item the player wears on the face, like Nancy's
758// glasses. Empty when there is none.
760 static constexpr uint32 getTag() { return MKTAG('E', 'Q', 'I', 'P'); }
761 virtual void synchronize(Common::Serializer &ser);
762
763 Common::String faceItem;
764};
765
766// Nancy21. The pictures the camera of the cell phone took, as PNG files, which
767// the scripts show from the "LOADSAVE" tree
769 static constexpr uint32 getTag() { return MKTAG('S', 'C', 'P', 'C'); }
770 virtual void synchronize(Common::Serializer &ser);
771
773};
774
775// Nancy19. The journal entries and the tasks the scripts gave every player
776// character. A script only hands them out while its conditions hold, so they
777// are kept with the game.
780 Common::String heading; // the keys of the texts
781 Common::String text;
782 };
783
784 struct Task {
785 Common::String text;
786 Common::String flagName; // the flag that has to be set to check the task off
787 };
788
789 static constexpr uint32 getTag() { return MKTAG('S', 'C', 'J', 'N'); }
790 virtual void synchronize(Common::Serializer &ser);
791
792 Common::Array<JournalEntry> journalEntries[kMaxPlayerCharacters];
793 Common::Array<Task> tasks[kMaxPlayerCharacters];
794};
795
796// Nancy17. The contacts in the cell phone of every player character
797struct PhoneBookData : public PuzzleData {
798 struct Entry {
799 Common::String name;
800 Common::String number;
801 Common::String sceneName; // the scene that plays the call
802 int16 nameFlag = -1; // the number shows in place of the name until this is set
803
804 // What the phone lists the contact as
805 Common::String getDisplayText() const;
806 };
807
808 static constexpr uint32 getTag() { return MKTAG('P', 'H', 'B', 'K'); }
809 virtual void synchronize(Common::Serializer &ser);
810
811 Common::Array<Entry> entries[kMaxPlayerCharacters];
812};
813
814PuzzleData *makePuzzleData(const uint32 tag);
815
816} // End of namespace Nancy
817
818#endif // NANCY_PUZZLEDATA_H
Definition: array.h:52
void clear()
Definition: array.h:321
Definition: hashmap.h:85
Definition: serializer.h:80
Definition: str.h:59
#define MKTAG(a0, a1, a2, a3)
Definition: endian.h:188
Definition: actionmanager.h:32
Definition: hash-str.h:45
Definition: hash-str.h:49
Definition: rect.h:536
Definition: puzzledata.h:118
Definition: puzzledata.h:123
Definition: puzzledata.h:750
Definition: puzzledata.h:639
Definition: puzzledata.h:632
Definition: puzzledata.h:631
Definition: puzzledata.h:614
Definition: puzzledata.h:341
Definition: puzzledata.h:313
Definition: puzzledata.h:302
Definition: puzzledata.h:353
Definition: puzzledata.h:700
Definition: puzzledata.h:693
Definition: puzzledata.h:692
Definition: puzzledata.h:553
Definition: puzzledata.h:656
Definition: puzzledata.h:569
Definition: puzzledata.h:759
Definition: commontypes.h:203
Definition: puzzledata.h:163
Definition: puzzledata.h:540
Definition: puzzledata.h:504
Definition: puzzledata.h:192
Definition: puzzledata.h:188
Definition: puzzledata.h:150
Definition: puzzledata.h:589
Definition: puzzledata.h:603
Definition: puzzledata.h:798
Definition: puzzledata.h:797
Definition: puzzledata.h:475
Definition: puzzledata.h:474
Definition: puzzledata.h:38
Definition: puzzledata.h:173
Definition: puzzledata.h:87
Definition: puzzledata.h:56
Definition: puzzledata.h:714
Definition: puzzledata.h:779
Definition: puzzledata.h:784
Definition: puzzledata.h:778
Definition: puzzledata.h:768
Definition: puzzledata.h:740
Definition: puzzledata.h:731
Definition: puzzledata.h:723
Definition: puzzledata.h:109
Definition: puzzledata.h:45
Definition: puzzledata.h:136
Definition: commontypes.h:308
Definition: puzzledata.h:98
Definition: puzzledata.h:666
Definition: puzzledata.h:672
Definition: puzzledata.h:665
Definition: puzzledata.h:252
Definition: puzzledata.h:449
Definition: puzzledata.h:445
Definition: puzzledata.h:220
Definition: puzzledata.h:384
Definition: puzzledata.h:374
Definition: puzzledata.h:370
Definition: puzzledata.h:76
Definition: puzzledata.h:421
Definition: puzzledata.h:236
Definition: puzzledata.h:232
Definition: puzzledata.h:526