From 8a835899fb38ae5c79610d972ad858c90902a802 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 2 Jun 2005 22:14:57 +0000 Subject: [PATCH] Implement game load with '-x' comman-line parameter. Fix couple valgrind and compiler warnings. svn-id: r18313 --- saga/interface.cpp | 1 + saga/saga.cpp | 14 ++++++++++++-- saga/saveload.cpp | 2 +- saga/scene.cpp | 6 ++---- saga/sprite.cpp | 6 +++--- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/saga/interface.cpp b/saga/interface.cpp index d19776e5c53..1aeb5ce1f28 100644 --- a/saga/interface.cpp +++ b/saga/interface.cpp @@ -202,6 +202,7 @@ Interface::Interface(SagaEngine *vm) : _vm(vm), _initialized(false) { } _textInputRepeatPhase = 0; + _textInput = false; _initialized = true; } diff --git a/saga/saga.cpp b/saga/saga.cpp index 442645040ae..168625dbd11 100644 --- a/saga/saga.cpp +++ b/saga/saga.cpp @@ -301,9 +301,19 @@ int SagaEngine::go() { _previousTicks = _system->getMillis(); - // Begin Main Engine Loop + if (ConfMan.hasKey("save_slot")) { + // First scene sets up palette + _scene->changeScene(getStartSceneNumber(), 0, kTransitionNoFade); + _events->handleEvents(0); // Process immediate events + + char *fileName; + fileName = calcSaveFileName(ConfMan.getInt("save_slot")); + load(fileName); + _interface->setMode(kPanelMain); + } else { + _scene->startScene(); + } - _scene->startScene(); uint32 currentTicks; while (!_quit) { diff --git a/saga/saveload.cpp b/saga/saveload.cpp index f87bcf74d01..8a3e5befe4d 100644 --- a/saga/saveload.cpp +++ b/saga/saveload.cpp @@ -136,7 +136,7 @@ void SagaEngine::fillSaveList() { while (i < MAX_SAVES) { if (_saveMarks[i]) { name = calcSaveFileName(i); - if (in = _saveFileMan->openForLoading(name)) { + if ((in = _saveFileMan->openForLoading(name)) != NULL) { in->read(&header, sizeof(header)); if (header.type != MKID('SAGA')) { diff --git a/saga/scene.cpp b/saga/scene.cpp index dab5d998ae3..20f02a958ad 100644 --- a/saga/scene.cpp +++ b/saga/scene.cpp @@ -869,10 +869,8 @@ void Scene::draw() { } void Scene::endScene() { - - if (!_sceneLoaded) { - error("Scene::endScene(): No scene to end"); - } + if (!_sceneLoaded) + return; debug(0, "Ending scene..."); diff --git a/saga/sprite.cpp b/saga/sprite.cpp index 96f0d1c4552..255da47cca1 100644 --- a/saga/sprite.cpp +++ b/saga/sprite.cpp @@ -402,11 +402,11 @@ void Sprite::decodeRLEBuffer(const byte *inputBuffer, size_t inLength, size_t ou MemoryReadStream readS(inputBuffer, inLength); - while (!readS.eos() && (outPointer < outPointerEnd)) { + while (!readS.eos() && (outPointer < outPointerEnd - 1)) { bg_runcount = readS.readByte(); fg_runcount = readS.readByte(); - for (c = 0; c < bg_runcount; c++) { + for (c = 0; c < bg_runcount && !readS.eos(); c++) { *outPointer = (byte) 0; if (outPointer < outPointerEnd) outPointer++; @@ -414,7 +414,7 @@ void Sprite::decodeRLEBuffer(const byte *inputBuffer, size_t inLength, size_t ou return; } - for (c = 0; c < fg_runcount; c++) { + for (c = 0; c < fg_runcount && !readS.eos(); c++) { *outPointer = readS.readByte(); if (outPointer < outPointerEnd) outPointer++;