[Scummvm-cvs-logs] SF.net SVN: scummvm:[53754] scummvm/trunk/engines/sword25

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun Oct 24 03:31:30 CEST 2010


Revision: 53754
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53754&view=rev
Author:   fingolfin
Date:     2010-10-24 01:31:30 +0000 (Sun, 24 Oct 2010)

Log Message:
-----------
SWORD25: Merge B25SLoader into PNGLoader

Modified Paths:
--------------
    scummvm/trunk/engines/sword25/gfx/image/imageloader.cpp
    scummvm/trunk/engines/sword25/gfx/image/pngloader.cpp
    scummvm/trunk/engines/sword25/gfx/image/pngloader.h
    scummvm/trunk/engines/sword25/module.mk

Removed Paths:
-------------
    scummvm/trunk/engines/sword25/gfx/image/b25sloader.cpp
    scummvm/trunk/engines/sword25/gfx/image/b25sloader.h

Deleted: scummvm/trunk/engines/sword25/gfx/image/b25sloader.cpp
===================================================================
--- scummvm/trunk/engines/sword25/gfx/image/b25sloader.cpp	2010-10-24 01:30:53 UTC (rev 53753)
+++ scummvm/trunk/engines/sword25/gfx/image/b25sloader.cpp	2010-10-24 01:31:30 UTC (rev 53754)
@@ -1,110 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-/*
- * This code is based on Broken Sword 2.5 engine
- *
- * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
- *
- * Licensed under GNU GPL v2
- *
- */
-
-#include "sword25/gfx/image/b25sloader.h"
-#include "sword25/gfx/image/pngloader.h"
-
-namespace Sword25 {
-
-#define BS_LOG_PREFIX "B25SLOADER"
-
-namespace {
-static Common::String loadString(Common::ReadStream &in, uint maxSize = 999) {
-	Common::String result;
-
-	while (!in.eos() && (result.size() < maxSize)) {
-		char ch = (char)in.readByte();
-		if (ch == '\0')
-			break;
-
-		result += ch;
-	}
-
-	return result;
-}
-
-uint findEmbeddedPNG(const byte *fileDataPtr, uint fileSize) {
-	assert(fileSize >= 100);
-	if (memcmp(fileDataPtr, "BS25SAVEGAME", 12))
-		return 0;
-
-	// Read in the header
-	Common::MemoryReadStream stream(fileDataPtr, fileSize);
-	stream.seek(0, SEEK_SET);
-
-	// Headerinformationen der Spielstandes einlesen.
-	uint compressedGamedataSize;
-	loadString(stream);		// Marker
-	loadString(stream);		// Version
-	loadString(stream);		// Description
-	Common::String gameSize = loadString(stream);
-	compressedGamedataSize = atoi(gameSize.c_str());
-	loadString(stream);
-
-	// Return the offset of where the thumbnail starts
-	return static_cast<uint>(stream.pos() + compressedGamedataSize);
-}
-}
-
-bool B25SLoader::isCorrectImageFormat(const byte *fileDataPtr, uint fileSize) {
-	// PNG innerhalb des Spielstandes finden und den Methodenaufruf zu BS_PNGLoader weiterreichen.
-	uint pngOffset = findEmbeddedPNG(fileDataPtr, fileSize);
-	if (pngOffset > 0) {
-		return PNGLoader::doIsCorrectImageFormat(fileDataPtr + pngOffset, fileSize - pngOffset);
-	}
-
-	return false;
-}
-
-bool B25SLoader::decodeImage(const byte *fileDataPtr, uint fileSize, GraphicEngine::COLOR_FORMATS colorFormat, byte *&uncompressedDataPtr, int &width, int &height, int &pitch) {
-	// PNG innerhalb des Spielstandes finden und den Methodenaufruf zu BS_PNGLoader weiterreichen.
-	uint pngOffset = findEmbeddedPNG(fileDataPtr, fileSize);
-	if (pngOffset > 0) {
-		return PNGLoader::doDecodeImage(fileDataPtr + pngOffset, fileSize - pngOffset, colorFormat, uncompressedDataPtr, width, height, pitch);
-	}
-
-	return false;
-}
-
-bool B25SLoader::imageProperties(const byte *fileDataPtr, uint fileSize, GraphicEngine::COLOR_FORMATS &colorFormat, int &width, int &height) {
-	// PNG innerhalb des Spielstandes finden und den Methodenaufruf zu BS_PNGLoader weiterreichen.
-	uint pngOffset = findEmbeddedPNG(fileDataPtr, fileSize);
-	if (pngOffset > 0) {
-		return PNGLoader::doImageProperties(fileDataPtr + pngOffset, fileSize - pngOffset, colorFormat, width, height);
-	}
-
-	return false;
-}
-
-} // End of namespace Sword25

