Added autosave support in Kyra.

svn-id: r34535
This commit is contained in:
Johannes Schickel 2008-09-14 19:48:40 +00:00
parent da92fb470c
commit 48adf18e21
11 changed files with 36 additions and 5 deletions

3
NEWS
View file

@ -8,6 +8,9 @@ For a more comprehensive changelog for the latest experimental SVN code, see:
New Games:
- Added support for Discworld.
KYRA:
- Added support for Auto-save feature
0.12.0 (2008-08-31)
New Games:
- Added support for The Legend of Kyrandia: Book Two: Hand of Fate.

View file

@ -311,8 +311,6 @@ void GUI::updateSaveList() {
s1 -= '0';
s2 -= '0';
s3 -= '0';
if (s1 == 9 && s2 == 9 && s3 == 9)
continue;
_saveSlots.push_back(s1*100+s2*10+s3);
}

View file

@ -462,8 +462,13 @@ void KyraEngine_HoF::runLoop() {
_drawNoShapeFlag = 0;
_gui->optionsButton(0);
_deathHandler = -1;
if (!_runFlag || !quit())
break;
}
checkAutosave();
if (_system->getMillis() > _nextIdleAnim)
showIdleAnim();

View file

@ -406,6 +406,8 @@ void KyraEngine_LoK::mainLoop() {
int32 frameTime = (int32)_system->getMillis();
_skipFlag = false;
checkAutosave();
if (_currentCharacter->sceneId == 210) {
updateKyragemFading();
if (seq_playEnd() && _deathHandler != 8)

View file

@ -1008,8 +1008,13 @@ void KyraEngine_MR::runLoop() {
_drawNoShapeFlag = 0;
_gui->optionsButton(0);
_deathHandler = -1;
if (quit())
break;
}
checkAutosave();
if (_system->getMillis() >= _nextIdleAnim)
showIdleAnim();

View file

@ -181,6 +181,9 @@ int KyraEngine_v1::init() {
_gameToLoad = -1;
}
// Prevent autosave on game startup
_lastAutosave = _system->getMillis();
return 0;
}

View file

@ -271,6 +271,9 @@ protected:
// save/load
int _gameToLoad;
uint32 _lastAutosave;
void checkAutosave();
const char *getSavegameFilename(int num);
bool saveFileLoadable(int slot);
@ -295,6 +298,8 @@ protected:
static kReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *file, bool loadThumbnail, SaveHeader &header);
virtual void saveGame(const char *fileName, const char *saveName, const Graphics::Surface *thumbnail) = 0;
Common::SeekableReadStream *openSaveForReading(const char *filename, SaveHeader &header);
Common::WriteStream *openSaveForWriting(const char *filename, const char *saveName, const Graphics::Surface *thumbnail) const;
};

View file

@ -147,6 +147,9 @@ private:
void setHandItem(uint16) {}
void removeHandItem() {}
bool lineIsPassable(int, int) { return false; }
// save
void saveGame(const char *fileName, const char *saveName, const Graphics::Surface *thumbnail) {}
};
} // end of namespace Kyra

View file

@ -220,7 +220,7 @@ const char *KyraEngine_v1::getSavegameFilename(int num) {
assert(num >= 0 && num <= 999);
char extension[5];
sprintf(extension, "%.3d", num);
sprintf(extension, "%03d", num);
filename = _targetName + "." + extension;
@ -242,5 +242,12 @@ bool KyraEngine_v1::saveFileLoadable(int slot) {
return false;
}
void KyraEngine_v1::checkAutosave() {
if (shouldPerformAutoSave(_lastAutosave)) {
saveGame(getSavegameFilename(999), "Autosave", 0);
_lastAutosave = _system->getMillis();
}
}
} // end of namespace Kyra

View file

@ -293,7 +293,7 @@ int KyraEngine_MR::o3_updateScore(EMCState *script) {
int KyraEngine_MR::o3_makeSecondChanceSave(EMCState *script) {
debugC(3, kDebugLevelScriptFuncs, "KyraEngine_MR::o3_makeSecondChanceSave(%p) ()", (const void *)script);
saveGame(getSavegameFilename(999), "SECOND CHANCE SAVE GAME", 0);
saveGame(getSavegameFilename(999), "Autosave", 0);
return 0;
}

View file

@ -65,7 +65,7 @@ void KyraEngine_MR::timerRunSceneScript7(int arg) {
void KyraEngine_MR::timerFleaDeath(int arg) {
debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_MR::timerFleaDeath(%d)", arg);
_timer->setCountdown(4, 5400);
saveGame(getSavegameFilename(999), "SECOND CHANCE SAVE GAME", 0);
saveGame(getSavegameFilename(999), "Autosave", 0);
_screen->hideMouse();
_timer->disable(4);
runAnimationScript("FLEADTH1.EMC", 0, 0, 1, 1);