[Scummvm-cvs-logs] SF.net SVN: scummvm: [30985] scummvm/trunk/engines/saga/saga.cpp

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Feb 27 16:11:16 CET 2008


Revision: 30985
          http://scummvm.svn.sourceforge.net/scummvm/?rev=30985&view=rev
Author:   thebluegr
Date:     2008-02-27 07:11:16 -0800 (Wed, 27 Feb 2008)

Log Message:
-----------
Fix for bug #1895205 - "IHNM: end game text/caption error"

Modified Paths:
--------------
    scummvm/trunk/engines/saga/saga.cpp

Modified: scummvm/trunk/engines/saga/saga.cpp
===================================================================
--- scummvm/trunk/engines/saga/saga.cpp	2008-02-27 15:01:33 UTC (rev 30984)
+++ scummvm/trunk/engines/saga/saga.cpp	2008-02-27 15:11:16 UTC (rev 30985)
@@ -315,6 +315,7 @@
 void SagaEngine::loadStrings(StringsTable &stringsTable, const byte *stringsPointer, size_t stringsLength) {
 	uint16 stringsCount;
 	size_t offset;
+	size_t prevOffset = 0;
 	int i;
 
 	if (stringsLength == 0) {
@@ -334,6 +335,13 @@
 	scriptS.seek(0);
 	while (i < stringsCount) {
 		offset = scriptS.readUint16();
+		// In some rooms in IHNM, string offsets can be greater than the maximum value than a 16-bit integer can hold
+		// We detect this by checking the previous offset, and if it was bigger than the current one, an overflow
+		// occured (since the string offsets are sequential), so we're adding the missing part of the number
+		// Fixes bug #1895205 - "IHNM: end game text/caption error"
+		if (prevOffset > offset)
+			offset += 65536;
+		prevOffset = offset;
 		if (offset == stringsLength) {
 			stringsCount = i;
 			stringsTable.strings = (const char **)realloc(stringsTable.strings, stringsCount * sizeof(*stringsTable.strings));


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