Deleted: scummvm/trunk/engines/sword25/gfx/image/b25sloader.h
===================================================================
--- scummvm/trunk/engines/sword25/gfx/image/b25sloader.h	2010-10-24 01:30:53 UTC (rev 53753)
+++ scummvm/trunk/engines/sword25/gfx/image/b25sloader.h	2010-10-24 01:31:30 UTC (rev 53754)
@@ -1,54 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-/*
- * This code is based on Broken Sword 2.5 engine
- *
- * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
- *
- * Licensed under GNU GPL v2
- *
- */
-
-#ifndef SWORD25_B25SLOADER_H
-#define SWORD25_B25SLOADER_H
-
-#include "sword25/kernel/common.h"
-#include "sword25/gfx/image/imageloader.h"
-
-namespace Sword25 {
-
-class B25SLoader : public ImageLoader {
-	friend class ImageLoaderManager;
-protected:
-	virtual bool isCorrectImageFormat(const byte *fileDataPtr, uint fileSize);
-	virtual bool decodeImage(const byte *fileDataPtr, uint fileSize,  GraphicEngine::COLOR_FORMATS colorFormat, byte *&uncompressedDataPtr, int &width, int &height, int &pitch);
-	virtual bool imageProperties(const byte *fileDataPtr, uint fileSize, GraphicEngine::COLOR_FORMATS &colorFormat, int &width, int &height);
-
-};
-
-} // End of namespace Sword25
-
-#endif

Modified: scummvm/trunk/engines/sword25/gfx/image/imageloader.cpp
===================================================================
--- scummvm/trunk/engines/sword25/gfx/image/imageloader.cpp	2010-10-24 01:30:53 UTC (rev 53753)
+++ scummvm/trunk/engines/sword25/gfx/image/imageloader.cpp	2010-10-24 01:31:30 UTC (rev 53754)
@@ -35,7 +35,6 @@
 #include "sword25/gfx/image/imageloader.h"
 
 #include "sword25/gfx/image/pngloader.h"
-#include "sword25/gfx/image/b25sloader.h"
 
 DECLARE_SINGLETON(Sword25::ImageLoaderManager)
 
@@ -80,7 +79,6 @@
 
 ImageLoaderManager::ImageLoaderManager() {
 	_imageLoaderList.push_back(new PNGLoader());
-	_imageLoaderList.push_back(new B25SLoader());
 }
 
 ImageLoaderManager::~ImageLoaderManager() {

Modified: scummvm/trunk/engines/sword25/gfx/image/pngloader.cpp
===================================================================
--- scummvm/trunk/engines/sword25/gfx/image/pngloader.cpp	2010-10-24 01:30:53 UTC (rev 53753)
+++ scummvm/trunk/engines/sword25/gfx/image/pngloader.cpp	2010-10-24 01:31:30 UTC (rev 53754)
@@ -40,9 +40,54 @@
 
 #define BS_LOG_PREFIX "PNGLOADER"
 
-PNGLoader::PNGLoader() {
+
+namespace {
+
+/**
+ * Load a NULL-terminated string from the given stream.
+ */
+static Common::String loadString(Common::ReadStream &in, uint maxSize = 999) {
+	Common::String result;
+
+	while (!in.eos() && (result.size() < maxSize)) {
+		char ch = (char)in.readByte();
+		if (ch == '\0')
+			break;
+
+		result += ch;
+	}
+
+	return result;
 }
 
+/**
+ * Check if the given data is a savegame, and if so, locate the
+ * offset to the image data.
+ * @return offset to image data if fileDataPtr contains a savegame; 0 otherwise
+ */
+static uint findEmbeddedPNG(const byte *fileDataPtr, uint fileSize) {
+	assert(fileSize >= 100);
+	if (memcmp(fileDataPtr, "BS25SAVEGAME", 12))
+		return 0;
+
+	// Read in the header
+	Common::MemoryReadStream stream(fileDataPtr, fileSize);
+	stream.seek(0, SEEK_SET);
+
+	// Headerinformationen der Spielstandes einlesen.
+	uint compressedGamedataSize;
+	loadString(stream);		// Marker
+	loadString(stream);		// Version
+	loadString(stream);		// Description
+	Common::String gameSize = loadString(stream);
+	compressedGamedataSize = atoi(gameSize.c_str());
+	loadString(stream);
+
+	// Return the offset of where the thumbnail starts
+	return static_cast<uint>(stream.pos() + compressedGamedataSize);
+}
+}
+
 static void png_user_read_data(png_structp png_ptr, png_bytep data, png_size_t length) {
 	const byte **ref = (const byte **)png_get_io_ptr(png_ptr);
 	memcpy(data, *ref, length);
@@ -194,7 +239,8 @@
 }
 
 bool PNGLoader::decodeImage(const byte *fileDataPtr, uint fileSize,  GraphicEngine::COLOR_FORMATS colorFormat, byte *&uncompressedDataPtr, int &width, int &height, int &pitch) {
-	return doDecodeImage(fileDataPtr, fileSize, colorFormat, uncompressedDataPtr, width, height, pitch);
+	uint pngOffset = findEmbeddedPNG(fileDataPtr, fileSize);
+	return doDecodeImage(fileDataPtr + pngOffset, fileSize - pngOffset, colorFormat, uncompressedDataPtr, width, height, pitch);
 }
 
 bool PNGLoader::doImageProperties(const byte *fileDataPtr, uint fileSize, GraphicEngine::COLOR_FORMATS &colorFormat, int &width, int &height) {
@@ -242,7 +288,8 @@
 }
 
 bool PNGLoader::imageProperties(const byte *fileDataPtr, uint fileSize, GraphicEngine::COLOR_FORMATS &colorFormat, int &width, int &height) {
-	return doImageProperties(fileDataPtr, fileSize, colorFormat, width, height);
+	uint pngOffset = findEmbeddedPNG(fileDataPtr, fileSize);
+	return doImageProperties(fileDataPtr + pngOffset, fileSize - pngOffset, colorFormat, width, height);
 }
 
 bool PNGLoader::doIsCorrectImageFormat(const byte *fileDataPtr, uint fileSize) {
@@ -253,7 +300,8 @@
 }
 
 bool PNGLoader::isCorrectImageFormat(const byte *fileDataPtr, uint fileSize) {
-	return doIsCorrectImageFormat(fileDataPtr, fileSize);
+	uint pngOffset = findEmbeddedPNG(fileDataPtr, fileSize);
+	return doIsCorrectImageFormat(fileDataPtr + pngOffset, fileSize - pngOffset);
 }
 
 } // End of namespace Sword25

Modified: scummvm/trunk/engines/sword25/gfx/image/pngloader.h
===================================================================
--- scummvm/trunk/engines/sword25/gfx/image/pngloader.h	2010-10-24 01:30:53 UTC (rev 53753)
+++ scummvm/trunk/engines/sword25/gfx/image/pngloader.h	2010-10-24 01:31:30 UTC (rev 53754)
@@ -60,7 +60,6 @@
 	static bool doImageProperties(const byte *fileDataPtr, uint fileSize, GraphicEngine::COLOR_FORMATS &colorFormat, int &width, int &height);
 
 protected:
-	PNGLoader();
 	bool decodeImage(const byte *pFileData, uint fileSize,
 	                 GraphicEngine::COLOR_FORMATS colorFormat,
 	                 byte *&pUncompressedData,

Modified: scummvm/trunk/engines/sword25/module.mk
===================================================================
--- scummvm/trunk/engines/sword25/module.mk	2010-10-24 01:30:53 UTC (rev 53753)
+++ scummvm/trunk/engines/sword25/module.mk	2010-10-24 01:31:30 UTC (rev 53754)
@@ -26,7 +26,6 @@
 	gfx/text.o \
 	gfx/timedrenderobject.o \
 	gfx/image/art.o \
-	gfx/image/b25sloader.o \
 	gfx/image/imageloader.o \
 	gfx/image/pngloader.o \
 	gfx/image/renderedimage.o \


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