ScummVM API documentation
saveload.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  * This file is dual-licensed.
22  * In addition to the GPLv3 license mentioned above, this code is also
23  * licensed under LGPL 2.1. See LICENSES/COPYING.LGPL file for the
24  * full text of the license.
25  *
26  */
27 
28 #ifndef GOB_SAVE_SAVELOAD_H
29 #define GOB_SAVE_SAVELOAD_H
30 
31 #include "gob/save/savefile.h"
32 #include "gob/save/savehandler.h"
33 
34 namespace Gob {
35 
36 class GobEngine;
37 
39 class SaveLoad {
40 public:
42  enum SaveMode {
47  };
48 
53  SaveLoad(GobEngine *vm);
54  virtual ~SaveLoad();
55 
57  static const char *stripPath(const char *fileName, char separator = '\\');
58 
60  static Common::String replacePathSeparators(const char *path, char newSeparator);
61 
63  virtual SaveMode getSaveMode(const char *fileName) const;
64 
66  virtual Common::List<Common::String> getFilesMatchingPattern(const char *pattern) const;
67 
69  int32 getSize(const char *fileName);
71  bool load(const char *fileName, int16 dataVar, int32 size, int32 offset);
72  bool loadToRaw(const char *fileName, byte *ptr, int32 size, int32 offset);
74  bool save(const char *fileName, int16 dataVar, int32 size, int32 offset);
75  bool saveFromRaw(const char *fileName, byte *ptr, int32 size, int32 offset);
76  bool copySaveGame(const char *fileNameSrc, const char *fileNameDest);
77 
79  bool deleteFile(const char *fileName);
80 
81 protected:
82  GobEngine *_vm;
83 
84  virtual SaveHandler *getHandler(const char *fileName) const;
85  virtual const char *getDescription(const char *fileName) const;
86 };
87 
89 class SaveLoad_Geisha : public SaveLoad {
90 public:
91  SaveLoad_Geisha(GobEngine *vm, const char *targetName);
92  ~SaveLoad_Geisha() override;
93 
94  SaveMode getSaveMode(const char *fileName) const override;
95 
96 protected:
97  static const uint32 kSlotCount = 7;
98  static const uint32 kSlotSize = 44;
99 
100  static const uint32 kSaveFileSize = kSlotCount * kSlotSize;
101 
102  struct SaveFile {
103  const char *sourceName;
104  SaveMode mode;
105  SaveHandler *handler;
106  const char *description;
107  };
108 
110  class GameHandler : public SaveHandler {
111  public:
112  GameHandler(GobEngine *vm, const Common::String &target);
113  ~GameHandler() override;
114 
115  int32 getSize() override;
116  bool load(int16 dataVar, int32 size, int32 offset) override;
117  bool save(int16 dataVar, int32 size, int32 offset) override;
118 
119  private:
121  class File : public SlotFileIndexed {
122  public:
123  File(GobEngine *vm, const Common::String &base);
124  ~File() override;
125 
126  int getSlot(int32 offset) const override;
127  int getSlotRemainder(int32 offset) const override;
128  };
129 
130  File _file;
131  };
132 
133  static SaveFile _saveFiles[];
134 
135  SaveHandler *getHandler(const char *fileName) const override;
136  const char *getDescription(const char *fileName) const override;
137 
138  const SaveFile *getSaveFile(const char *fileName) const;
139  SaveFile *getSaveFile(const char *fileName);
140 };
141 
143 class SaveLoad_v2 : public SaveLoad {
144 public:
145  static const uint32 kSlotCount = 15;
146  static const uint32 kSlotNameLength = 40;
147 
149  static const uint32 kIndexSize = kSlotCount * kSlotNameLength;
150 
151  SaveLoad_v2(GobEngine *vm, const char *targetName);
152  ~SaveLoad_v2() override;
153 
154  SaveMode getSaveMode(const char *fileName) const override;
155 
156 protected:
157  struct SaveFile {
158  const char *sourceName;
159  SaveMode mode;
160  SaveHandler *handler;
161  const char *description;
162  };
163 
165  class GameHandler : public SaveHandler {
166  public:
167  GameHandler(GobEngine *vm, const char *target);
168  ~GameHandler() override;
169 
170  int32 getSize() override;
171  bool load(int16 dataVar, int32 size, int32 offset) override;
172  bool save(int16 dataVar, int32 size, int32 offset) override;
173 
174  private:
176  class File : public SlotFileIndexed {
177  public:
178  File(GobEngine *vm, const char *base);
179  ~File() override;
180 
181  int getSlot(int32 offset) const override;
182  int getSlotRemainder(int32 offset) const override;
183  };
184 
185  byte _index[kIndexSize];
186  bool _hasIndex;
187 
188  File *_slotFile;
189 
190  void buildIndex(byte *buffer) const;
191  };
192 
193  static SaveFile _saveFiles[];
194 
195  GameHandler *_gameHandler;
196  NotesHandler *_notesHandler;
197  TempSpriteHandler *_tempSpriteHandler;
198 
199  SaveHandler *getHandler(const char *fileName) const override;
200  const char *getDescription(const char *fileName) const override;
201 
202  const SaveFile *getSaveFile(const char *fileName) const;
203  SaveFile *getSaveFile(const char *fileName);
204 };
205 
208 public:
209  static const uint32 kSlotCount = 15;
210  static const uint32 kSlotNameLength = 40;
211 
213  static const uint32 kIndexSize = kSlotCount * kSlotNameLength;
214 
215  SaveLoad_Fascination(GobEngine *vm, const char *targetName);
216  ~SaveLoad_Fascination() override;
217 
218  SaveMode getSaveMode(const char *fileName) const override;
219 
220 protected:
221  struct SaveFile {
222  const char *sourceName;
223  SaveMode mode;
224  int slot;
225  SaveHandler *handler;
226  const char *description;
227  };
228 
230  class GameHandler : public SaveHandler {
231  public:
232  GameHandler(GobEngine *vm, const char *target, int slot, byte *index, bool *hasIndex);
233  ~GameHandler() override;
234 
235  int32 getSize() override;
236  bool load(int16 dataVar, int32 size, int32 offset) override;
237  bool save(int16 dataVar, int32 size, int32 offset) override;
238 
239  private:
241  class File : public SlotFileIndexed {
242  public:
243  File(GobEngine *vm, const char *base);
244  ~File() override;
245 
246  int getSlot(int32 offset) const override;
247  int getSlotRemainder(int32 offset) const override;
248  };
249 
250  byte *_index;
251  bool *_hasIndex;
252  int _slot;
253 
254  File *_slotFile;
255 
256  void buildIndex(byte *buffer) const;
257  };
258 
259  byte _index[kIndexSize];
260  bool _hasIndex;
261 
262  static SaveFile _saveFiles[];
263 
264  SaveHandler *getHandler(const char *fileName) const override;
265  const char *getDescription(const char *fileName) const override;
266 
267  const SaveFile *getSaveFile(const char *fileName) const;
268  SaveFile *getSaveFile(const char *fileName);
269 };
270 
272 class SaveLoad_Adibou1 : public SaveLoad {
273 public:
274  static const int32 kAdibou1NbrOfDrawings = 8;
275  SaveLoad_Adibou1(GobEngine *vm, const char *targetName);
276  ~SaveLoad_Adibou1() override;
277 
278  SaveMode getSaveMode(const char *fileName) const override;
279 
280 protected:
281  struct SaveFile {
282  const char *sourceName;
283  SaveMode mode;
284  SaveHandler *handler;
285  const char *description;
286  };
287 
289  public:
290  SpriteHandler(GobEngine *vm, const Common::String &target, const Common::String &ext);
291  ~SpriteHandler() override;
292 
293  int32 getSize() override;
294  bool load(int16 dataVar, int32 size, int32 offset) override;
295  bool save(int16 dataVar, int32 size, int32 offset) override;
296 
297  private:
298  class File : public SlotFileStatic {
299  public:
300  File(GobEngine *vm, const Common::String &base, const Common::String &ext);
301  ~File() override;
302  };
303 
304  File _file;
305  };
306 
307 
309  public:
311  const Common::String &target,
312  const Common::String &ext);
313  ~DrawingWithThumbnailHandler() override;
314 
315  int32 getSize() override;
316  bool load(int16 dataVar, int32 size, int32 offset) override;
317  bool save(int16 dataVar, int32 size, int32 offset) override;
318 
319  private:
320  class File : public SlotFileStatic {
321  public:
322  File(GobEngine *vm, const Common::String &base, const Common::String &ext);
323  ~File() override;
324  };
325 
326  File _file;
327  SaveWriter *_writer;
328  SaveReader *_reader;
329  };
330 
331  class GameFileHandler : public SaveHandler {
332  public:
333  GameFileHandler(GobEngine *vm, const Common::String &target, const Common::String &ext);
334  ~GameFileHandler() override;
335 
336  int32 getSize() override;
337  bool load(int16 dataVar, int32 size, int32 offset) override;
338  bool save(int16 dataVar, int32 size, int32 offset) override;
339  bool deleteFile() override;
340 
341  private:
342  // Save from raw pointer if ptrRaw != nullptr, else save from game variables
343  bool save(const byte *ptrRaw, int16 dataVar, int32 size, int32 offset);
344 
345  class File : public SlotFileStatic {
346  public:
347  File(GobEngine *vm, const Common::String &base, const Common::String &ext);
348  ~File() override;
349  };
350 
351  File _file;
352  };
353 
354  static SaveFile _saveFiles[];
355 
356  GameFileHandler *_bouHandler;
357  GameFileHandler *_constructionHandler;
358  SpriteHandler *_drawingHandler;
359  TempSpriteHandler *_menuHandler;
360  DrawingWithThumbnailHandler *_drawingWithThumbnailHandler[kAdibou1NbrOfDrawings];
361 
362  SaveHandler *getHandler(const char *fileName) const override;
363  const char *getDescription(const char *fileName) const override;
364 
365  const SaveFile *getSaveFile(const char *fileName) const;
366  SaveFile *getSaveFile(const char *fileName);
367 };
368 
370 class SaveLoad_v3 : public SaveLoad {
371 public:
372  static const uint32 kSlotCount = 30;
373  static const uint32 kSlotNameLength = 40;
374 
375  static const uint32 kPropsSize = 500;
377  static const uint32 kIndexSize = kSlotCount * kSlotNameLength;
378 
381  kScreenshotTypeLost
382  };
383 
384  SaveLoad_v3(GobEngine *vm, const char *targetName, ScreenshotType sShotType);
385  ~SaveLoad_v3() override;
386 
387  SaveMode getSaveMode(const char *fileName) const override;
388 
389 protected:
390  struct SaveFile {
391  const char *sourceName;
392  SaveMode mode;
393  SaveHandler *handler;
394  const char *description;
395  };
396 
397  class ScreenshotHandler;
398 
400  class GameHandler : public SaveHandler {
401  friend class SaveLoad_v3::ScreenshotHandler;
402  public:
403 
404  GameHandler(GobEngine *vm, const char *target, bool usesScreenshots);
405  ~GameHandler() override;
406 
407  int32 getSize() override;
408  bool load(int16 dataVar, int32 size, int32 offset) override;
409  bool save(int16 dataVar, int32 size, int32 offset) override;
410 
411  bool saveScreenshot(int slot, const SavePartSprite *screenshot);
412  bool loadScreenshot(int slot, SavePartSprite *screenshot);
413 
415  class File : public SlotFileIndexed {
416  public:
417  File(GobEngine *vm, const char *base);
418  File(const File &file);
419  ~File() override;
420 
421  int getSlot(int32 offset) const override;
422  int getSlotRemainder(int32 offset) const override;
423  };
424  private:
425 
426  File *_slotFile;
427 
428  bool _usesScreenshots;
429 
430  bool _firstSize;
431 
433  byte _props[kPropsSize];
434  byte _index[kIndexSize];
435  bool _hasIndex;
436 
437  SaveReader *_reader;
438  SaveWriter *_writer;
439 
440  void buildIndex(byte *buffer) const;
441 
442  bool createReader(int slot);
443  bool createWriter(int slot);
444 
445  };
446 
449  public:
450  ScreenshotHandler(GobEngine *vm, GameHandler *gameHandler, ScreenshotType sShotType);
451  ~ScreenshotHandler() override;
452 
453  int32 getSize() override;
454  bool load(int16 dataVar, int32 size, int32 offset) override;
455  bool save(int16 dataVar, int32 size, int32 offset) override;
456 
457  private:
459  class File : public SaveLoad_v3::GameHandler::File {
460  public:
461  File(const SaveLoad_v3::GameHandler::File &file,
462  uint32 shotSize, uint32 shotIndexSize);
463  ~File() override;
464 
465  int getSlot(int32 offset) const override;
466  int getSlotRemainder(int32 offset) const override;
467 
468  void buildScreenshotIndex(byte *buffer) const;
469 
470  protected:
471  uint32 _shotSize;
472  uint32 _shotIndexSize;
473  };
474 
475  File *_file;
476  GameHandler *_gameHandler;
477  ScreenshotType _sShotType;
478 
479  uint32 _shotSize;
480  int32 _shotIndexSize;
481  byte _index[80];
482  };
483 
484  static SaveFile _saveFiles[];
485 
486  ScreenshotType _sShotType;
487 
488  GameHandler *_gameHandler;
489  NotesHandler *_notesHandler;
490  TempSpriteHandler *_tempSpriteHandler;
491  ScreenshotHandler *_screenshotHandler;
492 
493  SaveHandler *getHandler(const char *fileName) const override;
494  const char *getDescription(const char *fileName) const override;
495 
496  const SaveFile *getSaveFile(const char *fileName) const;
497  SaveFile *getSaveFile(const char *fileName);
498 };
499 
501 class SaveLoad_Inca2 : public SaveLoad {
502 public:
503  static const uint32 kSlotCount = 40;
504  static const uint32 kPropsSize = 500;
505 
506  SaveLoad_Inca2(GobEngine *vm, const char *targetName);
507  ~SaveLoad_Inca2() override;
508 
509  SaveMode getSaveMode(const char *fileName) const override;
510 
511 protected:
512  struct SaveFile {
513  const char *sourceName;
514  SaveMode mode;
515  SaveHandler *handler;
516  const char *description;
517  };
518 
520  class VoiceHandler : public SaveHandler {
521  public:
522  VoiceHandler(GobEngine *vm);
523  ~VoiceHandler() override;
524 
525  int32 getSize() override;
526  bool load(int16 dataVar, int32 size, int32 offset) override;
527  bool save(int16 dataVar, int32 size, int32 offset) override;
528  };
529 
530  class ScreenshotHandler;
531 
533  class GameHandler : public SaveHandler {
535  public:
536 
537  GameHandler(GobEngine *vm, const char *target);
538  ~GameHandler() override;
539 
540  int32 getSize() override;
541  bool load(int16 dataVar, int32 size, int32 offset) override;
542  bool save(int16 dataVar, int32 size, int32 offset) override;
543 
544  bool saveScreenshot(int slot, const SavePartSprite *screenshot);
545  bool loadScreenshot(int slot, SavePartSprite *screenshot);
546 
548  class File : public SlotFileIndexed {
549  public:
550  File(GobEngine *vm, const char *base);
551  File(const File &file);
552  ~File() override;
553 
554  int getSlot(int32 offset) const override;
555  int getSlotRemainder(int32 offset) const override;
556  };
557 
558  private:
559 
560  File *_slotFile;
561 
562  byte _props[kPropsSize];
563 
564  SaveReader *_reader;
565  SaveWriter *_writer;
566 
567  void buildIndex();
568 
569  bool createReader(int slot);
570  bool createWriter(int slot);
571  };
572 
575  public:
576  ScreenshotHandler(GobEngine *vm, GameHandler *gameHandler);
577  ~ScreenshotHandler() override;
578 
579  int32 getSize() override;
580  bool load(int16 dataVar, int32 size, int32 offset) override;
581  bool save(int16 dataVar, int32 size, int32 offset) override;
582 
583  private:
585  class File : public SaveLoad_Inca2::GameHandler::File {
586  public:
587  File(const SaveLoad_Inca2::GameHandler::File &file);
588  ~File() override;
589 
590  int getSlot(int32 offset) const override;
591  int getSlotRemainder(int32 offset) const override;
592 
593  void buildScreenshotIndex(byte *buffer) const;
594  };
595 
596  File *_file;
597  GameHandler *_gameHandler;
598 
599  byte _index[80];
600  };
601 
602  static SaveFile _saveFiles[];
603 
604  VoiceHandler *_voiceHandler;
605  TempSpriteHandler *_tempSpriteHandler;
606  GameHandler *_gameHandler;
607  ScreenshotHandler *_screenshotHandler;
608 
609  SaveHandler *getHandler(const char *fileName) const override;
610  const char *getDescription(const char *fileName) const override;
611 
612  const SaveFile *getSaveFile(const char *fileName) const;
613  SaveFile *getSaveFile(const char *fileName);
614 };
615 
617 class SaveLoad_v4 : public SaveLoad {
618 public:
619  static const uint32 kSlotCount = 10;
620  static const uint32 kSlotNameLength = 40;
621 
622  static const uint32 kPropsSize = 500;
624  static const uint32 kIndexSize = (kSlotCount * kSlotNameLength) + 800;
625 
626  SaveLoad_v4(GobEngine *vm, const char *targetName);
627  ~SaveLoad_v4() override;
628 
629  SaveMode getSaveMode(const char *fileName) const override;
630 
631 protected:
632  struct SaveFile {
633  const char *sourceName;
634  SaveMode mode;
635  SaveHandler *handler;
636  const char *description;
637  };
638 
639  class ScreenPropsHandler;
640 
642  class GameHandler : public SaveHandler {
643  friend class SaveLoad_v4::ScreenPropsHandler;
644  public:
645  GameHandler(GobEngine *vm, const char *target);
646  ~GameHandler() override;
647 
648  int getLastSlot() const;
649 
650  int32 getSize() override;
651  bool load(int16 dataVar, int32 size, int32 offset) override;
652  bool save(int16 dataVar, int32 size, int32 offset) override;
653 
654  bool saveScreenProps(int slot, const byte *props);
655  bool loadScreenProps(int slot, byte *props);
656 
658  class File : public SlotFileIndexed {
659  public:
660  File(GobEngine *vm, const char *base);
661  File(const File &file);
662  ~File() override;
663 
664  int getSlot(int32 offset) const override;
665  int getSlotRemainder(int32 offset) const override;
666  };
667 
668  private:
669  bool _firstSize;
670 
671  byte _props[kPropsSize];
672  byte _index[kIndexSize];
673  bool _hasIndex;
674 
675  File *_slotFile;
676 
677  int _lastSlot;
678 
679  SaveReader *_reader;
680  SaveWriter *_writer;
681 
682  void buildIndex(byte *buffer) const;
683 
684  bool createReader(int slot);
685  bool createWriter(int slot);
686  };
687 
689  friend class SaveLoad_v4::ScreenPropsHandler;
690  public:
692  ~CurScreenPropsHandler() override;
693 
694  int32 getSize() override;
695  bool load(int16 dataVar, int32 size, int32 offset) override;
696  bool save(int16 dataVar, int32 size, int32 offset) override;
697 
698  private:
699  byte *_props;
700  };
701 
703  public:
704  ScreenPropsHandler(GobEngine *vm, uint32 slot,
705  CurScreenPropsHandler *curProps, GameHandler *gameHandler);
706  ~ScreenPropsHandler() override;
707 
708  int32 getSize() override;
709  bool load(int16 dataVar, int32 size, int32 offset) override;
710  bool save(int16 dataVar, int32 size, int32 offset) override;
711 
712  private:
713  class File : public SaveLoad_v4::GameHandler::File {
714  public:
715  File(const SaveLoad_v4::GameHandler::File &file, uint32 slot);
716  ~File() override;
717 
718  int getSlot(int32 offset) const override;
719  int getSlotRemainder(int32 offset) const override;
720 
721  private:
722  uint32 _slot;
723  };
724 
725  uint32 _slot;
726  CurScreenPropsHandler *_curProps;
727  GameHandler *_gameHandler;
728 
729  File *_file;
730  };
731 
732  static SaveFile _saveFiles[];
733 
734  GameHandler *_gameHandler;
735  CurScreenPropsHandler *_curProps;
736  ScreenPropsHandler *_props[10];
737 
738  SaveHandler *getHandler(const char *fileName) const override;
739  const char *getDescription(const char *fileName) const override;
740 
741  const SaveFile *getSaveFile(const char *fileName) const;
742  SaveFile *getSaveFile(const char *fileName);
743 };
744 
746 class SaveLoad_v6 : public SaveLoad {
747 public:
748  static const uint32 kSlotCount = 60;
749  static const uint32 kSlotNameLength = 40;
750 
751  static const uint32 kPropsSize = 500;
753  static const uint32 kIndexSize = kSlotCount * kSlotNameLength;
754 
755  SaveLoad_v6(GobEngine *vm, const char *targetName);
756  ~SaveLoad_v6() override;
757 
758  SaveMode getSaveMode(const char *fileName) const override;
759 
760 protected:
761  struct SaveFile {
762  const char *sourceName;
763  SaveMode mode;
764  SaveHandler *handler;
765  const char *description;
766  };
767 
770  public:
772  ~SpriteHandler() override;
773 
774  bool set(SaveReader *reader, uint32 part);
775  bool get(SaveWriter *writer, uint32 part);
776  };
777 
779  class GameHandler : public SaveHandler {
780  public:
781  GameHandler(GobEngine *vm, const char *target, SpriteHandler &spriteHandler);
782  ~GameHandler() override;
783 
784  int32 getSize() override;
785  bool load(int16 dataVar, int32 size, int32 offset) override;
786  bool save(int16 dataVar, int32 size, int32 offset) override;
787 
788  uint8 getExtraID(int slot);
789  bool loadExtra(int slot, uint8 id, int16 dataVar, int32 size, int32 offset);
790  bool saveExtra(int slot, uint8 id, int16 dataVar, int32 size, int32 offset);
791 
792  private:
794  class File : public SlotFileIndexed {
795  public:
796  File(GobEngine *vm, const char *base);
797  ~File() override;
798 
799  int getSlot(int32 offset) const override;
800  int getSlotRemainder(int32 offset) const override;
801  };
802 
803  SpriteHandler *_spriteHandler;
804 
805  byte _props[kPropsSize];
806  byte _index[kIndexSize];
807 
808  File *_slotFile;
809 
810  SaveReader *_reader;
811  SaveWriter *_writer;
812 
813  bool _hasExtra;
814 
815  void buildIndex(byte *buffer) const;
816 
817  void refreshProps();
818 
819  bool createReader(int slot);
820  bool createWriter(int slot);
821  };
822 
824  class AutoHandler : public SaveHandler {
825  public:
826  AutoHandler(GobEngine *vm, const Common::String &target);
827  ~AutoHandler() override;
828 
829  int32 getSize() override;
830  bool load(int16 dataVar, int32 size, int32 offset) override;
831  bool save(int16 dataVar, int32 size, int32 offset) override;
832 
833  private:
834  class File : public SlotFileStatic {
835  public:
836  File(GobEngine *vm, const Common::String &base);
837  ~File() override;
838  };
839 
840  File _file;
841  };
842 
845  public:
846  AutoSpriteHandler(GobEngine *vm, const Common::String &target);
847  ~AutoSpriteHandler() override;
848 
849  int32 getSize() override;
850  bool load(int16 dataVar, int32 size, int32 offset) override;
851  bool save(int16 dataVar, int32 size, int32 offset) override;
852 
853  private:
854  class File : public SlotFileStatic {
855  public:
856  File(GobEngine *vm, const Common::String &base);
857  ~File() override;
858  };
859 
860  File _file;
861  };
862 
864  class TempHandler : public SaveHandler {
865  public:
866  TempHandler(GobEngine *vm);
867  ~TempHandler() override;
868 
869  int32 getSize() override;
870  bool load(int16 dataVar, int32 size, int32 offset) override;
871  bool save(int16 dataVar, int32 size, int32 offset) override;
872  bool deleteFile() override;
873 
874  private:
875  bool _empty;
876 
877  uint32 _size;
878  byte *_data;
879  };
880 
881  class ExtraHandler : public SaveHandler {
882  public:
883  ExtraHandler(GobEngine *vm, GameHandler &game, uint8 id, int slot);
884  ~ExtraHandler() override;
885 
886  int32 getSize() override;
887  bool load(int16 dataVar, int32 size, int32 offset) override;
888  bool save(int16 dataVar, int32 size, int32 offset) override;
889 
890  private:
891  uint8 _id;
892  int _slot;
893 
894  GameHandler *_game;
895  };
896 
897  static SaveFile _saveFiles[];
898 
899  SpriteHandler *_spriteHandler;
900  GameHandler *_gameHandler;
901  AutoHandler *_autoHandler;
902  AutoSpriteHandler *_autoSpriteHandler;
903  TempHandler *_tmpHandler[2];
904  ExtraHandler *_extraHandler[120];
905 
906  SaveHandler *getHandler(const char *fileName) const override;
907  const char *getDescription(const char *fileName) const override;
908 
909  const SaveFile *getSaveFile(const char *fileName) const;
910  SaveFile *getSaveFile(const char *fileName);
911 };
912 
914 class SaveLoad_Playtoons : public SaveLoad {
915 public:
916  static const uint32 kSlotCount = 60;
917  static const uint32 kSlotNameLength = 40;
918 
919  static const uint32 kPropsSize = 3921;
921  static const uint32 kIndexSize = kSlotCount * kSlotNameLength;
922 
923  SaveLoad_Playtoons(GobEngine *vm, const char *targetName);
924  ~SaveLoad_Playtoons() override;
925 
926  SaveMode getSaveMode(const char *fileName) const override;
927 
928 protected:
929  struct SaveFile {
930  const char *sourceName;
931  SaveMode mode;
932  SaveHandler *handler;
933  const char *description;
934  };
935 
937  class GameHandler : public SaveHandler {
938  public:
939  GameHandler(GobEngine *vm, const char *target);
940  ~GameHandler() override;
941 
942  int32 getSize() override;
943  bool load(int16 dataVar, int32 size, int32 offset) override;
944  bool save(int16 dataVar, int32 size, int32 offset) override;
945 
946  private:
948  class File : public SlotFileIndexed {
949  public:
950  File(GobEngine *vm, const char *base);
951  ~File() override;
952 
953  int getSlot(int32 offset) const override;
954  int getSlotRemainder(int32 offset) const override;
955  };
956 
957  byte _props[kPropsSize];
958  byte _index[kIndexSize];
959 
960  File *_slotFile;
961  TempSpriteHandler *_tempSpriteHandler;
962 
963  void buildIndex(byte *buffer) const;
964  };
965 
966  static SaveFile _saveFiles[];
967 
968  GameHandler *_gameHandler;
969 
970  SaveHandler *getHandler(const char *fileName) const override;
971  const char *getDescription(const char *fileName) const override;
972 
973  const SaveFile *getSaveFile(const char *fileName) const;
974  SaveFile *getSaveFile(const char *fileName);
975 };
976 
978 class SaveLoad_v7: public SaveLoad {
979 public:
980  static const uint32 kChildrenCount = 16;
981  static const uint32 kAdibou2NbrOfApplications = 5;
982  static const uint32 kAdibou2NbrOfSavedDrawings = 12;
983  static const uint32 kAdibou2NbrOfConstructionGameFiles = 3;
984  SaveLoad_v7(GobEngine *vm, const char *targetName);
985  ~SaveLoad_v7() override;
986 
987  SaveMode getSaveMode(const char *fileName) const override;
988  Common::List<Common::String> getFilesMatchingPattern(const char *pattern) const override;
989 
990 protected:
991  struct SaveFile {
992  const char *sourceName;
993  SaveMode mode;
994  SaveHandler *handler;
995  const char *description;
996  };
997 
999  public:
1000  SpriteHandler(GobEngine *vm, const Common::String &target, const Common::String &ext);
1001  ~SpriteHandler() override;
1002 
1003  int32 getSize() override;
1004  bool load(int16 dataVar, int32 size, int32 offset) override;
1005  bool save(int16 dataVar, int32 size, int32 offset) override;
1006  bool loadToRaw(byte *ptr, int32 size, int32 offset) override;
1007  bool saveFromRaw(const byte* ptr, int32 size, int32 offset) override;
1008  bool deleteFile() override;
1009 
1010  private:
1011  class File : public SlotFileStatic {
1012  public:
1013  File(GobEngine *vm, const Common::String &base, const Common::String &ext);
1014  ~File() override;
1015  };
1016 
1017  File _file;
1018  };
1019 
1021  public:
1023  SaveReader *reader,
1024  SaveWriter *writer,
1025  bool isThumbnail,
1026  uint32 chunkSize = 1);
1027  ~DrawingOnFloppyDiskHandler() override;
1028 
1029  int32 getSize() override;
1030  bool load(int16 dataVar, int32 size, int32 offset) override;
1031  bool save(int16 dataVar, int32 size, int32 offset) override;
1032  bool deleteFile() override;
1033 
1034  private:
1035  class File : public SlotFileStatic {
1036  public:
1037  File(GobEngine *vm, const Common::String &base, const Common::String &ext);
1038  ~File() override;
1039  };
1040 
1041  //File _file;
1042  SaveWriter *_writer;
1043  SaveReader *_reader;
1044  bool _isThumbnail;
1045  int32 _chunkSize;
1046  };
1047 
1048  class GameFileHandler : public SaveHandler {
1049  public:
1050  GameFileHandler(GobEngine *vm, const Common::String &target, const Common::String &ext);
1051  ~GameFileHandler() override;
1052 
1053  int32 getSize() override;
1054  bool load(int16 dataVar, int32 size, int32 offset) override;
1055  bool save(int16 dataVar, int32 size, int32 offset) override;
1056  bool loadToRaw(byte *ptr, int32 size, int32 offset) override;
1057  bool saveFromRaw(const byte *ptr, int32 size, int32 offset) override;
1058  bool deleteFile() override;
1059 
1060  private:
1061  // Save from raw pointer if ptrRaw != nullptr, else save from game variables
1062  bool save(const byte *ptrRaw, int16 dataVar, int32 size, int32 offset);
1063 
1064  class File : public SlotFileStatic {
1065  public:
1066  File(GobEngine *vm, const Common::String &base, const Common::String &ext);
1067  ~File() override;
1068  };
1069 
1070  File _file;
1071  };
1072 
1073 
1074  static SaveFile _saveFiles[];
1075 
1076  SpriteHandler *_faceHandler[kChildrenCount];
1077  FakeFileHandler *_childrenHandler;
1078  FakeFileHandler *_debilHandler[4];
1079  GameFileHandler *_configHandler;
1080  GameFileHandler *_adibou2EnvHandler[kChildrenCount];
1081  SpriteHandler *_adibou2WeatherHandler[kChildrenCount];
1082  GameFileHandler *_adibou2BreakoutGameProgressHandler[kChildrenCount];
1083  FakeFileHandler *_adibou2ConstructionGameTempFileHandler[kAdibou2NbrOfConstructionGameFiles];
1084  GameFileHandler *_adibou2ConstructionGameProgressHandler[kChildrenCount][kAdibou2NbrOfConstructionGameFiles];
1085  GameFileHandler *_adibou2AppProgressHandler[kChildrenCount][kAdibou2NbrOfApplications];
1086  GameFileHandler *_adibou2MemoHandler[kChildrenCount];
1087  GameFileHandler *_adibou2DiploHandler[kChildrenCount];
1088  GameFileHandler *_adibou2AppliHandler[kAdibou2NbrOfApplications];
1089  GameFileHandler *_adibou2CriteHandler[kAdibou2NbrOfApplications];
1090  GameFileHandler *_adibou2ExoHandler[kAdibou2NbrOfApplications];
1091  GameFileHandler *_adibou2ApplicationsInfoHandler;
1092  FakeFileHandler *_adibou2RetourHandler;
1093  FakeFileHandler *_adibou2LanceHandler;
1094  TempSpriteHandler *_adibou2AppIcoHandler[kAdibou2NbrOfApplications];
1095  SpriteHandler *_adibou2DrawingHandler[kChildrenCount][kAdibou2NbrOfSavedDrawings];
1096  SpriteHandler *_adibou2DrawingThumbnailHandler[kChildrenCount][kAdibou2NbrOfSavedDrawings];
1097  GameFileHandler *_adibou2DrawingPaletteHandler[kChildrenCount];
1098  SpriteHandler *_adibou2DrawingMailboxHandler[kChildrenCount];
1099  SpriteHandler *_adibou2CakePhotoHandler[kChildrenCount];
1100  SpriteHandler *_adibou2FlowerPhotoHandler[kChildrenCount];
1101  SpriteHandler *_adibou2FlowerInVaseHandler[kChildrenCount];
1102  SpriteHandler *_adibou2FadedFlowerInVaseHandler[kChildrenCount];
1103  SpriteHandler *_adibou2PosterHandler[kChildrenCount];
1104  DrawingOnFloppyDiskHandler *_adibou2DrawingOnFloppyDiskHandler;
1105  DrawingOnFloppyDiskHandler *_adibou2DrawingThumbnailOnFloppyDiskHandler;
1106  FakeFileHandler *_adibou2TestDobHandler;
1107  FakeFileHandler *_adibou2ExerciseListHandler;
1108 
1109  FakeFileHandler *_addy4BaseHandler[2];
1110  FakeFileHandler *_addy4GrundschuleHandler[11];
1111 
1112  SaveHandler *getHandler(const char *fileName) const override;
1113  const char *getDescription(const char *fileName) const override;
1114 
1115  const SaveFile *getSaveFile(const char *fileName) const;
1116 };
1117 
1118 } // End of namespace Gob
1119 
1120 #endif // GOB_SAVE_SAVELOAD_H
Definition: saveload.h:221
Definition: saveload.h:448
Definition: saveload.h:143
static const char * stripPath(const char *fileName, char separator='\\')
Definition: saveload.h:937
Definition: gob.h:163
Definition: str.h:59
Definition: savefile.h:313
Definition: saveload.h:702
Definition: savehandler.h:96
Definition: savehandler.h:172
Ignore it.
Definition: saveload.h:44
Definition: saveload.h:165
Definition: savefile.h:340
SaveMode
Definition: saveload.h:42
Definition: saveload.h:881
Definition: savehandler.h:194
Definition: saveload.h:824
Definition: saveload.h:110
Definition: saveload.h:102
Definition: saveload.h:779
Definition: saveload.h:617
Definition: saveload.h:89
ScreenshotType
Definition: saveload.h:379
Definition: saveload.h:512
Definition: saveload.h:533
virtual Common::List< Common::String > getFilesMatchingPattern(const char *pattern) const
SaveLoad(GobEngine *vm)
Definition: saveload.h:207
Definition: saveload.h:978
Definition: saveload.h:642
A normal save.
Definition: saveload.h:46
Definition: savehandler.h:141
Definition: saveload.h:157
Definition: anifile.h:40
Definition: saveload.h:991
Definition: savehandler.h:68
Definition: saveload.h:761
Definition: saveload.h:390
Definition: saveload.h:632
Definition: savehandler.h:116
Definition: saveload.h:288
Goblins 3 type screenshot.
Definition: saveload.h:380
Definition: saveload.h:864
Definition: saveload.h:400
Definition: saveload.h:370
Definition: saveload.h:520
Definition: saveload.h:230
Definition: saveload.h:548
Definition: saveload.h:574
bool load(const char *fileName, int16 dataVar, int32 size, int32 offset)
Definition: saveload.h:272
Definition: savefile.h:162
Definition: saveload.h:844
Definition: saveload.h:415
static Common::String replacePathSeparators(const char *path, char newSeparator)
Definition: saveload.h:929
Definition: saveload.h:39
Definition: saveload.h:501
int32 getSize(const char *fileName)
Definition: saveload.h:1048
bool save(const char *fileName, int16 dataVar, int32 size, int32 offset)
Definition: saveload.h:914
Definition: saveload.h:769
Definition: saveload.h:331
Definition: saveload.h:746
bool deleteFile(const char *fileName)
Definition: saveload.h:688
Don&#39;t handle it.
Definition: saveload.h:43
Definition: saveload.h:281
virtual SaveMode getSaveMode(const char *fileName) const
Definition: saveload.h:658
Definition: saveload.h:998
Just claim it exists.
Definition: saveload.h:45