[Scummvm-git-logs] scummvm master -> 97b93c9f5ff31a13c14101c370d5b491d6aeda7a

sluicebox noreply at scummvm.org
Sat Jan 14 02:13:23 UTC 2023


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:
97b93c9f5f SCI: Remove dead code from findGameObject()


Commit: 97b93c9f5ff31a13c14101c370d5b491d6aeda7a
    https://github.com/scummvm/scummvm/commit/97b93c9f5ff31a13c14101c370d5b491d6aeda7a
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2023-01-13T18:13:02-08:00

Commit Message:
SCI: Remove dead code from findGameObject()

This code attempted to skip calling the function that finds script 0's
export block, but this never happened because it tests the wrong offset.
Even if it tested the right offset, it would have just been duplicating
what the function does.

Changed paths:
    engines/sci/resource/resource.cpp


diff --git a/engines/sci/resource/resource.cpp b/engines/sci/resource/resource.cpp
index d48206a4e4e..ef51771f422 100644
--- a/engines/sci/resource/resource.cpp
+++ b/engines/sci/resource/resource.cpp
@@ -3028,20 +3028,12 @@ reg_t ResourceManager::findGameObject(const bool addSci11ScriptOffset, const boo
 	SciSpan<const byte>::const_iterator offsetPtr;
 
 	if (getSciVersion() <= SCI_VERSION_1_LATE) {
-		SciSpan<const byte> buf = (getSciVersion() == SCI_VERSION_0_EARLY) ? script->subspan(2) : *script;
+		offsetPtr = findSci0ExportsBlock(*script);
+		if (offsetPtr == script->cend())
+			error("Unable to find exports block from script 0");
+		offsetPtr += 4 + 2;
 
-		// Check if the first block is the exports block (in most cases, it is)
-		bool exportsIsFirst = buf.getUint16LEAt(4) == 7;
-		if (exportsIsFirst) {
-			offsetPtr = buf.subspan(4 + 2).cbegin();
-		} else {
-			offsetPtr = findSci0ExportsBlock(*script);
-			if (offsetPtr == buf.cend())
-				error("Unable to find exports block from script 0");
-			offsetPtr += 4 + 2;
-		}
-
-		int16 offset = !isSci11Mac() ? offsetPtr.getUint16LE() : offsetPtr.getUint16BE();
+		uint16 offset = !isSci11Mac() ? offsetPtr.getUint16LE() : offsetPtr.getUint16BE();
 		return make_reg(1, offset);
 	} else if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1_LATE) {
 		offsetPtr = script->cbegin() + 4 + 2 + 2;




More information about the Scummvm-git-logs mailing list