aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjohndoe1232012-11-22 00:33:38 +0000
committerWillem Jan Palenstijn2013-05-08 20:47:38 +0200
commit99e15e400537d85ff9f68cc10973b6d2c36c1776 (patch)
treec952cf20e881481758b9c20dc63d6d2e979861ab
parentc182688e44a385549ca0734196a8a920a13ed8b6 (diff)
downloadscummvm-rg350-99e15e400537d85ff9f68cc10973b6d2c36c1776.tar.gz
scummvm-rg350-99e15e400537d85ff9f68cc10973b6d2c36c1776.tar.bz2
scummvm-rg350-99e15e400537d85ff9f68cc10973b6d2c36c1776.zip
NEVERHOOD: More work on saveload, saving works, loading not yet (from the GMM, in-game isn't finished yet)
-rw-r--r--engines/neverhood/detection.cpp39
-rw-r--r--engines/neverhood/gamevars.cpp24
-rw-r--r--engines/neverhood/gamevars.h5
-rw-r--r--engines/neverhood/neverhood.cpp16
-rw-r--r--engines/neverhood/saveload.cpp8
5 files changed, 52 insertions, 40 deletions
diff --git a/engines/neverhood/detection.cpp b/engines/neverhood/detection.cpp
index df9eca3d7f..ed7053ac34 100644
--- a/engines/neverhood/detection.cpp
+++ b/engines/neverhood/detection.cpp
@@ -126,12 +126,10 @@ public:
virtual bool hasFeature(MetaEngineFeature f) const;
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
-#if 0 // Not used yet but let's keep it for later when it is
SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
void removeSaveState(const char *target, int slot) const;
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
-#endif
const ADGameDescription *fallbackDetect(const Common::FSList &fslist) const;
@@ -139,20 +137,20 @@ public:
bool NeverhoodMetaEngine::hasFeature(MetaEngineFeature f) const {
return
- false; // Nothing yet :(
-// (f == kSupportsListSaves) ||
-// (f == kSupportsLoadingDuringStartup) ||
+ (f == kSupportsListSaves) ||
+ (f == kSupportsLoadingDuringStartup) ||
// (f == kSupportsDeleteSave) ||
-// (f == kSavesSupportMetaInfo) ||
-// (f == kSavesSupportThumbnail);
+ (f == kSavesSupportMetaInfo) ||
+ (f == kSavesSupportThumbnail) ||
+ (f == kSavesSupportCreationDate) ||
+ (f == kSavesSupportPlayTime);
}
bool Neverhood::NeverhoodEngine::hasFeature(EngineFeature f) const {
return
- false; // Nothing yet :(
// (f == kSupportsRTL) || // TODO: Not yet...
-// (f == kSupportsLoadingDuringRuntime) ||
-// (f == kSupportsSavingDuringRuntime);
+ (f == kSupportsLoadingDuringRuntime) ||
+ (f == kSupportsSavingDuringRuntime);
}
bool NeverhoodMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
@@ -177,8 +175,6 @@ const ADGameDescription *NeverhoodMetaEngine::fallbackDetect(const Common::FSLis
return NULL;
}
-#if 0 // Not used yet but let's keep it for later when it is
-
SaveStateList NeverhoodMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Neverhood::NeverhoodEngine::SaveHeader header;
@@ -213,9 +209,6 @@ int NeverhoodMetaEngine::getMaximumSaveSlot() const {
}
void NeverhoodMetaEngine::removeSaveState(const char *target, int slot) const {
- // Slot 0 can't be deleted, it's for restarting the game(s)
- if (slot == 0)
- return;
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::String filename = Neverhood::NeverhoodEngine::getSavegameFilename(target, slot);
@@ -235,11 +228,6 @@ void NeverhoodMetaEngine::removeSaveState(const char *target, int slot) const {
// Rename every slot greater than the deleted slot,
// Also do not rename quicksaves.
if (slotNum > slot && slotNum < 990) {
- // FIXME: Our savefile renaming done here is inconsitent with what we do in
- // GUI_v2::deleteMenu. While here we rename every slot with a greater equal
- // number of the deleted slot to deleted slot, deleted slot + 1 etc.,
- // we only rename the following slots in GUI_v2::deleteMenu until a slot
- // is missing.
saveFileMan->renameSavefile(file->c_str(), filename.c_str());
filename = Neverhood::NeverhoodEngine::getSavegameFilename(target, ++slot);
@@ -265,7 +253,14 @@ SaveStateDescriptor NeverhoodMetaEngine::querySaveMetaInfos(const char *target,
desc.setDeletableFlag(false);
desc.setWriteProtectedFlag(false);
desc.setThumbnail(header.thumbnail);
-
+ int day = (header.saveDate >> 24) & 0xFF;
+ int month = (header.saveDate >> 16) & 0xFF;
+ int year = header.saveDate & 0xFFFF;
+ desc.setSaveDate(year, month, day);
+ int hour = (header.saveTime >> 16) & 0xFF;
+ int minutes = (header.saveTime >> 8) & 0xFF;
+ desc.setSaveTime(hour, minutes);
+ desc.setPlayTime(header.playTime * 1000);
return desc;
}
}
@@ -273,8 +268,6 @@ SaveStateDescriptor NeverhoodMetaEngine::querySaveMetaInfos(const char *target,
return SaveStateDescriptor();
}
-#endif
-
#if PLUGIN_ENABLED_DYNAMIC(NEVERHOOD)
REGISTER_PLUGIN_DYNAMIC(NEVERHOOD, PLUGIN_TYPE_ENGINE, NeverhoodMetaEngine);
#else
diff --git a/engines/neverhood/gamevars.cpp b/engines/neverhood/gamevars.cpp
index e56ec1ec7d..558543fa31 100644
--- a/engines/neverhood/gamevars.cpp
+++ b/engines/neverhood/gamevars.cpp
@@ -31,6 +31,30 @@ GameVars::GameVars() {
GameVars::~GameVars() {
}
+void GameVars::loadState(Common::InSaveFile *in) {
+ uint varCount;
+ _vars.clear();
+ varCount = in->readUint32LE();
+ for (uint i = 0; i < varCount; ++i) {
+ GameVar var;
+ var.nameHash = in->readUint32LE();
+ var.value = in->readUint32LE();
+ var.firstIndex = in->readUint16LE();
+ var.nextIndex = in->readUint16LE();
+ }
+}
+
+void GameVars::saveState(Common::OutSaveFile *out) {
+ out->writeUint32LE(_vars.size());
+ for (uint i = 0; i < _vars.size(); ++i) {
+ GameVar &var = _vars[i];
+ out->writeUint32LE(var.nameHash);
+ out->writeUint32LE(var.value);
+ out->writeUint16LE(var.firstIndex);
+ out->writeUint16LE(var.nextIndex);
+ }
+}
+
uint32 GameVars::getGlobalVar(uint32 nameHash) {
int16 varIndex = findSubVarIndex(0, nameHash);
return varIndex != -1 ? _vars[varIndex].value : 0;
diff --git a/engines/neverhood/gamevars.h b/engines/neverhood/gamevars.h
index 623e5b5c6f..36fcebcbb8 100644
--- a/engines/neverhood/gamevars.h
+++ b/engines/neverhood/gamevars.h
@@ -24,6 +24,7 @@
#define NEVERHOOD_GAMEVARS_H
#include "common/array.h"
+#include "common/savefile.h"
#include "neverhood/neverhood.h"
namespace Neverhood {
@@ -170,8 +171,8 @@ class GameVars {
public:
GameVars();
~GameVars();
- // TODO void load(???);
- // TODO void save(???);
+ void loadState(Common::InSaveFile *in);
+ void saveState(Common::OutSaveFile *out);
uint32 getGlobalVar(uint32 nameHash);
void setGlobalVar(uint32 nameHash, uint32 value);
uint32 getSubVar(uint32 nameHash, uint32 subNameHash);
diff --git a/engines/neverhood/neverhood.cpp b/engines/neverhood/neverhood.cpp
index c29cc7baf5..fbb8df319b 100644
--- a/engines/neverhood/neverhood.cpp
+++ b/engines/neverhood/neverhood.cpp
@@ -86,13 +86,6 @@ Common::Error NeverhoodEngine::run() {
CursorMan.showMouse(true);
-#if 0
- // TODO: This should probably be implemented as debug command later
- dumpAllResources();
-#endif
-
-#if 1
-
_soundMan = new SoundMan(this);
_audioResourceMan = new AudioResourceMan(this);
@@ -101,6 +94,9 @@ Common::Error NeverhoodEngine::run() {
_gameModule->startup();
+ // TODO Check if this can actually be false...
+ _isSaveAllowed = true;
+
uint32 nextFrameTime = 0;
// Preliminary main loop, needs some more work but works for testing
@@ -145,25 +141,19 @@ Common::Error NeverhoodEngine::run() {
_gameModule->draw();
_screen->update();
nextFrameTime = _screen->getNextFrameTime();
- //_gameVars->dumpVars();
};
_soundMan->update();
_audioResourceMan->update();
- //_screen->update();
_system->updateScreen();
_system->delayMillis(10);
- debug(0, "---------------------------------------");
-
}
delete _gameModule;
delete _collisionMan;
delete _soundMan;
delete _audioResourceMan;
-#endif
-
delete _res;
delete _screen;
diff --git a/engines/neverhood/saveload.cpp b/engines/neverhood/saveload.cpp
index 96d7fdd9f2..851943d61f 100644
--- a/engines/neverhood/saveload.cpp
+++ b/engines/neverhood/saveload.cpp
@@ -26,6 +26,7 @@
#include "graphics/thumbnail.h"
#include "neverhood/neverhood.h"
+#include "neverhood/gamevars.h"
namespace Neverhood {
@@ -90,7 +91,10 @@ void NeverhoodEngine::savegame(const char *filename, const char *description) {
out->writeUint32LE(playTime);
// Header end
- // TODO
+ _gameVars->setGlobalVar(0x108A4870, _gameState.sceneNum);
+ _gameVars->setGlobalVar(0x82C80875, _gameState.which);
+
+ _gameVars->saveState(out);
out->finalize();
delete out;
@@ -115,7 +119,7 @@ void NeverhoodEngine::loadgame(const char *filename) {
g_engine->setTotalPlayTime(header.playTime * 1000);
- // TODO
+ _gameVars->loadState(in);
delete in;