[Scummvm-git-logs] scummvm branch-2-6 -> 75aa2447505c0a1d52cee5756a6b7787daccf05a

dreammaster noreply at scummvm.org
Thu Jun 23 04:45:25 UTC 2022


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:
75aa244750 CHEWY: Fix speech crashes later in the game


Commit: 75aa2447505c0a1d52cee5756a6b7787daccf05a
    https://github.com/scummvm/scummvm/commit/75aa2447505c0a1d52cee5756a6b7787daccf05a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2022-06-22T21:45:16-07:00

Commit Message:
CHEWY: Fix speech crashes later in the game

Changed paths:
    engines/chewy/resource.cpp


diff --git a/engines/chewy/resource.cpp b/engines/chewy/resource.cpp
index 7998b18da09..aea96b44309 100644
--- a/engines/chewy/resource.cpp
+++ b/engines/chewy/resource.cpp
@@ -68,10 +68,22 @@ Resource::Resource(Common::String filename) {
 		_encrypted = true;
 
 	_chunkCount = _stream.readUint16LE();
-	_chunkList.reserve(_chunkCount);
+	_chunkList.resize(_chunkCount);
+
+	if (header == headerGeneric) {
+		// NGS files have an index at the end
+		_stream.seek(-(int)(_chunkCount * sizeof(uint32)), SEEK_END);
+		for (uint i = 0; i < _chunkCount; i++) {
+			Chunk &cur = _chunkList[i];
+			cur.pos = _stream.readUint32LE();
+		}
+	}
 
 	for (uint i = 0; i < _chunkCount; i++) {
-		Chunk cur;
+		Chunk &cur = _chunkList[i];
+		if (header == headerGeneric)
+			_stream.seek(cur.pos - 6);
+
 		cur.size = _stream.readUint32LE();
 
 		if (isText) {
@@ -88,6 +100,9 @@ Resource::Resource(Common::String filename) {
 
 		cur.pos = _stream.pos();
 
+		// TODO: Is this workaround necessary anymore
+		// with the stream offset fixes
+#if 0
 		// WORKAROUND: Patch invalid speech sample
 		if (isSpeech && i == 2277 && cur.size == 57028) {
 			cur.size = 152057;
@@ -96,9 +111,10 @@ Resource::Resource(Common::String filename) {
 			_chunkList.push_back(cur);
 			continue;
 		}
+#endif
 
-		_stream.skip(cur.size);
-		_chunkList.push_back(cur);
+		if (header != headerGeneric)
+			_stream.skip(cur.size);
 	}
 
 	_spriteCorrectionsCount = 0;




More information about the Scummvm-git-logs mailing list