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