Ticket #3651: sword1_save.patch
File sword1_save.patch, 5.5 KB (added by , 17 years ago) |
---|
-
sword1.cpp
339 339 _logic->initialize(); 340 340 _objectMan->initialize(); 341 341 _mouse->initialize(); 342 _control = new Control( _saveFileMan, _resMan, _objectMan, _system, _mouse, _sound, _music);342 _control = new Control(this, _saveFileMan, _resMan, _objectMan, _system, _mouse, _sound, _music); 343 343 344 344 return 0; 345 345 } -
control.h
42 42 class Mouse; 43 43 class Music; 44 44 class Sound; 45 class SwordEngine; 45 46 46 47 #define MAX_BUTTONS 16 47 48 … … 82 83 83 84 class Control { 84 85 public: 85 Control( Common::SaveFileManager *saveFileMan, ResMan *pResMan, ObjectMan *pObjMan, OSystem *system, Mouse *pMouse, Sound *pSound, Music *pMusic);86 Control(SwordEngine *engine, Common::SaveFileManager *saveFileMan, ResMan *pResMan, ObjectMan *pObjMan, OSystem *system, Mouse *pMouse, Sound *pSound, Music *pMusic); 86 87 uint8 runPanel(void); 87 88 void doRestore(void); 88 89 void askForCd(void); … … 134 135 static const uint8 _languageStrings[8 * 20][43]; 135 136 const uint8 (*_lStrings)[43]; 136 137 Common::SaveFileManager *_saveFileMan; 138 SwordEngine *_engine; 137 139 ObjectMan *_objMan; 138 140 ResMan *_resMan; 139 141 OSystem *_system; -
control.cpp
160 160 draw(); 161 161 } 162 162 163 Control::Control(Common::SaveFileManager *saveFileMan, ResMan *pResMan, ObjectMan *pObjMan, OSystem *system, Mouse *pMouse, Sound *pSound, Music *pMusic) { 163 Control::Control(SwordEngine *engine, Common::SaveFileManager *saveFileMan, ResMan *pResMan, ObjectMan *pObjMan, OSystem *system, Mouse *pMouse, Sound *pSound, Music *pMusic) { 164 _engine = engine; 164 165 _saveFileMan = saveFileMan; 165 166 _resMan = pResMan; 166 167 _objMan = pObjMan; … … 717 718 718 719 void Control::readSavegameDescriptions(void) { 719 720 Common::InSaveFile *inf; 720 inf = _saveFileMan->openForLoading( "SAVEGAME.INF");721 inf = _saveFileMan->openForLoading((_engine->getTargetName() + ".inf").c_str()); 721 722 _saveScrollPos = _saveFiles = 0; 722 723 _selectedSavegame = 255; 723 724 for (uint8 cnt = 0; cnt < 64; cnt++) { … … 761 762 762 763 void Control::writeSavegameDescriptions(void) { 763 764 Common::OutSaveFile *outf; 764 outf = _saveFileMan->openForSaving( "SAVEGAME.INF");765 outf = _saveFileMan->openForSaving((_engine->getTargetName() + ".inf").c_str()); 765 766 766 767 if (!outf) { 767 768 // Display an error message, and do nothing 768 displayMessage(0, "Can't create SAVEGAME.INF. (%s)", _saveFileMan->popErrorDesc().c_str());769 displayMessage(0, "Can't create %s.inf. (%s)", _engine->getTargetName().c_str(), _saveFileMan->popErrorDesc().c_str()); 769 770 return; 770 771 } 771 772 … … 784 785 } 785 786 outf->finalize(); 786 787 if (outf->ioFailed()) 787 displayMessage(0, "Can't write to SAVEGAME.INF. Device full? (%s)", _saveFileMan->popErrorDesc().c_str());788 displayMessage(0, "Can't write to %s.inf. Device full? (%s)", _engine->getTargetName().c_str(), _saveFileMan->popErrorDesc().c_str()); 788 789 delete outf; 789 790 } 790 791 … … 947 948 } 948 949 949 950 void Control::saveGameToFile(uint8 slot) { 950 char fName[15]; 951 Common::String filename = _engine->getTargetName(); 952 char fName[5]; 953 snprintf(fName, 5, ".%03d", slot); 954 filename += fName; 955 951 956 uint16 cnt; 952 sprintf(fName, "SAVEGAME.%03d", slot);953 957 uint16 liveBuf[TOTAL_SECTIONS]; 954 958 Common::OutSaveFile *outf; 955 outf = _saveFileMan->openForSaving(f Name);959 outf = _saveFileMan->openForSaving(filename.c_str()); 956 960 if (!outf) { 957 961 // Display an error message and do nothing 958 displayMessage(0, "Unable to create file '%s'. (%s)", f Name, _saveFileMan->popErrorDesc().c_str());962 displayMessage(0, "Unable to create file '%s'. (%s)", filename.c_str(), _saveFileMan->popErrorDesc().c_str()); 959 963 return; 960 964 } 961 965 … … 979 983 outf->writeUint32LE(playerRaw[cnt2]); 980 984 outf->finalize(); 981 985 if (outf->ioFailed()) 982 displayMessage(0, "Couldn't write to file '%s'. Device full? (%s)", f Name, _saveFileMan->popErrorDesc().c_str());986 displayMessage(0, "Couldn't write to file '%s'. Device full? (%s)", filename.c_str(), _saveFileMan->popErrorDesc().c_str()); 983 987 delete outf; 984 988 } 985 989 986 990 bool Control::restoreGameFromFile(uint8 slot) { 987 char fName[15]; 991 Common::String filename = _engine->getTargetName(); 992 char fName[5]; 993 snprintf(fName, 5, ".%03d", slot); 994 filename += fName; 995 988 996 uint16 cnt; 989 sprintf(fName, "SAVEGAME.%03d", slot);990 997 Common::InSaveFile *inf; 991 inf = _saveFileMan->openForLoading(f Name);998 inf = _saveFileMan->openForLoading(filename.c_str()); 992 999 if (!inf) { 993 1000 // Display an error message, and do nothing 994 displayMessage(0, "Can't open file '%s'. (%s)", f Name, _saveFileMan->popErrorDesc().c_str());1001 displayMessage(0, "Can't open file '%s'. (%s)", filename.c_str(), _saveFileMan->popErrorDesc().c_str()); 995 1002 return false; 996 1003 } 997 1004 … … 1015 1022 playerBuf[cnt2] = inf->readUint32LE(); 1016 1023 1017 1024 if (inf->ioFailed()) { 1018 displayMessage(0, "Can't read from file '%s'. (%s)", f Name, _saveFileMan->popErrorDesc().c_str());1025 displayMessage(0, "Can't read from file '%s'. (%s)", filename.c_str(), _saveFileMan->popErrorDesc().c_str()); 1019 1026 delete inf; 1020 1027 free(_restoreBuf); 1021 1028 _restoreBuf = NULL; -
sword1.h
80 80 void reinitialize(void); 81 81 82 82 uint32 _features; 83 84 Common::String getTargetName() const { return _targetName; } 83 85 protected: 84 86 int go(); 85 87 int init();