aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2008-03-28 00:53:54 +0000
committerJohannes Schickel2008-03-28 00:53:54 +0000
commitb033c5f605559854e92bda06ffd54ec132a3c22c (patch)
treec6def4e073b4f54d926b10a66f7ce904836fe066
parenta1ec44cef2284a285a17f22136ffd285a26af42f (diff)
downloadscummvm-rg350-b033c5f605559854e92bda06ffd54ec132a3c22c.tar.gz
scummvm-rg350-b033c5f605559854e92bda06ffd54ec132a3c22c.tar.bz2
scummvm-rg350-b033c5f605559854e92bda06ffd54ec132a3c22c.zip
Implemented savegame loading via command line params -x/--save-slot.
svn-id: r31281
-rw-r--r--engines/kyra/kyra.cpp8
-rw-r--r--engines/kyra/kyra.h4
-rw-r--r--engines/kyra/kyra_v1.cpp37
-rw-r--r--engines/kyra/kyra_v1.h1
-rw-r--r--engines/kyra/kyra_v2.cpp34
-rw-r--r--engines/kyra/saveload.cpp19
6 files changed, 72 insertions, 31 deletions
diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp
index b1af49a5ae..8a377c231d 100644
--- a/engines/kyra/kyra.cpp
+++ b/engines/kyra/kyra.cpp
@@ -59,6 +59,8 @@ KyraEngine::KyraEngine(OSystem *system, const GameFlags &flags)
_lastMusicCommand = -1;
_curSfxFile = _curMusicTheme = -1;
+ _gameToLoad = -1;
+
memset(_flagsTable, 0, sizeof(_flagsTable));
// sets up all engine specific debug levels
@@ -143,6 +145,12 @@ int KyraEngine::init() {
setupOpcodeTable();
readSettings();
+ if (ConfMan.hasKey("save_slot")) {
+ _gameToLoad = ConfMan.getInt("save_slot");
+ if (!saveFileLoadable(_gameToLoad))
+ _gameToLoad = -1;
+ }
+
_lang = 0;
Common::Language lang = Common::parseLanguage(ConfMan.get("language"));
diff --git a/engines/kyra/kyra.h b/engines/kyra/kyra.h
index fc37b2fb94..0e8b91a55d 100644
--- a/engines/kyra/kyra.h
+++ b/engines/kyra/kyra.h
@@ -228,7 +228,10 @@ protected:
static const int8 _addYPosTable[];
// save/load
+ int _gameToLoad;
+
const char *getSavegameFilename(int num);
+ bool saveFileLoadable(int slot);
struct SaveHeader {
Common::String description;
@@ -246,6 +249,7 @@ protected:
kRSHEInvalidVersion = 2,
kRSHEIoError = 3
};
+
static kReadSaveHeaderError readSaveHeader(Common::InSaveFile *file, SaveHeader &header);
Common::InSaveFile *openSaveForReading(const char *filename, SaveHeader &header);
diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp
index fa5c84c610..08fdd117cc 100644
--- a/engines/kyra/kyra_v1.cpp
+++ b/engines/kyra/kyra_v1.cpp
@@ -318,12 +318,14 @@ int KyraEngine_v1::go() {
} else {
setGameFlag(0xF3);
setGameFlag(0xFD);
- setGameFlag(0xEF);
- seq_intro();
- if (_quitFlag)
- return 0;
- if (_skipIntroFlag && _abortIntroFlag)
- resetGameFlag(0xEF);
+ if (_gameToLoad == -1) {
+ setGameFlag(0xEF);
+ seq_intro();
+ if (_quitFlag)
+ return 0;
+ if (_skipIntroFlag && _abortIntroFlag)
+ resetGameFlag(0xEF);
+ }
startup();
resetGameFlag(0xEF);
mainLoop();
@@ -398,16 +400,21 @@ void KyraEngine_v1::startup() {
error("Could not load \"_NPC.EMC\" script");
snd_playTheme(1);
- enterNewScene(_currentCharacter->sceneId, _currentCharacter->facing, 0, 0, 1);
+ if (_gameToLoad == -1) {
+ enterNewScene(_currentCharacter->sceneId, _currentCharacter->facing, 0, 0, 1);
- if (_abortIntroFlag && _skipIntroFlag) {
- _menuDirectlyToLoad = true;
- _screen->setMouseCursor(1, 1, _shapes[0]);
- _screen->showMouse();
- buttonMenuCallback(0);
- _menuDirectlyToLoad = false;
- } else
- saveGame(getSavegameFilename(0), "New game");
+ if (_abortIntroFlag && _skipIntroFlag) {
+ _menuDirectlyToLoad = true;
+ _screen->setMouseCursor(1, 1, _shapes[0]);
+ _screen->showMouse();
+ buttonMenuCallback(0);
+ _menuDirectlyToLoad = false;
+ } else
+ saveGame(getSavegameFilename(0), "New game");
+ } else {
+ loadGame(getSavegameFilename(_gameToLoad));
+ _gameToLoad = -1;
+ }
}
void KyraEngine_v1::mainLoop() {
diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h
index ee31fb97ff..b78539ee59 100644
--- a/engines/kyra/kyra_v1.h
+++ b/engines/kyra/kyra_v1.h
@@ -621,7 +621,6 @@ protected:
bool _cancelSubMenu;
uint8 _toplevelMenu;
int _savegameOffset;
- int _gameToLoad;
char _savegameName[31];
const char *_specialSavegameString;
Common::KeyState _keyPressed;
diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp
index 89c9c2a863..0d183d2c09 100644
--- a/engines/kyra/kyra_v2.cpp
+++ b/engines/kyra/kyra_v2.cpp
@@ -234,14 +234,18 @@ int KyraEngine_v2::init() {
}
int KyraEngine_v2::go() {
- if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)
- seq_showStarcraftLogo();
+ if (_gameToLoad == -1) {
+ if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98)
+ seq_showStarcraftLogo();
- if (_flags.isDemo && !_flags.isTalkie) {
- seq_playSequences(kSequenceDemoVirgin, kSequenceDemoFisher);
- _menuChoice = 4;
+ if (_flags.isDemo && !_flags.isTalkie) {
+ seq_playSequences(kSequenceDemoVirgin, kSequenceDemoFisher);
+ _menuChoice = 4;
+ } else {
+ seq_playSequences(kSequenceVirgin, kSequenceZanfaun);
+ }
} else {
- seq_playSequences(kSequenceVirgin, kSequenceZanfaun);
+ _menuChoice = 1;
}
_res->unloadAllPakFiles();
@@ -361,9 +365,11 @@ void KyraEngine_v2::startup() {
clearAnimObjects();
- // XXX
+ for (int i = 0; i < 19; ++i)
+ memset(_conversationState[i], -1, sizeof(int8)*14);
clearCauldronTable();
- // XXX
+ memset(_inputColorCode, -1, sizeof(_inputColorCode));
+ memset(_newSceneDlgState, 0, sizeof(_newSceneDlgState));
memset(_hiddenItems, -1, sizeof(_hiddenItems));
for (int i = 0; i < 23; ++i)
resetCauldronStateTable(i);
@@ -374,14 +380,16 @@ void KyraEngine_v2::startup() {
runStartScript(1, 0);
loadNPCScript();
- // XXX
- snd_playWanderScoreViaMap(52, 1);
- // XXX
+ if (_gameToLoad == -1) {
+ snd_playWanderScoreViaMap(52, 1);
+ enterNewScene(_mainCharacter.sceneId, _mainCharacter.facing, 0, 0, 1);
+ saveGame(getSavegameFilename(0), "New Game");
+ } else {
+ loadGame(getSavegameFilename(_gameToLoad));
+ }
- enterNewScene(_mainCharacter.sceneId, _mainCharacter.facing, 0, 0, 1);
_screen->showMouse();
- //sub_20EE8(1);
setNextIdleAnimTimer();
//XXX
_timer->setDelay(0, 5);
diff --git a/engines/kyra/saveload.cpp b/engines/kyra/saveload.cpp
index 9347da4aeb..0635fa02b5 100644
--- a/engines/kyra/saveload.cpp
+++ b/engines/kyra/saveload.cpp
@@ -108,7 +108,7 @@ Common::InSaveFile *KyraEngine::openSaveForReading(const char *filename, SaveHea
Common::InSaveFile *in = 0;
if (!(in = _saveFileMan->openForLoading(filename))) {
- warning("Can't open file '%s', game not loaded", filename);
+ warning("Can't open file '%s', game not loadable", filename);
return 0;
}
@@ -119,7 +119,7 @@ Common::InSaveFile *KyraEngine::openSaveForReading(const char *filename, SaveHea
else if (errorCode == kRSHEInvalidVersion)
warning("Savegame is not the right version (%u, '%s')", header.version, header.oldHeader ? "true" : "false");
else if (errorCode == kRSHEIoError)
- warning("Load failed ('%s').", filename);
+ warning("Load failed '%s'", filename);
delete in;
return 0;
@@ -198,5 +198,20 @@ const char *KyraEngine::getSavegameFilename(int num) {
return filename.c_str();
}
+bool KyraEngine::saveFileLoadable(int slot) {
+ if (slot < 0 || slot > 999)
+ return false;
+
+ SaveHeader header;
+ Common::InSaveFile *in = openSaveForReading(getSavegameFilename(slot), header);
+
+ if (in) {
+ delete in;
+ return true;
+ }
+
+ return false;
+}
+
} // end of namespace Kyra