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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Jul 1 18:04:48 CEST 2010


Revision: 50550
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50550&view=rev
Author:   fingolfin
Date:     2010-07-01 16:04:48 +0000 (Thu, 01 Jul 2010)

Log Message:
-----------
SCI: Add SegManager::getSystemString() method

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kernel32.cpp
    scummvm/trunk/engines/sci/engine/seg_manager.cpp
    scummvm/trunk/engines/sci/engine/seg_manager.h

Modified: scummvm/trunk/engines/sci/engine/kernel32.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel32.cpp	2010-07-01 16:04:29 UTC (rev 50549)
+++ scummvm/trunk/engines/sci/engine/kernel32.cpp	2010-07-01 16:04:48 UTC (rev 50550)
@@ -609,13 +609,15 @@
 		if (argv[1].segment == s->_segMan->getSysStringsSegment()) {
 			// Resize if necessary
 			const uint16 sysStringId = argv[1].toUint16();
-			if ((uint32)s->_segMan->_sysStrings->_strings[sysStringId]._maxSize < index1 + count) {
-				free(s->_segMan->_sysStrings->_strings[sysStringId]._value);
-				s->_segMan->_sysStrings->_strings[sysStringId]._maxSize = index1 + count;
-				s->_segMan->_sysStrings->_strings[sysStringId]._value = (char *)calloc(index1 + count, sizeof(char));
+			SystemString *sysString = s->_segMan->getSystemString(sysStringId);
+			assert(sysString);
+			if ((uint32)sysString->_maxSize < index1 + count) {
+				free(sysString->_value);
+				sysString->_maxSize = index1 + count;
+				sysString->_value = (char *)calloc(index1 + count, sizeof(char));
 			}
 
-			strncpy(s->_segMan->_sysStrings->_strings[sysStringId]._value + index1, string2 + index2, count);
+			strncpy(sysString->_value + index1, string2 + index2, count);
 		} else {
 			SciString *string1 = s->_segMan->lookupString(argv[1]);
 

Modified: scummvm/trunk/engines/sci/engine/seg_manager.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.cpp	2010-07-01 16:04:29 UTC (rev 50549)
+++ scummvm/trunk/engines/sci/engine/seg_manager.cpp	2010-07-01 16:04:48 UTC (rev 50550)
@@ -85,7 +85,7 @@
 	_sysStrings = (SystemStrings *)allocSegment(new SystemStrings(), &_sysStringsSegId);
 
 	// Allocate static buffer for savegame and CWD directories
-	SystemString *strSaveDir = &_sysStrings->_strings[SYS_STRING_SAVEDIR];
+	SystemString *strSaveDir = getSystemString(SYS_STRING_SAVEDIR);
 	strSaveDir->_name = "savedir";
 	strSaveDir->_maxSize = MAX_SAVE_DIR_SIZE;
 	strSaveDir->_value = (char *)calloc(MAX_SAVE_DIR_SIZE, sizeof(char));
@@ -94,7 +94,7 @@
 	::strcpy(strSaveDir->_value, "");
 
 	// Allocate static buffer for the parser base
-	SystemString *strParserBase = &_sysStrings->_strings[SYS_STRING_PARSER_BASE];
+	SystemString *strParserBase = getSystemString(SYS_STRING_PARSER_BASE);
 	strParserBase->_name = "parser-base";
 	strParserBase->_maxSize = MAX_PARSER_BASE;
 	strParserBase->_value = (char *)calloc(MAX_PARSER_BASE, sizeof(char));

Modified: scummvm/trunk/engines/sci/engine/seg_manager.h
===================================================================
--- scummvm/trunk/engines/sci/engine/seg_manager.h	2010-07-01 16:04:29 UTC (rev 50549)
+++ scummvm/trunk/engines/sci/engine/seg_manager.h	2010-07-01 16:04:48 UTC (rev 50550)
@@ -448,6 +448,18 @@
 	 */
 	SegmentId getSysStringsSegment() { return _sysStringsSegId; }
 
+	/**
+	 * Get a pointer to the system string with the specified index,
+	 * or NULL if that index is invalid.
+	 *
+	 * This method is currently only used by kString().
+	 */
+	SystemString *getSystemString(uint idx) const {
+		if (idx >= SYS_STRINGS_MAX)
+			return NULL;
+		return &_sysStrings->_strings[idx];
+	}
+
 public: // TODO: make private
 	Common::Array<SegmentObj *> _heap;
 	// Only accessible from saveLoadWithSerializer()
@@ -476,11 +488,8 @@
 
 	/* System strings */
 	SegmentId _sysStringsSegId;
-public:	// TODO: make private. Only kString() needs direct access
 	SystemStrings *_sysStrings;
 
-private:
-
 #ifdef ENABLE_SCI32
 	SegmentId _arraysSegId;
 	SegmentId _stringSegId;


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