[Scummvm-cvs-logs] SF.net SVN: scummvm:[53374] scummvm/trunk/engines/sword25
sev at users.sourceforge.net
sev at users.sourceforge.net
Wed Oct 13 01:59:50 CEST 2010
Revision: 53374
http://scummvm.svn.sourceforge.net/scummvm/?rev=53374&view=rev
Author: sev
Date: 2010-10-12 23:59:49 +0000 (Tue, 12 Oct 2010)
Log Message:
-----------
SWORD25: Implemented thumbnail loading for savegame list
Modified Paths:
--------------
scummvm/trunk/engines/sword25/gfx/image/b25sloader.cpp
scummvm/trunk/engines/sword25/package/packagemanager.cpp
Modified: scummvm/trunk/engines/sword25/gfx/image/b25sloader.cpp
===================================================================
--- scummvm/trunk/engines/sword25/gfx/image/b25sloader.cpp 2010-10-12 23:59:23 UTC (rev 53373)
+++ scummvm/trunk/engines/sword25/gfx/image/b25sloader.cpp 2010-10-12 23:59:49 UTC (rev 53374)
@@ -46,30 +46,36 @@
// -----------------------------------------------------------------------------
namespace {
+static Common::String LoadString(Common::ReadStream &In, uint MaxSize = 999) {
+ Common::String Result;
+
+ char ch = (char)In.readByte();
+ while ((ch != '\0') && (ch != ' ')) {
+ Result += ch;
+ if (Result.size() >= MaxSize) break;
+ ch = (char)In.readByte();
+ }
+
+ return Result;
+}
+
uint FindEmbeddedPNG(const byte *FileDataPtr, uint FileSize) {
if (memcmp(FileDataPtr, "BS25SAVEGAME", 12))
return 0;
-#if 0
- // Einen Stringstream mit dem Anfang der Datei intialisieren. 512 Byte sollten hierf\xFCr gen\xFCgen.
- istringstream StringStream(string(FileDataPtr, FileDataPtr + min(static_cast<uint>(512), FileSize)));
+ // Read in the header
+ Common::MemoryReadStream stream(FileDataPtr, FileSize);
// Headerinformationen der Spielstandes einlesen.
- string Marker, VersionID;
- uint CompressedGamedataSize, UncompressedGamedataSize;
- StringStream >> Marker >> VersionID >> CompressedGamedataSize >> UncompressedGamedataSize;
- if (!StringStream.good()) return 0;
+ uint compressedGamedataSize;
+ LoadString(stream);
+ LoadString(stream);
+ Common::String gameSize = LoadString(stream);
+ compressedGamedataSize = atoi(gameSize.c_str());
+ LoadString(stream);
- // Testen, ob wir tats\xE4chlich einen Spielstand haben.
- if (Marker == "BS25SAVEGAME") {
- // Offset zum PNG innerhalb des Spielstandes berechnen und zur\xFCckgeben.
- return static_cast<uint>(StringStream.tellg()) + CompressedGamedataSize + 1;
- }
-#else
- warning("STUB:FindEmbeddedPNG()");
-#endif
-
- return 0;
+ // Return the offset of where the thumbnail starts
+ return static_cast<uint>(stream.pos() + compressedGamedataSize);
}
}
Modified: scummvm/trunk/engines/sword25/package/packagemanager.cpp
===================================================================
--- scummvm/trunk/engines/sword25/package/packagemanager.cpp 2010-10-12 23:59:23 UTC (rev 53373)
+++ scummvm/trunk/engines/sword25/package/packagemanager.cpp 2010-10-12 23:59:49 UTC (rev 53374)
@@ -36,8 +36,11 @@
#include "common/archive.h"
#include "common/config-manager.h"
+#include "common/savefile.h"
#include "common/str-array.h"
+#include "common/system.h"
#include "common/unzip.h"
+#include "sword25/kernel/filesystemutil.h"
#include "sword25/package/packagemanager.h"
namespace Sword25 {
@@ -142,7 +145,29 @@
}
byte *PackageManager::GetFile(const Common::String &fileName, uint *fileSizePtr) {
+ const Common::String B25S_EXTENSION(".b25s");
Common::SeekableReadStream *in;
+
+ if (fileName.hasSuffix(B25S_EXTENSION)) {
+ // Savegame loading logic
+ Common::SaveFileManager *sfm = g_system->getSavefileManager();
+ Common::InSaveFile *file = sfm->openForLoading(
+ FileSystemUtil::GetInstance().GetPathFilename(fileName));
+ if (!file) {
+ BS_LOG_ERRORLN("Could not load savegame \"%s\".", fileName.c_str());
+ return 0;
+ }
+
+ if (*fileSizePtr)
+ *fileSizePtr = file->size();
+
+ byte *buffer = new byte[file->size()];
+ file->read(buffer, file->size());
+
+ delete file;
+ return buffer;
+ }
+
Common::ArchiveMemberPtr fileNode = GetArchiveMember(normalizePath(fileName, _currentDirectory));
if (!fileNode)
return 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list