aboutsummaryrefslogtreecommitdiff
path: root/engines/gob
diff options
context:
space:
mode:
authorSven Hesse2012-06-15 15:09:01 +0200
committerSven Hesse2012-06-15 15:09:01 +0200
commit5961609a56a910d81d38389c6ac61d06eca6f029 (patch)
tree1e64164a143b9fdfad5efd9723b40e87721d0a30 /engines/gob
parent7632246264102d88922fc963284af6250ea12f57 (diff)
downloadscummvm-rg350-5961609a56a910d81d38389c6ac61d06eca6f029.tar.gz
scummvm-rg350-5961609a56a910d81d38389c6ac61d06eca6f029.tar.bz2
scummvm-rg350-5961609a56a910d81d38389c6ac61d06eca6f029.zip
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.
Diffstat (limited to 'engines/gob')
-rw-r--r--engines/gob/gob.cpp10
-rw-r--r--engines/gob/gob.h4
-rw-r--r--engines/gob/resources.cpp12
-rw-r--r--engines/gob/resources.h6
4 files changed, 27 insertions, 5 deletions
diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp
index a13f6a372f..f3480fed99 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 165760e6d5..19489e4924 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 d5497c25be..a84f4ac4b8 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 39155c5176..04b3b9d31e 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