NEVERHOOD: More work on saveload, saving works, loading not yet (from the GMM, in-game isn't finished yet)
This commit is contained in:
parent
c182688e44
commit
99e15e4005
5 changed files with 52 additions and 40 deletions
|
@ -126,12 +126,10 @@ public:
|
||||||
virtual bool hasFeature(MetaEngineFeature f) const;
|
virtual bool hasFeature(MetaEngineFeature f) const;
|
||||||
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) 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;
|
SaveStateList listSaves(const char *target) const;
|
||||||
virtual int getMaximumSaveSlot() const;
|
virtual int getMaximumSaveSlot() const;
|
||||||
void removeSaveState(const char *target, int slot) const;
|
void removeSaveState(const char *target, int slot) const;
|
||||||
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
|
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
|
||||||
#endif
|
|
||||||
|
|
||||||
const ADGameDescription *fallbackDetect(const Common::FSList &fslist) const;
|
const ADGameDescription *fallbackDetect(const Common::FSList &fslist) const;
|
||||||
|
|
||||||
|
@ -139,20 +137,20 @@ public:
|
||||||
|
|
||||||
bool NeverhoodMetaEngine::hasFeature(MetaEngineFeature f) const {
|
bool NeverhoodMetaEngine::hasFeature(MetaEngineFeature f) const {
|
||||||
return
|
return
|
||||||
false; // Nothing yet :(
|
(f == kSupportsListSaves) ||
|
||||||
// (f == kSupportsListSaves) ||
|
(f == kSupportsLoadingDuringStartup) ||
|
||||||
// (f == kSupportsLoadingDuringStartup) ||
|
|
||||||
// (f == kSupportsDeleteSave) ||
|
// (f == kSupportsDeleteSave) ||
|
||||||
// (f == kSavesSupportMetaInfo) ||
|
(f == kSavesSupportMetaInfo) ||
|
||||||
// (f == kSavesSupportThumbnail);
|
(f == kSavesSupportThumbnail) ||
|
||||||
|
(f == kSavesSupportCreationDate) ||
|
||||||
|
(f == kSavesSupportPlayTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Neverhood::NeverhoodEngine::hasFeature(EngineFeature f) const {
|
bool Neverhood::NeverhoodEngine::hasFeature(EngineFeature f) const {
|
||||||
return
|
return
|
||||||
false; // Nothing yet :(
|
|
||||||
// (f == kSupportsRTL) || // TODO: Not yet...
|
// (f == kSupportsRTL) || // TODO: Not yet...
|
||||||
// (f == kSupportsLoadingDuringRuntime) ||
|
(f == kSupportsLoadingDuringRuntime) ||
|
||||||
// (f == kSupportsSavingDuringRuntime);
|
(f == kSupportsSavingDuringRuntime);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NeverhoodMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
|
bool NeverhoodMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
|
||||||
|
@ -177,8 +175,6 @@ const ADGameDescription *NeverhoodMetaEngine::fallbackDetect(const Common::FSLis
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 // Not used yet but let's keep it for later when it is
|
|
||||||
|
|
||||||
SaveStateList NeverhoodMetaEngine::listSaves(const char *target) const {
|
SaveStateList NeverhoodMetaEngine::listSaves(const char *target) const {
|
||||||
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
|
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
|
||||||
Neverhood::NeverhoodEngine::SaveHeader header;
|
Neverhood::NeverhoodEngine::SaveHeader header;
|
||||||
|
@ -213,9 +209,6 @@ int NeverhoodMetaEngine::getMaximumSaveSlot() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NeverhoodMetaEngine::removeSaveState(const char *target, int slot) 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::SaveFileManager *saveFileMan = g_system->getSavefileManager();
|
||||||
Common::String filename = Neverhood::NeverhoodEngine::getSavegameFilename(target, slot);
|
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,
|
// Rename every slot greater than the deleted slot,
|
||||||
// Also do not rename quicksaves.
|
// Also do not rename quicksaves.
|
||||||
if (slotNum > slot && slotNum < 990) {
|
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());
|
saveFileMan->renameSavefile(file->c_str(), filename.c_str());
|
||||||
|
|
||||||
filename = Neverhood::NeverhoodEngine::getSavegameFilename(target, ++slot);
|
filename = Neverhood::NeverhoodEngine::getSavegameFilename(target, ++slot);
|
||||||
|
@ -265,7 +253,14 @@ SaveStateDescriptor NeverhoodMetaEngine::querySaveMetaInfos(const char *target,
|
||||||
desc.setDeletableFlag(false);
|
desc.setDeletableFlag(false);
|
||||||
desc.setWriteProtectedFlag(false);
|
desc.setWriteProtectedFlag(false);
|
||||||
desc.setThumbnail(header.thumbnail);
|
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;
|
return desc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -273,8 +268,6 @@ SaveStateDescriptor NeverhoodMetaEngine::querySaveMetaInfos(const char *target,
|
||||||
return SaveStateDescriptor();
|
return SaveStateDescriptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if PLUGIN_ENABLED_DYNAMIC(NEVERHOOD)
|
#if PLUGIN_ENABLED_DYNAMIC(NEVERHOOD)
|
||||||
REGISTER_PLUGIN_DYNAMIC(NEVERHOOD, PLUGIN_TYPE_ENGINE, NeverhoodMetaEngine);
|
REGISTER_PLUGIN_DYNAMIC(NEVERHOOD, PLUGIN_TYPE_ENGINE, NeverhoodMetaEngine);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -31,6 +31,30 @@ GameVars::GameVars() {
|
||||||
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) {
|
uint32 GameVars::getGlobalVar(uint32 nameHash) {
|
||||||
int16 varIndex = findSubVarIndex(0, nameHash);
|
int16 varIndex = findSubVarIndex(0, nameHash);
|
||||||
return varIndex != -1 ? _vars[varIndex].value : 0;
|
return varIndex != -1 ? _vars[varIndex].value : 0;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#define NEVERHOOD_GAMEVARS_H
|
#define NEVERHOOD_GAMEVARS_H
|
||||||
|
|
||||||
#include "common/array.h"
|
#include "common/array.h"
|
||||||
|
#include "common/savefile.h"
|
||||||
#include "neverhood/neverhood.h"
|
#include "neverhood/neverhood.h"
|
||||||
|
|
||||||
namespace Neverhood {
|
namespace Neverhood {
|
||||||
|
@ -170,8 +171,8 @@ class GameVars {
|
||||||
public:
|
public:
|
||||||
GameVars();
|
GameVars();
|
||||||
~GameVars();
|
~GameVars();
|
||||||
// TODO void load(???);
|
void loadState(Common::InSaveFile *in);
|
||||||
// TODO void save(???);
|
void saveState(Common::OutSaveFile *out);
|
||||||
uint32 getGlobalVar(uint32 nameHash);
|
uint32 getGlobalVar(uint32 nameHash);
|
||||||
void setGlobalVar(uint32 nameHash, uint32 value);
|
void setGlobalVar(uint32 nameHash, uint32 value);
|
||||||
uint32 getSubVar(uint32 nameHash, uint32 subNameHash);
|
uint32 getSubVar(uint32 nameHash, uint32 subNameHash);
|
||||||
|
|
|
@ -86,13 +86,6 @@ Common::Error NeverhoodEngine::run() {
|
||||||
|
|
||||||
CursorMan.showMouse(true);
|
CursorMan.showMouse(true);
|
||||||
|
|
||||||
#if 0
|
|
||||||
// TODO: This should probably be implemented as debug command later
|
|
||||||
dumpAllResources();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
|
|
||||||
_soundMan = new SoundMan(this);
|
_soundMan = new SoundMan(this);
|
||||||
_audioResourceMan = new AudioResourceMan(this);
|
_audioResourceMan = new AudioResourceMan(this);
|
||||||
|
|
||||||
|
@ -101,6 +94,9 @@ Common::Error NeverhoodEngine::run() {
|
||||||
|
|
||||||
_gameModule->startup();
|
_gameModule->startup();
|
||||||
|
|
||||||
|
// TODO Check if this can actually be false...
|
||||||
|
_isSaveAllowed = true;
|
||||||
|
|
||||||
uint32 nextFrameTime = 0;
|
uint32 nextFrameTime = 0;
|
||||||
|
|
||||||
// Preliminary main loop, needs some more work but works for testing
|
// Preliminary main loop, needs some more work but works for testing
|
||||||
|
@ -145,25 +141,19 @@ Common::Error NeverhoodEngine::run() {
|
||||||
_gameModule->draw();
|
_gameModule->draw();
|
||||||
_screen->update();
|
_screen->update();
|
||||||
nextFrameTime = _screen->getNextFrameTime();
|
nextFrameTime = _screen->getNextFrameTime();
|
||||||
//_gameVars->dumpVars();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
_soundMan->update();
|
_soundMan->update();
|
||||||
_audioResourceMan->update();
|
_audioResourceMan->update();
|
||||||
//_screen->update();
|
|
||||||
_system->updateScreen();
|
_system->updateScreen();
|
||||||
_system->delayMillis(10);
|
_system->delayMillis(10);
|
||||||
|
|
||||||
debug(0, "---------------------------------------");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete _gameModule;
|
delete _gameModule;
|
||||||
delete _collisionMan;
|
delete _collisionMan;
|
||||||
delete _soundMan;
|
delete _soundMan;
|
||||||
delete _audioResourceMan;
|
delete _audioResourceMan;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
delete _res;
|
delete _res;
|
||||||
delete _screen;
|
delete _screen;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "graphics/thumbnail.h"
|
#include "graphics/thumbnail.h"
|
||||||
|
|
||||||
#include "neverhood/neverhood.h"
|
#include "neverhood/neverhood.h"
|
||||||
|
#include "neverhood/gamevars.h"
|
||||||
|
|
||||||
namespace Neverhood {
|
namespace Neverhood {
|
||||||
|
|
||||||
|
@ -90,7 +91,10 @@ void NeverhoodEngine::savegame(const char *filename, const char *description) {
|
||||||
out->writeUint32LE(playTime);
|
out->writeUint32LE(playTime);
|
||||||
// Header end
|
// Header end
|
||||||
|
|
||||||
// TODO
|
_gameVars->setGlobalVar(0x108A4870, _gameState.sceneNum);
|
||||||
|
_gameVars->setGlobalVar(0x82C80875, _gameState.which);
|
||||||
|
|
||||||
|
_gameVars->saveState(out);
|
||||||
|
|
||||||
out->finalize();
|
out->finalize();
|
||||||
delete out;
|
delete out;
|
||||||
|
@ -115,7 +119,7 @@ void NeverhoodEngine::loadgame(const char *filename) {
|
||||||
|
|
||||||
g_engine->setTotalPlayTime(header.playTime * 1000);
|
g_engine->setTotalPlayTime(header.playTime * 1000);
|
||||||
|
|
||||||
// TODO
|
_gameVars->loadState(in);
|
||||||
|
|
||||||
delete in;
|
delete in;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue