[Scummvm-cvs-logs] SF.net SVN: scummvm:[48124] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Thu Feb 25 16:22:26 CET 2010


Revision: 48124
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48124&view=rev
Author:   drmccoy
Date:     2010-02-25 15:22:26 +0000 (Thu, 25 Feb 2010)

Log Message:
-----------
Fixing problems with the texts table in TOT files when the order of the texts and resources tables are switched in the TOT file

Modified Paths:
--------------
    scummvm/trunk/engines/gob/resources.cpp
    scummvm/trunk/engines/gob/totfile.cpp
    scummvm/trunk/engines/gob/totfile.h

Modified: scummvm/trunk/engines/gob/resources.cpp
===================================================================
--- scummvm/trunk/engines/gob/resources.cpp	2010-02-24 00:39:48 UTC (rev 48123)
+++ scummvm/trunk/engines/gob/resources.cpp	2010-02-25 15:22:26 UTC (rev 48124)
@@ -350,16 +350,13 @@
 
 	_totTextTable = new TOTTextTable;
 
-	bool fromTOT;
 	if (totProps.textsOffset == 0) {
-		fromTOT                 = false;
 		_totTextTable->data     = loadTOTLocTexts(fileBase, _totTextTable->size);
 		_totTextTable->needFree = true;
 	} else {
-		fromTOT                 = true;
 		_totTextTable->data     = _totData + totProps.textsOffset - _totResStart;
 		_totTextTable->needFree = false;
-		_totTextTable->size     = _totSize - totProps.textsOffset;
+		_totTextTable->size     = totProps.textsSize;
 	}
 
 	if (_totTextTable->data) {
@@ -372,9 +369,6 @@
 
 			item.offset = totTextTable.readSint16LE();
 			item.size   = totTextTable.readSint16LE();
-
-			if (fromTOT)
-				item.offset -= (totProps.textsOffset - _totResStart);
 		}
 	}
 
@@ -572,14 +566,11 @@
 
 	if ((totItem.offset == 0xFFFF) || (totItem.size == 0))
 		return 0;
+
 	if ((totItem.offset + totItem.size) > (_totTextTable->size)) {
-// HACK: Some Fascination versions (Amiga, Atari and first PC floppies) have a different header, which is a problem here.
-//       Playtoons also have the same problem (and workaround).
-// TODO: Handle that in a proper way
-		if (((_vm->getGameType() == kGameTypeFascination) || (_vm->getGameType() == kGameTypePlaytoons)) && (_totTextTable->size < 0))
-			warning("totTextTable with negative size id:%d offset:%d in file %s : (size: %d)", id, totItem.offset, _totFile.c_str(), _totTextTable->size);
-		else
-			return 0;
+		warning("TOT text %d offset %d out of range (%s, %d, %d)",
+			id, totItem.offset, _totFile.c_str(), _totSize, totItem.size);
+		return 0;
 	}
 
 	return new TextItem(_totTextTable->data + totItem.offset, totItem.size);
@@ -710,7 +701,8 @@
 	int32 offset = _totResourceTable->dataOffset + totItem.offset - _totResStart;
 
 	if ((offset < 0) || (((uint32) (offset + totItem.size)) > _totSize)) {
-		warning("Skipping data id:%d offset:%d size :%d in file %s : out of _totTextTable", totItem.index, totItem.offset, totItem.size, _totFile.c_str());
+		warning("TOT data %d offset %d out of range (%s, %d, %d)",
+				totItem.index, totItem.offset, _totFile.c_str(), _totSize, totItem.size);
 		return 0;
 	}
 

Modified: scummvm/trunk/engines/gob/totfile.cpp
===================================================================
--- scummvm/trunk/engines/gob/totfile.cpp	2010-02-24 00:39:48 UTC (rev 48123)
+++ scummvm/trunk/engines/gob/totfile.cpp	2010-02-25 15:22:26 UTC (rev 48124)
@@ -97,12 +97,51 @@
 	for (int i = 0; i < 14; i++)
 		props.functions[i] = READ_LE_UINT16(_header + 100 + i * 2);
 
-	props.scriptEnd = _stream->size();
-	if (props.textsOffset > 0)
-		props.scriptEnd = MIN(props.scriptEnd, props.textsOffset);
-	if (props.resourcesOffset > 0)
-		props.scriptEnd = MIN(props.scriptEnd, props.resourcesOffset);
+	uint32 fileSize        = _stream->size();
+	uint32 textsOffset     = props.textsOffset;
+	uint32 resourcesOffset = props.resourcesOffset;
 
+	if (textsOffset == 0xFFFFFFFF)
+		textsOffset = 0;
+	if (resourcesOffset == 0xFFFFFFFF)
+		resourcesOffset = 0;
+
+	props.scriptEnd = fileSize;
+	if (textsOffset > 0)
+		props.scriptEnd = MIN(props.scriptEnd, textsOffset);
+	if (resourcesOffset > 0)
+		props.scriptEnd = MIN(props.scriptEnd, resourcesOffset);
+
+	// Calculate the sizes of the texts and resources tables for every possible order
+	if ((textsOffset > 0) && (resourcesOffset > 0)) {
+		// Both exists
+
+		if (props.textsOffset > resourcesOffset) {
+			// First resources, then texts
+			props.textsSize     = fileSize - textsOffset;
+			props.resourcesSize = textsOffset - resourcesOffset;
+		} else {
+			// First texts, then resources
+			props.textsSize     = resourcesOffset - textsOffset;
+			props.resourcesSize = fileSize - resourcesOffset;
+		}
+	} else if (textsOffset     > 0) {
+		// Only the texts table exists
+
+		props.textsSize     = fileSize - textsOffset;
+		props.resourcesSize = 0;
+	} else if (resourcesOffset > 0) {
+		// Only the resources table exists
+
+		props.textsSize     = 0;
+		props.resourcesSize = fileSize - resourcesOffset;
+	} else {
+		// Both don't exists
+
+		props.textsSize     = 0;
+		props.resourcesSize = 0;
+	}
+
 	return true;
 }
 

Modified: scummvm/trunk/engines/gob/totfile.h
===================================================================
--- scummvm/trunk/engines/gob/totfile.h	2010-02-24 00:39:48 UTC (rev 48123)
+++ scummvm/trunk/engines/gob/totfile.h	2010-02-25 15:22:26 UTC (rev 48124)
@@ -53,6 +53,8 @@
 		uint8  communHandling;
 		uint16 functions[14];
 		uint32 scriptEnd;
+		uint32 textsSize;
+		uint32 resourcesSize;
 	};
 
 	TOTFile(GobEngine *vm);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list