XEEN: Remove autosave code

This commit is contained in:
Paul Gilbert 2020-02-05 22:39:46 -08:00 committed by Paul Gilbert
parent 6c187dbb30
commit 6a3aac1478
6 changed files with 13 additions and 33 deletions

View File

@ -32,7 +32,7 @@
namespace Xeen {
EventsManager::EventsManager(XeenEngine *vm) : _vm(vm), _playTime(0), _gameCounter(0),
_frameCounter(0), _priorFrameCounterTime(0), _priorScreenRefreshTime(0), _lastAutosaveTime(0),
_frameCounter(0), _priorFrameCounterTime(0), _priorScreenRefreshTime(0),
_mousePressed(false), _sprites("mouse.icn") {
Common::fill(&_gameCounters[0], &_gameCounters[6], 0);
}
@ -76,11 +76,6 @@ void EventsManager::pollEvents() {
nextFrame();
}
// Handle auto saves
if (!_lastAutosaveTime)
_lastAutosaveTime = timer;
g_vm->autoSaveCheck(_lastAutosaveTime);
// Event handling
Common::Event event;
while (g_system->getEventManager()->pollEvent(event)) {

View File

@ -63,7 +63,6 @@ private:
uint32 _frameCounter;
uint32 _priorFrameCounterTime;
uint32 _priorScreenRefreshTime;
int _lastAutosaveTime;
uint32 _gameCounter;
uint32 _gameCounters[6];
uint32 _playTime;

View File

@ -116,8 +116,7 @@ void SavesManager::writeSavegameHeader(Common::OutSaveFile *out, XeenSavegameHea
}
Common::Error SavesManager::saveGameState(int slot, const Common::String &desc, bool isAutosave) {
Common::OutSaveFile *out = g_system->getSavefileManager()->openForSaving(
generateSaveName(slot));
Common::OutSaveFile *out = g_system->getSavefileManager()->openForSaving(g_vm->getSaveStateName(slot));
if (!out)
return Common::kCreatingFileFailed;
@ -159,7 +158,7 @@ Common::Error SavesManager::loadGameState(int slot) {
Party &party = *g_vm->_party;
Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(
generateSaveName(slot));
g_vm->getSaveStateName(slot));
if (!saveFile)
return Common::kReadingFailed;
@ -208,10 +207,6 @@ Common::Error SavesManager::loadGameState(int slot) {
return Common::kNoError;
}
Common::String SavesManager::generateSaveName(int slot) {
return Common::String::format("%s.%03d", _targetName.c_str(), slot);
}
void SavesManager::newGame() {
delete File::_xeenSave;
delete File::_darkSave;

View File

@ -49,12 +49,6 @@ class SavesManager {
private:
Common::String _targetName;
private:
/**
* Support method that generates a savegame name
* @param slot Slot number
*/
Common::String generateSaveName(int slot);
/**
* Initializes a new savegame
*/

View File

@ -202,6 +202,11 @@ bool XeenEngine::canSaveGameStateCurrently() {
&& (_map->mazeData()._mazeFlags & RESTRICTION_SAVE) == 0;
}
bool XeenEngine::canSaveAutosaveCurrently() {
return canSaveGameStateCurrently() &&
(_map && !(_map->mazeData()._mazeFlags & RESTRICTION_SAVE));
}
void XeenEngine::playGame() {
_files->setGameCc(0);
_sound->stopAllAudio();
@ -327,12 +332,4 @@ void XeenEngine::GUIError(const Common::String &msg) {
GUIErrorMessage(msg);
}
void XeenEngine::autoSaveCheck(int &lastSaveTime) {
if (shouldPerformAutoSave(lastSaveTime) && canSaveGameStateCurrently() &&
(_map && !(_map->mazeData()._mazeFlags & RESTRICTION_SAVE))) {
_saves->doAutosave();
lastSaveTime = g_system->getMillis();
}
}
} // End of namespace Xeen

View File

@ -281,6 +281,11 @@ public:
*/
bool canSaveGameStateCurrently() override;
/**
* Returns true if an autosave can be created
*/
virtual bool canSaveAutosaveCurrently() override;
/**
* Show a cutscene
* @param name Name of cutscene
@ -309,11 +314,6 @@ public:
* Show an error message in a GUI dialog
*/
void GUIError(const Common::String &msg);
/**
* Checks if an auto save should be done, and if so, takes care of it
*/
void autoSaveCheck(int &lastSaveTime);
};
extern XeenEngine *g_vm;