Fixes for Sword1 engine loading from launcher
svn-id: r33915
This commit is contained in:
parent
7e49b2e8a1
commit
603f0a2f8c
3 changed files with 15 additions and 5 deletions
|
@ -703,7 +703,7 @@ void Control::handleSaveKey(Common::KeyState kbd) {
|
||||||
bool Control::saveToFile(void) {
|
bool Control::saveToFile(void) {
|
||||||
if ((_selectedSavegame == 255) || !strlen((char*)_saveNames[_selectedSavegame]))
|
if ((_selectedSavegame == 255) || !strlen((char*)_saveNames[_selectedSavegame]))
|
||||||
return false; // no saveslot selected or no name entered
|
return false; // no saveslot selected or no name entered
|
||||||
saveGameToFile(_selectedSavegame);
|
saveGameToFile(_numSaves);
|
||||||
writeSavegameDescriptions();
|
writeSavegameDescriptions();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -741,6 +741,7 @@ void Control::readSavegameDescriptions(void) {
|
||||||
curFileNum++;
|
curFileNum++;
|
||||||
} while ((ch != 255) && (!inf->eos()));
|
} while ((ch != 255) && (!inf->eos()));
|
||||||
_saveFiles = curFileNum;
|
_saveFiles = curFileNum;
|
||||||
|
_numSaves = _saveFiles;
|
||||||
}
|
}
|
||||||
delete inf;
|
delete inf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,7 @@ private:
|
||||||
void deselectSaveslots(void);
|
void deselectSaveslots(void);
|
||||||
uint8 *_restoreBuf;
|
uint8 *_restoreBuf;
|
||||||
uint8 _saveFiles;
|
uint8 _saveFiles;
|
||||||
|
uint8 _numSaves;
|
||||||
uint8 _saveScrollPos;
|
uint8 _saveScrollPos;
|
||||||
uint8 _selectedSavegame;
|
uint8 _selectedSavegame;
|
||||||
uint8 _saveNames[64][32];
|
uint8 _saveNames[64][32];
|
||||||
|
|
|
@ -199,12 +199,20 @@ PluginError SwordMetaEngine::createInstance(OSystem *syst, Engine **engine) cons
|
||||||
SaveStateList SwordMetaEngine::listSaves(const char *target) const {
|
SaveStateList SwordMetaEngine::listSaves(const char *target) const {
|
||||||
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
|
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
|
||||||
SaveStateList saveList;
|
SaveStateList saveList;
|
||||||
|
|
||||||
|
Common::String pattern = "SAVEGAME.???";
|
||||||
|
Common::StringList filenames = saveFileMan->listSavefiles(pattern.c_str());
|
||||||
|
sort(filenames.begin(), filenames.end());
|
||||||
|
Common::StringList::const_iterator file = filenames.begin();
|
||||||
|
|
||||||
Common::InSaveFile *in = saveFileMan->openForLoading("SAVEGAME.INF");
|
Common::InSaveFile *in = saveFileMan->openForLoading("SAVEGAME.INF");
|
||||||
if (in) {
|
if (in) {
|
||||||
uint8 stop;
|
uint8 stop;
|
||||||
char saveDesc[32];
|
char saveDesc[32];
|
||||||
int slotNum = 0;
|
|
||||||
do {
|
do {
|
||||||
|
// Obtain the last digit of the filename, since they correspond to the save slot
|
||||||
|
int slotNum = atoi(file->c_str() + file->size() - 1);
|
||||||
|
|
||||||
uint pos = 0;
|
uint pos = 0;
|
||||||
do {
|
do {
|
||||||
stop = in->readByte();
|
stop = in->readByte();
|
||||||
|
@ -218,8 +226,8 @@ SaveStateList SwordMetaEngine::listSaves(const char *target) const {
|
||||||
}
|
}
|
||||||
} while ((stop != 10) && (stop != 255) && (!in->eos()));
|
} while ((stop != 10) && (stop != 255) && (!in->eos()));
|
||||||
if (saveDesc[0] != 0) {
|
if (saveDesc[0] != 0) {
|
||||||
saveList.push_back(SaveStateDescriptor(slotNum, saveDesc, "SAVEGAME.INF"));
|
saveList.push_back(SaveStateDescriptor(slotNum, saveDesc, *file));
|
||||||
slotNum++;
|
file++;
|
||||||
}
|
}
|
||||||
} while ((stop != 255) && (!in->eos()));
|
} while ((stop != 255) && (!in->eos()));
|
||||||
}
|
}
|
||||||
|
@ -688,7 +696,7 @@ int SwordEngine::go() {
|
||||||
int saveSlot = ConfMan.getInt("save_slot");
|
int saveSlot = ConfMan.getInt("save_slot");
|
||||||
// Savegames are numbered starting from 1 in the dialog window,
|
// Savegames are numbered starting from 1 in the dialog window,
|
||||||
// but their filenames are numbered starting from 0.
|
// but their filenames are numbered starting from 0.
|
||||||
if (saveSlot > 0 && _control->restoreGameFromFile(saveSlot - 1)) {
|
if (saveSlot >= 0 && _control->savegamesExist() &&_control->restoreGameFromFile(saveSlot)) {
|
||||||
_control->doRestore();
|
_control->doRestore();
|
||||||
} else if (_control->savegamesExist()) {
|
} else if (_control->savegamesExist()) {
|
||||||
_systemVars.controlPanelMode = CP_NEWGAME;
|
_systemVars.controlPanelMode = CP_NEWGAME;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue