[Scummvm-git-logs] scummvm master -> 4b93ebedf1a9f3258e38b60b2a233cb764eb0b7a

sev- sev at scummvm.org
Tue Sep 20 19:34:59 CEST 2016


This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
0aef5c55d4 FULLPIPE: Fix inventory not being cleared on game load
dde4076f72 FULLPIPE: Read ScummVM savegame header from end of the file
ca1eb70fd8 FULLPIPE: Read playtime and save date from save headers
ac7eb25ef0 FULLPIPE: Move more stuff to stateloader.cpp
cf4452388c FULLPIPE: Save ScummVM-specific header with the saves
4b93ebedf1 FULLPIPE: Correctly fill out dummy header on reading failure


Commit: 0aef5c55d4fbb27b7cb7ed3dda001c9ede205cf5
    https://github.com/scummvm/scummvm/commit/0aef5c55d4fbb27b7cb7ed3dda001c9ede205cf5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-09-20T19:34:48+02:00

Commit Message:
FULLPIPE: Fix inventory not being cleared on game load

Changed paths:
    engines/fullpipe/inventory.cpp



diff --git a/engines/fullpipe/inventory.cpp b/engines/fullpipe/inventory.cpp
index 8424e7e..345a02c 100644
--- a/engines/fullpipe/inventory.cpp
+++ b/engines/fullpipe/inventory.cpp
@@ -94,6 +94,11 @@ Inventory2::~Inventory2() {
 }
 
 bool Inventory2::loadPartial(MfcArchive &file) { // Inventory2_SerializePartially
+	for (uint i = 0; i < _inventoryItems.size(); i++)
+		delete _inventoryItems[i];
+
+	_inventoryItems.clear();
+
 	int numInvs = file.readUint32LE();
 
 	for (int i = 0; i < numInvs; i++) {


Commit: dde4076f725e30a1264b3f0935df7c6fdf7cf774
    https://github.com/scummvm/scummvm/commit/dde4076f725e30a1264b3f0935df7c6fdf7cf774
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-09-20T19:34:48+02:00

Commit Message:
FULLPIPE: Read ScummVM savegame header from end of the file

This will let us maintain backward compatibility with original saves

Changed paths:
    engines/fullpipe/gameloader.cpp



diff --git a/engines/fullpipe/gameloader.cpp b/engines/fullpipe/gameloader.cpp
index d1f2781..64c744f 100644
--- a/engines/fullpipe/gameloader.cpp
+++ b/engines/fullpipe/gameloader.cpp
@@ -700,6 +700,13 @@ bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header)
 	char saveIdentBuffer[6];
 	header.thumbnail = NULL;
 
+	uint oldPos = in->pos();
+
+	in->seek(4, SEEK_END);
+	uint headerOffset = in->readUint32LE();
+
+	in->seek(headerOffset, SEEK_SET);
+
 	// Validate the header Id
 	in->read(saveIdentBuffer, 6);
 	if (strcmp(saveIdentBuffer, "SVMCR"))
@@ -717,6 +724,9 @@ bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header)
 
 	// Get the thumbnail
 	header.thumbnail = Graphics::loadThumbnail(*in);
+
+	in->seek(oldPos, SEEK_SET); // Rewind the file
+
 	if (!header.thumbnail)
 		return false;
 


Commit: ca1eb70fd8760411c0be2eb48449765c15768cb6
    https://github.com/scummvm/scummvm/commit/ca1eb70fd8760411c0be2eb48449765c15768cb6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-09-20T19:34:48+02:00

Commit Message:
FULLPIPE: Read playtime and save date from save headers

Changed paths:
    engines/fullpipe/gameloader.cpp
    engines/fullpipe/gameloader.h
    engines/fullpipe/modal.cpp



diff --git a/engines/fullpipe/gameloader.cpp b/engines/fullpipe/gameloader.cpp
index 64c744f..d7e40f9 100644
--- a/engines/fullpipe/gameloader.cpp
+++ b/engines/fullpipe/gameloader.cpp
@@ -696,6 +696,17 @@ const char *getSavegameFile(int saveGameIdx) {
 	return buffer;
 }
 
+void parseSavegameHeader(Fullpipe::FullpipeSavegameHeader &header, SaveStateDescriptor &desc) {
+	int day = (header.date >> 24) & 0xFF;
+	int month = (header.date >> 16) & 0xFF;
+	int year = header.date & 0xFFFF;
+	desc.setSaveDate(year, month, day);
+	int hour = (header.time >> 8) & 0xFF;
+	int minutes = header.time & 0xFF;
+	desc.setSaveTime(hour, minutes);
+	desc.setPlayTime(header.playtime * 1000);
+}
+
 bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header) {
 	char saveIdentBuffer[6];
 	header.thumbnail = NULL;
@@ -709,8 +720,13 @@ bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header)
 
 	// Validate the header Id
 	in->read(saveIdentBuffer, 6);
-	if (strcmp(saveIdentBuffer, "SVMCR"))
+	if (strcmp(saveIdentBuffer, "SVMCR")) {
+		// This is wrong header, perhaps it is original savegame. Thus fill out dummy values
+		header.date = (16 >> 24) | (9 >> 20) | 2016;
+		header.time = (9 >> 8) | 56;
+		header.playtime = 1000;
 		return false;
+	}
 
 	header.version = in->readByte();
 	if (header.version != FULLPIPE_SAVEGAME_VERSION)
diff --git a/engines/fullpipe/gameloader.h b/engines/fullpipe/gameloader.h
index d984020..5687e6b 100644
--- a/engines/fullpipe/gameloader.h
+++ b/engines/fullpipe/gameloader.h
@@ -23,6 +23,8 @@
 #ifndef FULLPIPE_GAMELOADER_H
 #define FULLPIPE_GAMELOADER_H
 
+#include "engines/savestate.h"
+
 #include "fullpipe/objects.h"
 #include "fullpipe/inventory.h"
 #include "fullpipe/messages.h"
@@ -77,6 +79,9 @@ class PreloadItems : public Common::Array<PreloadItem *>, public CObject {
 struct FullpipeSavegameHeader {
 	uint8 version;
 	Common::String saveName;
+	uint32 date;
+	uint16 time;
+	uint32 playtime;
 	Graphics::Surface *thumbnail;
 };
 
@@ -134,6 +139,7 @@ class GameLoader : public CObject {
 
 const char *getSavegameFile(int saveGameIdx);
 bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header);
+void parseSavegameHeader(Fullpipe::FullpipeSavegameHeader &header, SaveStateDescriptor &desc);
 
 Inventory2 *getGameLoaderInventory();
 InteractionController *getGameLoaderInteractionController();
diff --git a/engines/fullpipe/modal.cpp b/engines/fullpipe/modal.cpp
index cceec4a..468d421 100644
--- a/engines/fullpipe/modal.cpp
+++ b/engines/fullpipe/modal.cpp
@@ -1640,9 +1640,7 @@ bool ModalSaveGame::getFileInfo(int slot, FileInfo *fileinfo) {
 	SaveStateDescriptor desc(slot, header.saveName);
 	char res[17];
 
-	// FIXME. HACK. TODO: Set proper dates
-	desc.setSaveDate(2016, 9, 18);
-	desc.setSaveTime(9, 56);
+	Fullpipe::parseSavegameHeader(header, desc);
 
 	snprintf(res, 17, "%s %s", desc.getSaveDate().c_str(), desc.getSaveTime().c_str());
 


Commit: ac7eb25ef08de284a1ea06ae4179a40153f4415e
    https://github.com/scummvm/scummvm/commit/ac7eb25ef08de284a1ea06ae4179a40153f4415e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-09-20T19:34:48+02:00

Commit Message:
FULLPIPE: Move more stuff to stateloader.cpp

Changed paths:
    engines/fullpipe/gameloader.cpp
    engines/fullpipe/stateloader.cpp



diff --git a/engines/fullpipe/gameloader.cpp b/engines/fullpipe/gameloader.cpp
index d7e40f9..57bde97 100644
--- a/engines/fullpipe/gameloader.cpp
+++ b/engines/fullpipe/gameloader.cpp
@@ -21,7 +21,6 @@
  */
 
 #include "fullpipe/fullpipe.h"
-#include "graphics/thumbnail.h"
 
 #include "fullpipe/gameloader.h"
 #include "fullpipe/scene.h"
@@ -696,59 +695,6 @@ const char *getSavegameFile(int saveGameIdx) {
 	return buffer;
 }
 
-void parseSavegameHeader(Fullpipe::FullpipeSavegameHeader &header, SaveStateDescriptor &desc) {
-	int day = (header.date >> 24) & 0xFF;
-	int month = (header.date >> 16) & 0xFF;
-	int year = header.date & 0xFFFF;
-	desc.setSaveDate(year, month, day);
-	int hour = (header.time >> 8) & 0xFF;
-	int minutes = header.time & 0xFF;
-	desc.setSaveTime(hour, minutes);
-	desc.setPlayTime(header.playtime * 1000);
-}
-
-bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header) {
-	char saveIdentBuffer[6];
-	header.thumbnail = NULL;
-
-	uint oldPos = in->pos();
-
-	in->seek(4, SEEK_END);
-	uint headerOffset = in->readUint32LE();
-
-	in->seek(headerOffset, SEEK_SET);
-
-	// Validate the header Id
-	in->read(saveIdentBuffer, 6);
-	if (strcmp(saveIdentBuffer, "SVMCR")) {
-		// This is wrong header, perhaps it is original savegame. Thus fill out dummy values
-		header.date = (16 >> 24) | (9 >> 20) | 2016;
-		header.time = (9 >> 8) | 56;
-		header.playtime = 1000;
-		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);
-
-	in->seek(oldPos, SEEK_SET); // Rewind the file
-
-	if (!header.thumbnail)
-		return false;
-
-	return true;
-}
-
 void GameLoader::restoreDefPicAniInfos() {
 	for (uint i = 0; i < _sc2array.size(); i++) {
 		if (_sc2array[i]._picAniInfos) {
diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp
index d5d374f..9cca85c 100644
--- a/engines/fullpipe/stateloader.cpp
+++ b/engines/fullpipe/stateloader.cpp
@@ -27,6 +27,8 @@
 #include "common/list.h"
 #include "common/memstream.h"
 
+#include "graphics/thumbnail.h"
+
 #include "fullpipe/objects.h"
 #include "fullpipe/gameloader.h"
 #include "fullpipe/scene.h"
@@ -158,6 +160,59 @@ void GameLoader::readSavegame(const char *fname) {
 	}
 }
 
+void parseSavegameHeader(Fullpipe::FullpipeSavegameHeader &header, SaveStateDescriptor &desc) {
+	int day = (header.date >> 24) & 0xFF;
+	int month = (header.date >> 16) & 0xFF;
+	int year = header.date & 0xFFFF;
+	desc.setSaveDate(year, month, day);
+	int hour = (header.time >> 8) & 0xFF;
+	int minutes = header.time & 0xFF;
+	desc.setSaveTime(hour, minutes);
+	desc.setPlayTime(header.playtime * 1000);
+}
+
+bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header) {
+	char saveIdentBuffer[6];
+	header.thumbnail = NULL;
+
+	uint oldPos = in->pos();
+
+	in->seek(4, SEEK_END);
+	uint headerOffset = in->readUint32LE();
+
+	in->seek(headerOffset, SEEK_SET);
+
+	// Validate the header Id
+	in->read(saveIdentBuffer, 6);
+	if (strcmp(saveIdentBuffer, "SVMCR")) {
+		// This is wrong header, perhaps it is original savegame. Thus fill out dummy values
+		header.date = (16 >> 24) | (9 >> 20) | 2016;
+		header.time = (9 >> 8) | 56;
+		header.playtime = 1000;
+		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);
+
+	in->seek(oldPos, SEEK_SET); // Rewind the file
+
+	if (!header.thumbnail)
+		return false;
+
+	return true;
+}
+
 void GameLoader::addVar(GameVar *var, GameVar *subvar) {
 	if (var && subvar) {
 		int type = var->_varType;


Commit: cf4452388cc4104072801b2a0c74bdef03d419d5
    https://github.com/scummvm/scummvm/commit/cf4452388cc4104072801b2a0c74bdef03d419d5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-09-20T19:34:48+02:00

Commit Message:
FULLPIPE: Save ScummVM-specific header with the saves

Changed paths:
    engines/fullpipe/gameloader.h
    engines/fullpipe/stateloader.cpp
    engines/fullpipe/statesaver.cpp



diff --git a/engines/fullpipe/gameloader.h b/engines/fullpipe/gameloader.h
index 5687e6b..9f99cb1 100644
--- a/engines/fullpipe/gameloader.h
+++ b/engines/fullpipe/gameloader.h
@@ -77,6 +77,7 @@ class PreloadItems : public Common::Array<PreloadItem *>, public CObject {
 };
 
 struct FullpipeSavegameHeader {
+	char id[6];
 	uint8 version;
 	Common::String saveName;
 	uint32 date;
diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp
index 9cca85c..a122331 100644
--- a/engines/fullpipe/stateloader.cpp
+++ b/engines/fullpipe/stateloader.cpp
@@ -169,22 +169,34 @@ void parseSavegameHeader(Fullpipe::FullpipeSavegameHeader &header, SaveStateDesc
 	int minutes = header.time & 0xFF;
 	desc.setSaveTime(hour, minutes);
 	desc.setPlayTime(header.playtime * 1000);
+
+	desc.setDescription(header.saveName);
 }
 
 bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header) {
-	char saveIdentBuffer[6];
 	header.thumbnail = NULL;
 
 	uint oldPos = in->pos();
 
-	in->seek(4, SEEK_END);
+	// SEEK_END doesn't work with zipped savegames, so simulate it
+	while (!in->eos())
+		in->readByte();
+
+	in->seek(-4, SEEK_CUR);
 	uint headerOffset = in->readUint32LE();
 
+	// Sanity check
+	if (headerOffset >= in->pos() || headerOffset == 0) {
+		in->seek(oldPos, SEEK_SET); // Rewind the file
+		return false;
+	}
+
 	in->seek(headerOffset, SEEK_SET);
 
+	in->read(header.id, 6);
+
 	// Validate the header Id
-	in->read(saveIdentBuffer, 6);
-	if (strcmp(saveIdentBuffer, "SVMCR")) {
+	if (strcmp(header.id, "SVMCR")) {
 		// This is wrong header, perhaps it is original savegame. Thus fill out dummy values
 		header.date = (16 >> 24) | (9 >> 20) | 2016;
 		header.time = (9 >> 8) | 56;
@@ -196,11 +208,15 @@ bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header)
 	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;
+	header.date = in->readUint32LE();
+	header.time = in->readUint16LE();
+	header.playtime = in->readUint32LE();
+
+	// Generate savename
+	SaveStateDescriptor desc;
+
+	parseSavegameHeader(header, desc);
+	header.saveName = Common::String::format("%s %s", desc.getSaveDate().c_str(), desc.getSaveTime().c_str());
 
 	// Get the thumbnail
 	header.thumbnail = Graphics::loadThumbnail(*in);
diff --git a/engines/fullpipe/statesaver.cpp b/engines/fullpipe/statesaver.cpp
index eaf0352..eb5de08 100644
--- a/engines/fullpipe/statesaver.cpp
+++ b/engines/fullpipe/statesaver.cpp
@@ -22,6 +22,8 @@
 
 #include "common/memstream.h"
 
+#include "graphics/thumbnail.h"
+
 #include "fullpipe/fullpipe.h"
 
 #include "fullpipe/gameloader.h"
@@ -114,6 +116,30 @@ void GameLoader::writeSavegame(Scene *sc, const char *fname) {
 
 	saveFile->write(stream.getData(), stream.size());
 
+	uint headerPos = saveFile->pos();
+	FullpipeSavegameHeader header2;
+
+	strcpy(header2.id, "SVMCR");
+	header2.version = FULLPIPE_SAVEGAME_VERSION;
+
+	TimeDate curTime;
+	g_system->getTimeAndDate(curTime);
+
+	header2.date = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
+	header2.time = ((curTime.tm_hour & 0xFF) << 8) | ((curTime.tm_min) & 0xFF);
+
+	header2.playtime = g_fp->getTotalPlayTime() / 1000;
+
+	saveFile->write(header2.id, 6);
+	saveFile->writeByte(header2.version);
+	saveFile->writeUint32LE(header2.date);
+	saveFile->writeUint16LE(header2.time);
+	saveFile->writeUint32LE(header2.playtime);
+
+	Graphics::saveThumbnail(*saveFile); // FIXME. Render proper screen
+
+	saveFile->writeUint32LE(headerPos);	// Store where the header starts
+
 	saveFile->finalize();
 
 	delete saveFile;


Commit: 4b93ebedf1a9f3258e38b60b2a233cb764eb0b7a
    https://github.com/scummvm/scummvm/commit/4b93ebedf1a9f3258e38b60b2a233cb764eb0b7a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-09-20T19:34:48+02:00

Commit Message:
FULLPIPE: Correctly fill out dummy header on reading failure

Changed paths:
    engines/fullpipe/stateloader.cpp



diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp
index a122331..4df9763 100644
--- a/engines/fullpipe/stateloader.cpp
+++ b/engines/fullpipe/stateloader.cpp
@@ -173,6 +173,13 @@ void parseSavegameHeader(Fullpipe::FullpipeSavegameHeader &header, SaveStateDesc
 	desc.setDescription(header.saveName);
 }
 
+void fillDummyHeader(Fullpipe::FullpipeSavegameHeader &header) {
+	// This is wrong header, perhaps it is original savegame. Thus fill out dummy values
+	header.date = (20 << 24) | (9 << 16) | 2016;
+	header.time = (9 << 8) | 56;
+	header.playtime = 1000;
+}
+
 bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header) {
 	header.thumbnail = NULL;
 
@@ -188,6 +195,7 @@ bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header)
 	// Sanity check
 	if (headerOffset >= in->pos() || headerOffset == 0) {
 		in->seek(oldPos, SEEK_SET); // Rewind the file
+		fillDummyHeader(header);
 		return false;
 	}
 
@@ -197,16 +205,17 @@ bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header)
 
 	// Validate the header Id
 	if (strcmp(header.id, "SVMCR")) {
-		// This is wrong header, perhaps it is original savegame. Thus fill out dummy values
-		header.date = (16 >> 24) | (9 >> 20) | 2016;
-		header.time = (9 >> 8) | 56;
-		header.playtime = 1000;
+		in->seek(oldPos, SEEK_SET); // Rewind the file
+		fillDummyHeader(header);
 		return false;
 	}
 
 	header.version = in->readByte();
-	if (header.version != FULLPIPE_SAVEGAME_VERSION)
+	if (header.version != FULLPIPE_SAVEGAME_VERSION) {
+		in->seek(oldPos, SEEK_SET); // Rewind the file
+		fillDummyHeader(header);
 		return false;
+	}
 
 	header.date = in->readUint32LE();
 	header.time = in->readUint16LE();





More information about the Scummvm-git-logs mailing list