[Scummvm-cvs-logs] scummvm master -> 5961609a56a910d81d38389c6ac61d06eca6f029

DrMcCoy drmccoy at drmccoy.de
Fri Jun 15 15:10:42 CEST 2012


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

Summary:
5961609a56 GOB: Add a resource size workaround for Little Red


Commit: 5961609a56a910d81d38389c6ac61d06eca6f029
    https://github.com/scummvm/scummvm/commit/5961609a56a910d81d38389c6ac61d06eca6f029
Author: Sven Hesse (drmccoy at users.sourceforge.net)
Date: 2012-06-15T06:09:01-07:00

Commit Message:
GOB: Add a resource size workaround for Little Red

This fixes the missing resources in the screen where Little Red
has to find the animals' homes for them.

Changed paths:
    engines/gob/gob.cpp
    engines/gob/gob.h
    engines/gob/resources.cpp
    engines/gob/resources.h



diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp
index a13f6a3..f3480fe 100644
--- a/engines/gob/gob.cpp
+++ b/engines/gob/gob.cpp
@@ -233,6 +233,10 @@ bool GobEngine::isDemo() const {
 	return (isSCNDemo() || isBATDemo());
 }
 
+bool GobEngine::hasResourceSizeWorkaround() const {
+	return _resourceSizeWorkaround;
+}
+
 bool GobEngine::isCurrentTot(const Common::String &tot) const {
 	return _game->_curTotFile.equalsIgnoreCase(tot);
 }
@@ -389,6 +393,8 @@ void GobEngine::pauseGame() {
 }
 
 bool GobEngine::initGameParts() {
+	_resourceSizeWorkaround = false;
+
 	// just detect some devices some of which will be always there if the music is not disabled
 	_noMusic = MidiDriver::getMusicType(MidiDriver::detectDevice(MDT_PCSPK | MDT_MIDI | MDT_ADLIB)) == MT_NULL ? true : false;
 	_saveLoad = 0;
@@ -471,6 +477,10 @@ bool GobEngine::initGameParts() {
 		_map      = new Map_v2(this);
 		_goblin   = new Goblin_v2(this);
 		_scenery  = new Scenery_v2(this);
+
+		// WORKAROUND: Little Red Riding Hood has a small resource size glitch in the
+		//             screen where Little Red needs to find the animals' homes.
+		_resourceSizeWorkaround = true;
 		break;
 
 	case kGameTypeGob3:
diff --git a/engines/gob/gob.h b/engines/gob/gob.h
index 165760e..19489e4 100644
--- a/engines/gob/gob.h
+++ b/engines/gob/gob.h
@@ -200,6 +200,8 @@ public:
 
 	GobConsole *_console;
 
+	bool _resourceSizeWorkaround;
+
 	Global *_global;
 	Util *_util;
 	DataIO *_dataIO;
@@ -236,6 +238,8 @@ public:
 	bool isTrueColor() const;
 	bool isDemo() const;
 
+	bool hasResourceSizeWorkaround() const;
+
 	bool isCurrentTot(const Common::String &tot) const;
 
 	void setTrueColor(bool trueColor);
diff --git a/engines/gob/resources.cpp b/engines/gob/resources.cpp
index d5497c2..a84f4ac 100644
--- a/engines/gob/resources.cpp
+++ b/engines/gob/resources.cpp
@@ -716,7 +716,7 @@ byte *Resources::getIMData(TOTResourceItem &totItem) const {
 	return _imData + offset;
 }
 
-byte *Resources::getEXTData(EXTResourceItem &extItem, uint32 size) const {
+byte *Resources::getEXTData(EXTResourceItem &extItem, uint32 &size) const {
 	Common::SeekableReadStream *stream = _vm->_dataIO->getFile(_extFile);
 	if (!stream)
 		return 0;
@@ -726,6 +726,10 @@ byte *Resources::getEXTData(EXTResourceItem &extItem, uint32 size) const {
 		return 0;
 	}
 
+	// If that workaround is active, limit the resource size instead of throwing an error
+	if (_vm->hasResourceSizeWorkaround())
+		size = MIN<int>(size, stream->size() - extItem.offset);
+
 	byte *data = new byte[extItem.packed ? (size + 2) : size];
 	if (stream->read(data, size) != size) {
 		delete[] data;
@@ -737,7 +741,7 @@ byte *Resources::getEXTData(EXTResourceItem &extItem, uint32 size) const {
 	return data;
 }
 
-byte *Resources::getEXData(EXTResourceItem &extItem, uint32 size) const {
+byte *Resources::getEXData(EXTResourceItem &extItem, uint32 &size) const {
 	Common::SeekableReadStream *stream = _vm->_dataIO->getFile(_exFile);
 	if (!stream)
 		return 0;
@@ -747,6 +751,10 @@ byte *Resources::getEXData(EXTResourceItem &extItem, uint32 size) const {
 		return 0;
 	}
 
+	// If that workaround is active, limit the resource size instead of throwing an error
+	if (_vm->hasResourceSizeWorkaround())
+		size = MIN<int>(size, stream->size() - extItem.offset);
+
 	byte *data = new byte[extItem.packed ? (size + 2) : size];
 	if (stream->read(data, size) != size) {
 		delete[] data;
diff --git a/engines/gob/resources.h b/engines/gob/resources.h
index 39155c5..04b3b9d 100644
--- a/engines/gob/resources.h
+++ b/engines/gob/resources.h
@@ -103,7 +103,7 @@ private:
 	static const int kTOTTextItemSize  = 2 + 2;
 
 	enum ResourceType {
-		kResourceTOT,
+		kResourceTOT = 0,
 		kResourceIM,
 		kResourceEXT,
 		kResourceEX
@@ -201,8 +201,8 @@ private:
 
 	byte *getTOTData(TOTResourceItem &totItem) const;
 	byte *getIMData(TOTResourceItem &totItem)  const;
-	byte *getEXTData(EXTResourceItem &extItem, uint32 size) const;
-	byte *getEXData(EXTResourceItem &extItem,  uint32 size) const;
+	byte *getEXTData(EXTResourceItem &extItem, uint32 &size) const;
+	byte *getEXData(EXTResourceItem &extItem,  uint32 &size) const;
 };
 
 } // End of namespace Gob






More information about the Scummvm-git-logs mailing list