[Scummvm-cvs-logs] scummvm master -> c7d017e166e3dd486ed443bdaa6591a7655fd15f
sev-
sev at scummvm.org
Thu May 1 11:08:00 CEST 2014
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
39f771a3c5 FULLPIPE: Implement ModalSaveGame::saveload()
c7d017e166 FULLPIPE: Implement ModalSaveGame::getFileInfo() and stubbed saveload support
Commit: 39f771a3c5a2c750fae3c357d3ddec66d63a03dc
https://github.com/scummvm/scummvm/commit/39f771a3c5a2c750fae3c357d3ddec66d63a03dc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2014-05-01T09:44:47+03:00
Commit Message:
FULLPIPE: Implement ModalSaveGame::saveload()
Changed paths:
engines/fullpipe/gameloader.cpp
engines/fullpipe/gameloader.h
engines/fullpipe/modal.cpp
engines/fullpipe/modal.h
engines/fullpipe/utils.h
diff --git a/engines/fullpipe/gameloader.cpp b/engines/fullpipe/gameloader.cpp
index d9f7327..f60b804 100644
--- a/engines/fullpipe/gameloader.cpp
+++ b/engines/fullpipe/gameloader.cpp
@@ -501,6 +501,14 @@ void GameLoader::updateSystems(int counterdiff) {
}
}
+void GameLoader::readSavegame(const char *fname) {
+ warning("STUB: readSavegame(%s)", fname);
+}
+
+void GameLoader::writeSavegame(Scene *sc, const char *fname) {
+ warning("STUB: writeSavegame(sc, %s)", fname);
+}
+
Sc2::Sc2() {
_sceneId = 0;
_field_2 = 0;
diff --git a/engines/fullpipe/gameloader.h b/engines/fullpipe/gameloader.h
index a79c0e1..61a8b7a 100644
--- a/engines/fullpipe/gameloader.h
+++ b/engines/fullpipe/gameloader.h
@@ -89,6 +89,9 @@ class GameLoader : public CObject {
void applyPicAniInfos(Scene *sc, PicAniInfo **picAniInfo, int picAniInfoCount);
void saveScenePicAniInfos(int sceneId);
+ void readSavegame(const char *fname);
+ void writeSavegame(Scene *sc, const char *fname);
+
GameProject *_gameProject;
InteractionController *_interactionController;
InputController *_inputController;
diff --git a/engines/fullpipe/modal.cpp b/engines/fullpipe/modal.cpp
index 39b021b..10d841e 100644
--- a/engines/fullpipe/modal.cpp
+++ b/engines/fullpipe/modal.cpp
@@ -1460,6 +1460,8 @@ ModalSaveGame::ModalSaveGame() {
_rect = g_fp->_sceneRect;
_queryDlg = 0;
_mode = 1;
+
+ _objtype = kObjTypeModalSaveGame;
}
ModalSaveGame::~ModalSaveGame() {
@@ -1718,6 +1720,38 @@ void ModalSaveGame::processMouse(int x, int y) {
_queryRes = 0;
}
+void ModalSaveGame::saveload() {
+ if (_objtype != kObjTypeModalSaveGame)
+ return;
+
+ if (_mode) {
+ if (getSaveName()) {
+ bool allowed = true;
+
+ for (Common::Array<MessageQueue *>::iterator s = g_fp->_globalMessageQueueList->begin(); s != g_fp->_globalMessageQueueList->end(); ++s) {
+ if (!(*s)->_isFinished && ((*s)->getFlags() & 1))
+ allowed = false;
+ }
+
+ if (g_fp->_isSaveAllowed && allowed)
+ g_fp->_gameLoader->writeSavegame(g_fp->_currentScene, getSaveName());
+ }
+ } else {
+ if (getSaveName()) {
+ if (_parentObj) {
+ delete _parentObj;
+
+ _parentObj = 0;
+ }
+
+ g_fp->stopAllSoundStreams();
+ g_fp->stopSoundStream2();
+
+ g_fp->_gameLoader->readSavegame(getSaveName());
+ }
+ }
+}
+
void FullpipeEngine::openHelp() {
if (!_modalObject) {
ModalHelp *help = new ModalHelp;
diff --git a/engines/fullpipe/modal.h b/engines/fullpipe/modal.h
index 2c2295f..0d73ddb 100644
--- a/engines/fullpipe/modal.h
+++ b/engines/fullpipe/modal.h
@@ -46,9 +46,10 @@ class BaseModalObject {
public:
BaseModalObject *_parentObj;
+ ObjType _objtype;
public:
- BaseModalObject() : _parentObj(0) {}
+ BaseModalObject() : _parentObj(0) { _objtype = kObjTypeDefault; }
virtual ~BaseModalObject() {}
@@ -259,7 +260,7 @@ public:
virtual bool handleMessage(ExCommand *message);
virtual bool init(int counterdiff);
virtual void update();
- virtual void saveload() {}
+ virtual void saveload();
void processMouse(int x, int y);
diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h
index 72e746c..3e3ec0b 100644
--- a/engines/fullpipe/utils.h
+++ b/engines/fullpipe/utils.h
@@ -68,6 +68,7 @@ enum ObjType {
kObjTypeDefault,
kObjTypeExCommand,
kObjTypeExCommand2,
+ kObjTypeModalSaveGame,
kObjTypeMovGraph,
kObjTypeMovGraphLink,
kObjTypeMovGraphNode,
Commit: c7d017e166e3dd486ed443bdaa6591a7655fd15f
https://github.com/scummvm/scummvm/commit/c7d017e166e3dd486ed443bdaa6591a7655fd15f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2014-05-01T12:06:40+03:00
Commit Message:
FULLPIPE: Implement ModalSaveGame::getFileInfo() and stubbed saveload support
Changed paths:
engines/fullpipe/detection.cpp
engines/fullpipe/fullpipe.h
engines/fullpipe/gameloader.cpp
engines/fullpipe/gameloader.h
engines/fullpipe/modal.cpp
engines/fullpipe/modal.h
diff --git a/engines/fullpipe/detection.cpp b/engines/fullpipe/detection.cpp
index 62c5dd3..de0ed04 100644
--- a/engines/fullpipe/detection.cpp
+++ b/engines/fullpipe/detection.cpp
@@ -26,6 +26,7 @@
#include "common/file.h"
#include "fullpipe/fullpipe.h"
+#include "fullpipe/gameloader.h"
namespace Fullpipe {
@@ -87,15 +88,72 @@ public:
}
virtual bool hasFeature(MetaEngineFeature f) const;
+ virtual int getMaximumSaveSlot() const { return 8; }
+ virtual SaveStateList listSaves(const char *target) const;
+ virtual void removeSaveState(const char *target, int slot) const;
+ virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const;
};
bool FullpipeMetaEngine::hasFeature(MetaEngineFeature f) const {
- return false;
+ return
+ (f == kSupportsListSaves) ||
+ (f == kSupportsDeleteSave) ||
+ (f == kSavesSupportMetaInfo) ||
+ (f == kSavesSupportThumbnail) ||
+ (f == kSavesSupportCreationDate) ||
+ (f == kSupportsLoadingDuringStartup);
}
-bool Fullpipe::FullpipeEngine::hasFeature(EngineFeature f) const {
- return false;
+SaveStateList FullpipeMetaEngine::listSaves(const char *target) const {
+ Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+ Common::StringArray filenames;
+ Common::String pattern("fullpipe.s??");
+
+ filenames = saveFileMan->listSavefiles(pattern);
+ sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
+
+ SaveStateList saveList;
+ for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+ // Obtain the last 2 digits of the filename, since they correspond to the save slot
+ int slotNum = atoi(file->c_str() + file->size() - 2);
+
+ if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) {
+ Common::InSaveFile *in = saveFileMan->openForLoading(*file);
+ if (in) {
+ Fullpipe::FullpipeSavegameHeader header;
+ Fullpipe::readSavegameHeader(in, header);
+ saveList.push_back(SaveStateDescriptor(slotNum, header.saveName));
+ delete header.thumbnail;
+ delete in;
+ }
+ }
+ }
+
+ return saveList;
+}
+
+void FullpipeMetaEngine::removeSaveState(const char *target, int slot) const {
+ g_system->getSavefileManager()->removeSavefile(Fullpipe::getSavegameFile(slot));
+}
+
+SaveStateDescriptor FullpipeMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
+ Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(
+ Fullpipe::getSavegameFile(slot));
+
+ if (f) {
+ Fullpipe::FullpipeSavegameHeader header;
+ Fullpipe::readSavegameHeader(f, header);
+ delete f;
+
+ // Create the return descriptor
+ SaveStateDescriptor desc(slot, header.saveName);
+ desc.setThumbnail(header.thumbnail);
+
+ return desc;
+ }
+
+ return SaveStateDescriptor();
}
bool FullpipeMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
diff --git a/engines/fullpipe/fullpipe.h b/engines/fullpipe/fullpipe.h
index 2750525..afdc493 100644
--- a/engines/fullpipe/fullpipe.h
+++ b/engines/fullpipe/fullpipe.h
@@ -99,7 +99,6 @@ public:
const ADGameDescription *_gameDescription;
const char *getGameId() const;
Common::Platform getPlatform() const;
- bool hasFeature(EngineFeature f) const;
Common::RandomSource *_rnd;
diff --git a/engines/fullpipe/gameloader.cpp b/engines/fullpipe/gameloader.cpp
index f60b804..5c528c4 100644
--- a/engines/fullpipe/gameloader.cpp
+++ b/engines/fullpipe/gameloader.cpp
@@ -21,6 +21,7 @@
*/
#include "fullpipe/fullpipe.h"
+#include "graphics/thumbnail.h"
#include "fullpipe/gameloader.h"
#include "fullpipe/scene.h"
@@ -601,6 +602,38 @@ bool PreloadItems::load(MfcArchive &file) {
return true;
}
+const char *getSavegameFile(int saveGameIdx) {
+ static char buffer[20];
+ sprintf(buffer, "fullpipe.s%02d", saveGameIdx);
+ return buffer;
+}
+
+bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header) {
+ char saveIdentBuffer[6];
+ header.thumbnail = NULL;
+
+ // Validate the header Id
+ in->read(saveIdentBuffer, 6);
+ if (strcmp(saveIdentBuffer, "SVMCR"))
+ return false;
+
+ header.version = in->readByte();
+ if (header.version != FULLPIPE_SAVEGAME_VERSION)
+ return false;
+
+ // Read in the string
+ header.saveName.clear();
+ char ch;
+ while ((ch = (char)in->readByte()) != '\0') header.saveName += ch;
+
+ // Get the thumbnail
+ header.thumbnail = Graphics::loadThumbnail(*in);
+ if (!header.thumbnail)
+ return false;
+
+ return true;
+}
+
GameVar *FullpipeEngine::getGameLoaderGameVar() {
if (_gameLoader)
return _gameLoader->_gameVar;
diff --git a/engines/fullpipe/gameloader.h b/engines/fullpipe/gameloader.h
index 61a8b7a..0796396 100644
--- a/engines/fullpipe/gameloader.h
+++ b/engines/fullpipe/gameloader.h
@@ -29,6 +29,8 @@
namespace Fullpipe {
+#define FULLPIPE_SAVEGAME_VERSION 1
+
class SceneTag;
class MctlCompound;
class InputController;
@@ -72,6 +74,12 @@ class PreloadItems : public Common::Array<PreloadItem *>, public CObject {
virtual bool load(MfcArchive &file);
};
+struct FullpipeSavegameHeader {
+ uint8 version;
+ Common::String saveName;
+ Graphics::Surface *thumbnail;
+};
+
class GameLoader : public CObject {
public:
GameLoader();
@@ -111,6 +119,9 @@ class GameLoader : public CObject {
int _preloadEntranceId;
};
+const char *getSavegameFile(int saveGameIdx);
+bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header);
+
Inventory2 *getGameLoaderInventory();
InteractionController *getGameLoaderInteractionController();
MctlCompound *getSc2MctlCompoundBySceneId(int16 sceneId);
diff --git a/engines/fullpipe/modal.cpp b/engines/fullpipe/modal.cpp
index 10d841e..ca082e6 100644
--- a/engines/fullpipe/modal.cpp
+++ b/engines/fullpipe/modal.cpp
@@ -34,6 +34,8 @@
#include "graphics/palette.h"
#include "video/avi_decoder.h"
+#include "engines/savestate.h"
+
namespace Fullpipe {
ModalIntro::ModalIntro() {
@@ -1593,9 +1595,9 @@ void ModalSaveGame::setup(Scene *sc, int mode) {
fileinfo = new FileInfo;
memset(fileinfo, 0, sizeof(FileInfo));
- snprintf(fileinfo->filename, 160, "save%02d.sav", i);
+ strncpy(fileinfo->filename, getSavegameFile(i), 160);
- if (!getFileInfo(fileinfo->filename, fileinfo)) {
+ if (!getFileInfo(i, fileinfo)) {
fileinfo->empty = true;
w = _emptyD->getDimensions(&point)->x;
} else {
@@ -1625,10 +1627,52 @@ char *ModalSaveGame::getSaveName() {
return _files[_queryRes]->filename;
}
-bool ModalSaveGame::getFileInfo(char *filename, FileInfo *fileinfo) {
- warning("STUB: ModalSaveGame::getFileInfo()");
+bool ModalSaveGame::getFileInfo(int slot, FileInfo *fileinfo) {
+ Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(
+ Fullpipe::getSavegameFile(slot));
- return false;
+ if (!f)
+ return false;
+
+ Fullpipe::FullpipeSavegameHeader header;
+ Fullpipe::readSavegameHeader(f, header);
+ delete f;
+
+ // Create the return descriptor
+ SaveStateDescriptor desc(slot, header.saveName);
+ char res[17];
+
+ snprintf(res, 17, "%s %s", desc.getSaveDate().c_str(), desc.getSaveTime().c_str());
+
+ for (int i = 0; i < 16; i++) {
+ switch(res[i]) {
+ case '.':
+ fileinfo->date[i] = 11;
+ break;
+ case ' ':
+ fileinfo->date[i] = 12;
+ break;
+ case ':':
+ fileinfo->date[i] = 10;
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ fileinfo->date[i] = res[i] - '0';
+ break;
+ default:
+ error("Incorrect date format: %s", res);
+ }
+ }
+
+ return true;
}
void ModalSaveGame::update() {
@@ -1659,10 +1703,10 @@ void ModalSaveGame::update() {
int x = _files[i]->fx1;
for (int j = 0; j < 16; j++) {
- _arrayL[j + _files[i]->day]->setOXY(x + 1, _files[i]->fy1);
- _arrayL[j + _files[i]->day]->draw();
+ _arrayL[_files[i]->date[j]]->setOXY(x + 1, _files[i]->fy1);
+ _arrayL[_files[i]->date[j]]->draw();
- x += _arrayL[j + _files[i]->day]->getDimensions(&point)->x + 2;
+ x += _arrayL[_files[i]->date[j]]->getDimensions(&point)->x + 2;
}
}
} else {
@@ -1673,10 +1717,10 @@ void ModalSaveGame::update() {
int x = _files[i]->fx1;
for (int j = 0; j < 16; j++) {
- _arrayD[j + _files[i]->day]->setOXY(x + 1, _files[i]->fy1);
- _arrayD[j + _files[i]->day]->draw();
+ _arrayD[_files[i]->date[j]]->setOXY(x + 1, _files[i]->fy1);
+ _arrayD[_files[i]->date[j]]->draw();
- x += _arrayD[j + _files[i]->day]->getDimensions(&point)->x + 2;
+ x += _arrayD[_files[i]->date[j]]->getDimensions(&point)->x + 2;
}
}
}
diff --git a/engines/fullpipe/modal.h b/engines/fullpipe/modal.h
index 0d73ddb..01d8e6b 100644
--- a/engines/fullpipe/modal.h
+++ b/engines/fullpipe/modal.h
@@ -32,10 +32,7 @@ class Sound;
struct FileInfo {
char filename[260];
bool empty;
- int day;
- int month;
- int year;
- int time;
+ char date[16];
int fx1;
int fx2;
int fy1;
@@ -269,7 +266,7 @@ public:
void processKey(int key);
char *getSaveName();
- bool getFileInfo(char *filename, FileInfo *fileinfo);
+ bool getFileInfo(int slot, FileInfo *fileinfo);
Common::Rect _rect;
int _oldBgX;
More information about the Scummvm-git-logs
mailing list