[Scummvm-cvs-logs] scummvm master -> 9396958536c487554f79e5a54064c8d37d45fe15

bluegr bluegr at gmail.com
Thu Sep 26 09:55:30 CEST 2013


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

Summary:
a5691e8dc8 NEVERHOOD: Expand the error thrown for broken resources in BLB archives
dca513dc20 COMMON: Expand the warnings thrown for broken DCL compressed data
9396958536 NEVERHOOD: Add a patch system for broken resources in Russian versions


Commit: a5691e8dc85bb1f7aee237529983f6fbab61c89d
    https://github.com/scummvm/scummvm/commit/a5691e8dc85bb1f7aee237529983f6fbab61c89d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2013-09-26T00:43:53-07:00

Commit Message:
NEVERHOOD: Expand the error thrown for broken resources in BLB archives

The Russian translated versions of Neverhood have invalid unpacked
sizes for some compressed resources. This helps in identifying their
resource parameters more easily

Changed paths:
    engines/neverhood/blbarchive.cpp



diff --git a/engines/neverhood/blbarchive.cpp b/engines/neverhood/blbarchive.cpp
index d730d75..c743037 100644
--- a/engines/neverhood/blbarchive.cpp
+++ b/engines/neverhood/blbarchive.cpp
@@ -131,7 +131,8 @@ void BlbArchive::load(BlbArchiveEntry *entry, byte *buffer, uint32 size) {
 		break;
 	case 3: // DCL-compressed
 		if (!Common::decompressDCL(&_fd, buffer, entry->diskSize, entry->size))
-			error("BlbArchive::load() Error during decompression of %08X", entry->fileHash);
+			error("BlbArchive::load() Error during decompression of %08X (offset: %d, disk size: %d, size: %d)",
+					entry->fileHash, entry->offset, entry->diskSize, entry->size);
 		break;
 	default:
 		error("BlbArchive::load() Unknown compression type %d", entry->comprType);


Commit: dca513dc207779bfd36a1c71e3712405a1d9856d
    https://github.com/scummvm/scummvm/commit/dca513dc207779bfd36a1c71e3712405a1d9856d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2013-09-26T00:46:09-07:00

Commit Message:
COMMON: Expand the warnings thrown for broken DCL compressed data

The Russian translated versions of Neverhood have invalid unpacked
sizes for some compressed resources. This helps in identifying their
resource parameters more easily

Changed paths:
    common/dcl.cpp



diff --git a/common/dcl.cpp b/common/dcl.cpp
index 1879be9..87ec0ad 100644
--- a/common/dcl.cpp
+++ b/common/dcl.cpp
@@ -371,12 +371,14 @@ bool DecompressorDCL::unpack(ReadStream *src, byte *dest, uint32 nPacked, uint32
 			debug(8, "\nCOPY(%d from %d)\n", val_length, val_distance);
 
 			if (val_length + _dwWrote > _szUnpacked) {
-				warning("DCL-INFLATE Error: Write out of bounds while copying %d bytes", val_length);
+				warning("DCL-INFLATE Error: Write out of bounds while copying %d bytes (declared unpacked size is %d bytes, current is %d + %d bytes)",
+						val_length, _szUnpacked, _dwWrote, val_length);
 				return false;
 			}
 
 			if (_dwWrote < val_distance) {
-				warning("DCL-INFLATE Error: Attempt to copy from before beginning of input stream");
+				warning("DCL-INFLATE Error: Attempt to copy from before beginning of input stream (declared unpacked size is %d bytes, current is %d bytes)",
+						_szUnpacked, _dwWrote);
 				return false;
 			}
 


Commit: 9396958536c487554f79e5a54064c8d37d45fe15
    https://github.com/scummvm/scummvm/commit/9396958536c487554f79e5a54064c8d37d45fe15
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2013-09-26T00:54:30-07:00

Commit Message:
NEVERHOOD: Add a patch system for broken resources in Russian versions

Some translated resources in Russian versions have incorrect unpacked
resource sizes. The original didn't perform checks for these, but we
do, thus we'll need to patch the unpacked resource sizes for each case

Changed paths:
    engines/neverhood/console.cpp
    engines/neverhood/detection.cpp
    engines/neverhood/neverhood.h
    engines/neverhood/resource.cpp
    engines/neverhood/resourceman.cpp
    engines/neverhood/resourceman.h
    engines/neverhood/sound.cpp



diff --git a/engines/neverhood/console.cpp b/engines/neverhood/console.cpp
index a2ceed8..708c687 100644
--- a/engines/neverhood/console.cpp
+++ b/engines/neverhood/console.cpp
@@ -252,7 +252,7 @@ bool Console::Cmd_DumpResource(int argc, const char **argv) {
 		if (!handle.isValid()) {
 			DebugPrintf("Invalid resource hash\n");
 		} else {
-			_vm->_res->loadResource(handle);
+			_vm->_res->loadResource(handle, _vm->applyResourceFixes());
 			Common::DumpFile outFile;
 			outFile.open(outFileName);
 			outFile.write(handle.data(), handle.size());
diff --git a/engines/neverhood/detection.cpp b/engines/neverhood/detection.cpp
index 3de0870..96c87ab 100644
--- a/engines/neverhood/detection.cpp
+++ b/engines/neverhood/detection.cpp
@@ -52,6 +52,10 @@ Common::Platform NeverhoodEngine::getPlatform() const {
 	return _gameDescription->desc.platform;
 }
 
+Common::Language NeverhoodEngine::getLanguage() const {
+	return _gameDescription->desc.language;
+}
+
 uint16 NeverhoodEngine::getVersion() const {
 	return _gameDescription->version;
 }
@@ -60,6 +64,10 @@ bool NeverhoodEngine::isDemo() const {
 	return _gameDescription->desc.flags & ADGF_DEMO;
 }
 
+bool NeverhoodEngine::applyResourceFixes() const {
+	return getLanguage() == Common::RU_RUS;
+}
+
 }
 
 static const PlainGameDescriptor neverhoodGames[] = {
diff --git a/engines/neverhood/neverhood.h b/engines/neverhood/neverhood.h
index 9b65f67..0561aa2 100644
--- a/engines/neverhood/neverhood.h
+++ b/engines/neverhood/neverhood.h
@@ -72,8 +72,10 @@ public:
 	uint32 getFeatures() const;
 	uint16 getVersion() const;
 	Common::Platform getPlatform() const;
+	Common::Language getLanguage() const;
 	bool hasFeature(EngineFeature f) const;
 	bool isDemo() const;
+	bool applyResourceFixes() const;
 	Common::String getTargetName() { return _targetName; };
 
 	Common::RandomSource *_rnd;
diff --git a/engines/neverhood/resource.cpp b/engines/neverhood/resource.cpp
index a1a517f..b45dbff 100644
--- a/engines/neverhood/resource.cpp
+++ b/engines/neverhood/resource.cpp
@@ -53,7 +53,7 @@ bool SpriteResource::load(uint32 fileHash, bool doLoadPosition) {
 	unload();
 	_vm->_res->queryResource(fileHash, _resourceHandle);
 	if (_resourceHandle.isValid() && _resourceHandle.type() == kResTypeBitmap) {
-		_vm->_res->loadResource(_resourceHandle);
+		_vm->_res->loadResource(_resourceHandle, _vm->applyResourceFixes());
 		const byte *spriteData = _resourceHandle.data();
 		NPoint *position = doLoadPosition ? &_position : NULL;
 		parseBitmapResource(spriteData, &_rle, &_dimensions, position, NULL, &_pixels);
@@ -83,7 +83,7 @@ bool PaletteResource::load(uint32 fileHash) {
 	_vm->_res->queryResource(fileHash, _resourceHandle);
 	if (_resourceHandle.isValid() &&
 		(_resourceHandle.type() == kResTypeBitmap || _resourceHandle.type() == kResTypePalette)) {
-		_vm->_res->loadResource(_resourceHandle);
+		_vm->_res->loadResource(_resourceHandle, _vm->applyResourceFixes());
 		_palette = _resourceHandle.data();
 		// Check if the palette is stored in a bitmap
 		if (_resourceHandle.type() == kResTypeBitmap)
@@ -144,7 +144,7 @@ bool AnimResource::load(uint32 fileHash) {
 	uint16 frameListStartOfs, frameCount;
 	uint32 spriteDataOfs, paletteDataOfs;
 
-	_vm->_res->loadResource(_resourceHandle);
+	_vm->_res->loadResource(_resourceHandle, _vm->applyResourceFixes());
 	resourceData = _resourceHandle.data();
 
 	animListCount = READ_LE_UINT16(resourceData);
@@ -323,7 +323,7 @@ void TextResource::load(uint32 fileHash) {
 	unload();
 	_vm->_res->queryResource(fileHash, _resourceHandle);
 	if (_resourceHandle.isValid() && _resourceHandle.type() == kResTypeText) {
-		_vm->_res->loadResource(_resourceHandle);
+		_vm->_res->loadResource(_resourceHandle, _vm->applyResourceFixes());
 		_textData = _resourceHandle.data();
 		_count = READ_LE_UINT32(_textData);
 	}
@@ -359,7 +359,7 @@ void DataResource::load(uint32 fileHash) {
 	unload();
 	_vm->_res->queryResource(fileHash, _resourceHandle);
 	if (_resourceHandle.isValid() && _resourceHandle.type() == kResTypeData) {
-		_vm->_res->loadResource(_resourceHandle);
+		_vm->_res->loadResource(_resourceHandle, _vm->applyResourceFixes());
 		data = _resourceHandle.data();
 		dataSize = _resourceHandle.size();
 	}
diff --git a/engines/neverhood/resourceman.cpp b/engines/neverhood/resourceman.cpp
index 37089a5..518755a 100644
--- a/engines/neverhood/resourceman.cpp
+++ b/engines/neverhood/resourceman.cpp
@@ -85,7 +85,25 @@ void ResourceMan::queryResource(uint32 fileHash, ResourceHandle &resourceHandle)
 	resourceHandle._extData = firstEntry ? firstEntry->archiveEntry->extData : NULL;
 }
 
-void ResourceMan::loadResource(ResourceHandle &resourceHandle) {
+struct EntrySizeFix {
+	uint32 fileHash;
+	uint32 offset;
+	uint32 diskSize;
+	uint32 size;
+	uint32 fixedSize;
+};
+
+static const EntrySizeFix entrySizeFixes[] = {
+	//  fileHash    offset   diskSize   size  fixedSize
+	// Fixes for the Russian "Dyadyushka Risech" version
+	// TODO
+	// Fixes for the Russian "Fargus" version
+	// TODO
+	//
+	{          0,        0,         0,     0,         0 }
+};
+
+void ResourceMan::loadResource(ResourceHandle &resourceHandle, bool applyResourceFixes) {
 	resourceHandle._data = NULL;
 	if (resourceHandle.isValid()) {
 		const uint32 fileHash = resourceHandle.fileHash();
@@ -97,8 +115,19 @@ void ResourceMan::loadResource(ResourceHandle &resourceHandle) {
 		if (resourceData->data != NULL) {
 			resourceData->dataRefCount++;
 		} else {
-			resourceData->data = new byte[resourceHandle._resourceFileEntry->archiveEntry->size];
-			resourceHandle._resourceFileEntry->archive->load(resourceHandle._resourceFileEntry->archiveEntry, resourceData->data, 0);
+			BlbArchiveEntry *entry = resourceHandle._resourceFileEntry->archiveEntry;
+
+			// Apply fixes for broken resources in Russian versions
+			if (applyResourceFixes) {
+				for (const EntrySizeFix *cur = entrySizeFixes; cur->fileHash > 0; ++cur) {
+					if (entry->fileHash == cur->fileHash && entry->offset == cur->offset &&
+						entry->diskSize == cur->diskSize && entry->size == cur->size)
+						entry->size = cur->fixedSize;
+				}
+			}
+
+			resourceData->data = new byte[entry->size];
+			resourceHandle._resourceFileEntry->archive->load(entry, resourceData->data, 0);
 			resourceData->dataRefCount = 1;
 		}
 		resourceHandle._data = resourceData->data;
diff --git a/engines/neverhood/resourceman.h b/engines/neverhood/resourceman.h
index 5a3697f..29bf40a 100644
--- a/engines/neverhood/resourceman.h
+++ b/engines/neverhood/resourceman.h
@@ -78,7 +78,7 @@ public:
 	const ResourceFileEntry& getEntry(uint index) { return _entries[index]; }
 	uint getEntryCount() { return _entries.size(); }
 	void queryResource(uint32 fileHash, ResourceHandle &resourceHandle);
-	void loadResource(ResourceHandle &resourceHandle);
+	void loadResource(ResourceHandle &resourceHandle, bool applyResourceFixes);
 	void unloadResource(ResourceHandle &resourceHandle);
 	void purgeResources();
 protected:
diff --git a/engines/neverhood/sound.cpp b/engines/neverhood/sound.cpp
index 1fd0967..746dd17 100644
--- a/engines/neverhood/sound.cpp
+++ b/engines/neverhood/sound.cpp
@@ -577,7 +577,7 @@ AudioResourceManSoundItem::AudioResourceManSoundItem(NeverhoodEngine *vm, uint32
 void AudioResourceManSoundItem::loadSound() {
 	if (!_data && _resourceHandle.isValid() &&
 		(_resourceHandle.type() == kResTypeSound || _resourceHandle.type() == kResTypeMusic)) {
-		_vm->_res->loadResource(_resourceHandle);
+		_vm->_res->loadResource(_resourceHandle, _vm->applyResourceFixes());
 		_data = _resourceHandle.data();
 	}
 }






More information about the Scummvm-git-logs mailing list