TUCKER: Changing autosave to work with common Engine code
This commit is contained in:
parent
958cb05295
commit
6c187dbb30
3 changed files with 12 additions and 37 deletions
|
@ -93,7 +93,7 @@ TuckerEngine::SavegameError TuckerEngine::saveOrLoadGameStateData(S &s) {
|
|||
}
|
||||
|
||||
Common::Error TuckerEngine::loadGameState(int slot) {
|
||||
Common::String fileName = generateGameStateFileName(_targetName.c_str(), slot);
|
||||
Common::String fileName = getSaveStateName(slot);
|
||||
Common::InSaveFile *file = _saveFileMan->openForLoading(fileName);
|
||||
|
||||
if (!file) {
|
||||
|
@ -235,11 +235,7 @@ TuckerEngine::SavegameError TuckerEngine::writeSavegameHeader(Common::OutSaveFil
|
|||
}
|
||||
|
||||
Common::Error TuckerEngine::saveGameState(int slot, const Common::String &description, bool isAutosave) {
|
||||
return writeSavegame(slot, description, false);
|
||||
}
|
||||
|
||||
Common::Error TuckerEngine::writeSavegame(int slot, const Common::String &description, bool autosave) {
|
||||
Common::String fileName = generateGameStateFileName(_targetName.c_str(), slot);
|
||||
Common::String fileName = getSaveStateName(slot);
|
||||
Common::OutSaveFile *file = _saveFileMan->openForSaving(fileName);
|
||||
SavegameHeader header;
|
||||
SavegameError savegameError = kSavegameNoError;
|
||||
|
@ -249,7 +245,7 @@ Common::Error TuckerEngine::writeSavegame(int slot, const Common::String &descri
|
|||
|
||||
if (!savegameError) {
|
||||
// savegame flags
|
||||
if (autosave)
|
||||
if (isAutosave)
|
||||
header.flags |= kSavegameFlagAutosave;
|
||||
|
||||
// description
|
||||
|
@ -274,7 +270,7 @@ Common::Error TuckerEngine::writeSavegame(int slot, const Common::String &descri
|
|||
return Common::kNoError;
|
||||
}
|
||||
|
||||
bool TuckerEngine::isAutosaveAllowed() {
|
||||
bool TuckerEngine::canSaveAutosaveCurrently() {
|
||||
return isAutosaveAllowed(_targetName.c_str());
|
||||
}
|
||||
|
||||
|
@ -284,24 +280,6 @@ bool TuckerEngine::isAutosaveAllowed(const char *target) {
|
|||
return (savegameError == kSavegameNotFoundError || (savegameHeader.flags & kSavegameFlagAutosave));
|
||||
}
|
||||
|
||||
void TuckerEngine::writeAutosave() {
|
||||
if (canSaveGameStateCurrently()) {
|
||||
// unconditionally reset last autosave timestamp so we don't start
|
||||
// hammering the disk in case we can't/don't actually write the file
|
||||
_lastSaveTime = _system->getMillis();
|
||||
|
||||
if (!isAutosaveAllowed()) {
|
||||
warning("Refusing to overwrite non-autosave savegame in slot %i, skipping autosave", kAutoSaveSlot);
|
||||
return;
|
||||
}
|
||||
|
||||
if (writeSavegame(kAutoSaveSlot, "Autosave", true).getCode() != Common::kNoError) {
|
||||
warning("Can't create autosave in slot %i, game not saved", kAutoSaveSlot);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TuckerEngine::canLoadOrSave() const {
|
||||
return !_player && _cursorState != kCursorStateDisabledHidden;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue