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

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Wed Jul 7 16:19:36 CEST 2010


Revision: 50735
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50735&view=rev
Author:   m_kiewitz
Date:     2010-07-07 14:19:36 +0000 (Wed, 07 Jul 2010)

Log Message:
-----------
SCI: accepting decimal/hexadecimal input on segment_info & kill_segment debug command, cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/console.h

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2010-07-07 11:02:11 UTC (rev 50734)
+++ scummvm/trunk/engines/sci/console.cpp	2010-07-07 14:19:36 UTC (rev 50735)
@@ -1581,7 +1581,7 @@
 		DebugPrintf("Provides information on the specified segment(s)\n");
 		DebugPrintf("Usage: %s <segment number>\n", argv[0]);
 		DebugPrintf("<segment number> can be a number, which shows the information of the segment with\n");
-		DebugPrintf("the specified number, or \"all\" to show information on all active segments");
+		DebugPrintf("the specified number, or \"all\" to show information on all active segments\n");
 		return true;
 	}
 
@@ -1589,9 +1589,11 @@
 		for (uint i = 0; i < _engine->_gamestate->_segMan->_heap.size(); i++)
 			segmentInfo(i);
 	} else {
-		int nr = atoi(argv[1]);
-		if (!segmentInfo(nr))
-			DebugPrintf("Segment %04x does not exist\n", nr);
+		int segmentNr;
+		if (!parseInteger(argv[1], segmentNr))
+			return true;
+		if (!segmentInfo(segmentNr))
+			DebugPrintf("Segment %04xh does not exist\n", segmentNr);
 	}
 
 	return true;
@@ -1604,21 +1606,23 @@
 		DebugPrintf("Usage: %s <segment number>\n", argv[0]);
 		return true;
 	}
+	int segmentNumber;
+	if (!parseInteger(argv[1], segmentNumber))
+		return true;
+	_engine->_gamestate->_segMan->getScript(segmentNumber)->setLockers(0);
 
-	_engine->_gamestate->_segMan->getScript(atoi(argv[1]))->setLockers(0);
-
 	return true;
 }
 
 bool Console::cmdShowMap(int argc, const char **argv) {
 	if (argc != 2) {
-		DebugPrintf("Shows one of the screen maps\n");
+		DebugPrintf("Switches to one of the following screen maps\n");
 		DebugPrintf("Usage: %s <screen map>\n", argv[0]);
 		DebugPrintf("Screen maps:\n");
-		DebugPrintf("- 0: visual map (back buffer)\n");
-		DebugPrintf("- 1: priority map (back buffer)\n");
-		DebugPrintf("- 2: control map (static buffer)\n");
-		DebugPrintf("- 3: display screen (newgui only)\n");
+		DebugPrintf("- 0: visual map\n");
+		DebugPrintf("- 1: priority map\n");
+		DebugPrintf("- 2: control map\n");
+		DebugPrintf("- 3: display screen\n");
 		return true;
 	}
 
@@ -1929,25 +1933,9 @@
 			return true;
 		}
 
-		char *endPtr = 0;
-		int idxLen = strlen(argv[2]);
-		const char *lastChar = argv[2] + idxLen - (idxLen == 0 ? 0 : 1);
+		if (!parseInteger(argv[2], varIndex))
+			return true;
 
-		if ((strncmp(argv[2], "0x", 2) == 0) || (*lastChar == 'h')) {
-			// hexadecimal number
-			varIndex = strtol(argv[2], &endPtr, 16);
-			if ((*endPtr != 0) && (*endPtr != 'h')) {
-				DebugPrintf("Invalid hexadecimal number '%s'\n", argv[2]);
-				return true;
-			}
-		} else {
-			// decimal number
-			varIndex = strtol(argv[2], &endPtr, 10);
-			if (*endPtr != 0) {
-				DebugPrintf("Invalid decimal number '%s'\n", argv[2]);
-				return true;
-			}
-		}
 		if (varIndex < 0) {
 			DebugPrintf("Variable number may not be negative\n");
 			return true;
@@ -3145,6 +3133,29 @@
 	return 0;
 }
 
+bool Console::parseInteger(const char *argument, int &result) {
+	char *endPtr = 0;
+	int idxLen = strlen(argument);
+	const char *lastChar = argument + idxLen - (idxLen == 0 ? 0 : 1);
+
+	if ((strncmp(argument, "0x", 2) == 0) || (*lastChar == 'h')) {
+		// hexadecimal number
+		result = strtol(argument, &endPtr, 16);
+		if ((*endPtr != 0) && (*endPtr != 'h')) {
+			DebugPrintf("Invalid hexadecimal number '%s'\n", argument);
+			return false;
+		}
+	} else {
+		// decimal number
+		result = strtol(argument, &endPtr, 10);
+		if (*endPtr != 0) {
+			DebugPrintf("Invalid decimal number '%s'\n", argument);
+			return false;
+		}
+	}
+	return true;
+}
+
 void Console::printBasicVarInfo(reg_t variable) {
 	int segType = g_sci->getKernel()->findRegType(variable);
 	SegManager *segMan = g_sci->getEngineState()->_segMan;

Modified: scummvm/trunk/engines/sci/console.h
===================================================================
--- scummvm/trunk/engines/sci/console.h	2010-07-07 11:02:11 UTC (rev 50734)
+++ scummvm/trunk/engines/sci/console.h	2010-07-07 14:19:36 UTC (rev 50735)
@@ -146,6 +146,8 @@
 	bool cmdViewActiveObject(int argc, const char **argv);
 	bool cmdViewAccumulatorObject(int argc, const char **argv);
 
+	bool parseInteger(const char *argument, int &result);
+
 	void printBasicVarInfo(reg_t variable);
 
 	bool segmentInfo(int nr);


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