[Scummvm-cvs-logs] SF.net SVN: scummvm:[54365] scummvm/trunk/engines/sci/engine/vm.cpp

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Fri Nov 19 11:28:43 CET 2010


Revision: 54365
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54365&view=rev
Author:   thebluegr
Date:     2010-11-19 10:28:43 +0000 (Fri, 19 Nov 2010)

Log Message:
-----------
SCI: Added pointer arithmetic support for SCI2 strings

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/vm.cpp

Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp	2010-11-19 10:27:22 UTC (rev 54364)
+++ scummvm/trunk/engines/sci/engine/vm.cpp	2010-11-19 10:28:43 UTC (rev 54365)
@@ -641,6 +641,30 @@
 		base.offset += offset;
 		return base;
 
+	case SEG_TYPE_STRING: {
+		// We need to copy over the string into a new one
+		// Make sure that the offset is positive
+		if (offset < 0)
+			error("pointer_add: Attempt to reference a previous offset of a SCI string");
+
+		// Get the source string...
+		SciString *str = s->_segMan->lookupString(base);
+		Common::String rawStr = str->toString();
+
+		// ...and copy it to a new one
+		reg_t newStringAddr;
+		SciString *newStr = s->_segMan->allocateString(&newStringAddr);
+		newStr->setSize(str->getSize() - offset);
+
+		// Cut off characters till we reach the desired location
+		for (int i = 0; i < offset; i++)
+			rawStr.deleteChar(0);
+
+		newStr->fromString(rawStr);
+
+		return newStringAddr;
+	}
+
 	default:
 		// FIXME: Changed this to warning, because iceman does this during dancing with girl.
 		// Investigate why that is so and either fix the underlying issue or implement a more


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