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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Tue Jun 1 00:57:05 CEST 2010


Revision: 49364
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49364&view=rev
Author:   thebluegr
Date:     2010-05-31 22:57:05 +0000 (Mon, 31 May 2010)

Log Message:
-----------
Added a new console command, verify_scripts, used for sanity checking of SCI1.1-SCI2.1 game scripts

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-05-31 22:41:46 UTC (rev 49363)
+++ scummvm/trunk/engines/sci/console.cpp	2010-05-31 22:57:05 UTC (rev 49364)
@@ -105,6 +105,7 @@
 	DCmd_Register("resource_types",		WRAP_METHOD(Console, cmdResourceTypes));
 	DCmd_Register("list",				WRAP_METHOD(Console, cmdList));
 	DCmd_Register("hexgrep",			WRAP_METHOD(Console, cmdHexgrep));
+	DCmd_Register("verify_scripts",		WRAP_METHOD(Console, cmdVerifyScripts));
 	// Game
 	DCmd_Register("save_game",			WRAP_METHOD(Console, cmdSaveGame));
 	DCmd_Register("restore_game",		WRAP_METHOD(Console, cmdRestoreGame));
@@ -324,6 +325,7 @@
 	DebugPrintf(" resource_types - Shows the valid resource types\n");
 	DebugPrintf(" list - Lists all the resources of a given type\n");
 	DebugPrintf(" hexgrep - Searches some resources for a particular sequence of bytes, represented as hexadecimal numbers\n");
+	DebugPrintf(" verify_scripts - Performs sanity checks on SCI1.1-SCI2.1 game scripts (e.g. if they're up to 64KB in total)\n");
 	DebugPrintf("\n");
 	DebugPrintf("Game:\n");
 	DebugPrintf(" save_game - Saves the current game state to the hard disk\n");
@@ -811,6 +813,40 @@
 	return true;
 }
 
+bool Console::cmdVerifyScripts(int argc, const char **argv) {
+	if (getSciVersion() < SCI_VERSION_1_1) {
+		DebugPrintf("This script check is only meant for SCI1.1-SCI2.1 games\n");
+		return true;
+	}
+
+	Common::List<ResourceId> *resources = _engine->getResMan()->listResources(kResourceTypeScript);
+	sort(resources->begin(), resources->end(), ResourceIdLess());
+	Common::List<ResourceId>::iterator itr = resources->begin();
+
+	DebugPrintf("%d SCI1.1-SCI2.1 scripts found, performing sanity checks...\n", resources->size());
+
+	Resource *script, *heap;
+	while (itr != resources->end()) {
+		script = _engine->getResMan()->findResource(*itr, false);
+		if (!script)
+			DebugPrintf("Error: script %d couldn't be loaded\n", itr->number);
+
+		heap = _engine->getResMan()->findResource(*itr, false);
+		if (!heap)
+			DebugPrintf("Error: script %d doesn't have a corresponding heap\n", itr->number);
+
+		if (script && heap && (script->size + heap->size > 65535))
+			DebugPrintf("Error: script and heap %d together are larger than 64KB (%d bytes)\n",
+			itr->number, script->size + heap->size);
+
+		++itr;
+	}
+
+	DebugPrintf("SCI1.1-SCI2.1 script check finished\n");
+
+	return true;
+}
+
 bool Console::cmdList(int argc, const char **argv) {
 	if (argc < 2) {
 		DebugPrintf("Lists all the resources of a given type\n");

Modified: scummvm/trunk/engines/sci/console.h
===================================================================
--- scummvm/trunk/engines/sci/console.h	2010-05-31 22:41:46 UTC (rev 49363)
+++ scummvm/trunk/engines/sci/console.h	2010-05-31 22:57:05 UTC (rev 49364)
@@ -73,6 +73,7 @@
 	bool cmdResourceTypes(int argc, const char **argv);
 	bool cmdList(int argc, const char **argv);
 	bool cmdHexgrep(int argc, const char **argv);
+	bool cmdVerifyScripts(int argc, const char **argv);
 	// Game
 	bool cmdSaveGame(int argc, const char **argv);
 	bool cmdRestoreGame(int argc, const char **argv);


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