[Scummvm-cvs-logs] SF.net SVN: scummvm: [28600] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Tue Aug 14 01:17:17 CEST 2007


Revision: 28600
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28600&view=rev
Author:   peres001
Date:     2007-08-13 16:17:17 -0700 (Mon, 13 Aug 2007)

Log Message:
-----------
Changed Table to return 0 instead of -1 when lookup fails. Lookup already yields 1-based values when the item is found.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/animation.cpp
    scummvm/trunk/engines/parallaction/commands.cpp
    scummvm/trunk/engines/parallaction/debug.cpp
    scummvm/trunk/engines/parallaction/dialogue.cpp
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/zone.cpp

Modified: scummvm/trunk/engines/parallaction/animation.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/animation.cpp	2007-08-13 22:59:13 UTC (rev 28599)
+++ scummvm/trunk/engines/parallaction/animation.cpp	2007-08-13 23:17:17 UTC (rev 28600)
@@ -94,7 +94,7 @@
 				vD0->_type = ((4 + _objectsNames->lookup(_tokens[2])) << 16) & 0xFFFF0000;
 			}
 			int16 _si = _zoneTypeNames->lookup(_tokens[1]);
-			if (_si != -1) {
+			if (_si != Table::notFound) {
 				vD0->_type |= 1 << (_si-1);
 				if (((vD0->_type & 0xFFFF) != kZoneNone) && ((vD0->_type & 0xFFFF) != kZoneCommand)) {
 					parseZoneTypeBlock(script, vD0);
@@ -295,8 +295,6 @@
 	int16 _si = _instructionNames->lookup(_tokens[0]);
 	inst->_index = _si;
 
-//	printf("token[0] = %s (%i)\n", _tokens[0], inst->_index);
-
 	switch (inst->_index) {
 	case INST_ON:	// on
 	case INST_OFF:	// off
@@ -392,9 +390,10 @@
 		break;
 
 	case INST_CALL: {	// call
-		int16 _ax = _callableNames->lookup(_tokens[1]);
-		inst->_opBase._index = _ax - 1;
-		if (_ax - 1 < 0) exit(0);
+		int index = _callableNames->lookup(_tokens[1]);
+		if (index == Table::notFound)
+			error("unknown callable '%s'", _tokens[1]);
+		inst->_opBase._index = index - 1;
 	}
 	break;
 

Modified: scummvm/trunk/engines/parallaction/commands.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/commands.cpp	2007-08-13 22:59:13 UTC (rev 28599)
+++ scummvm/trunk/engines/parallaction/commands.cpp	2007-08-13 23:17:17 UTC (rev 28600)
@@ -48,7 +48,7 @@
 #define CMD_STOP			16
 
 DECLARE_COMMAND_PARSER(Flags) {
-	if (_globalTable->lookup(_tokens[1]) == -1) {
+	if (_globalTable->lookup(_tokens[1]) == Table::notFound) {
 		do {
 			char _al = _localFlagNames->lookup(_tokens[_cmdParseCtxt.nextToken]);
 			_cmdParseCtxt.nextToken++;

Modified: scummvm/trunk/engines/parallaction/debug.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/debug.cpp	2007-08-13 22:59:13 UTC (rev 28599)
+++ scummvm/trunk/engines/parallaction/debug.cpp	2007-08-13 23:17:17 UTC (rev 28600)
@@ -116,7 +116,7 @@
 		DebugPrintf("give <item name>\n");
 	} else {
 		int index = _vm->_objectsNames->lookup(argv[1]);
-		if (index != -1)
+		if (index != Table::notFound)
 			_vm->addInventoryItem(index + 4);
 		else
 			DebugPrintf("invalid item name '%s'\n", argv[1]);

Modified: scummvm/trunk/engines/parallaction/dialogue.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/dialogue.cpp	2007-08-13 22:59:13 UTC (rev 28599)
+++ scummvm/trunk/engines/parallaction/dialogue.cpp	2007-08-13 23:17:17 UTC (rev 28600)
@@ -151,7 +151,7 @@
 			int16 index = forwards.lookup(answer->_following._name);
 			free(answer->_following._name);
 
-			if (index == -1)
+			if (index == Table::notFound)
 				answer->_following._question = 0;
 			else
 				answer->_following._question = dialogue->_questions[index - 1];

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2007-08-13 22:59:13 UTC (rev 28599)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2007-08-13 23:17:17 UTC (rev 28600)
@@ -837,13 +837,13 @@
 
 }
 
-int16 Table::lookup(const char* s) {
+int Table::lookup(const char* s) {
 
 	for (uint16 i = 0; i < _used; i++) {
 		if (!scumm_stricmp(_data[i], s)) return i + 1;
 	}
 
-	return -1;
+	return notFound;
 }
 
 } // namespace Parallaction

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2007-08-13 22:59:13 UTC (rev 28599)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2007-08-13 23:17:17 UTC (rev 28600)
@@ -275,9 +275,13 @@
 
 	~Table();
 
+	enum {
+		notFound = 0
+	};
+
 	void addData(const char* s);
 
-	int16 lookup(const char* s);
+	int lookup(const char* s);
 };
 
 struct BackgroundInfo {

Modified: scummvm/trunk/engines/parallaction/zone.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/zone.cpp	2007-08-13 22:59:13 UTC (rev 28599)
+++ scummvm/trunk/engines/parallaction/zone.cpp	2007-08-13 23:17:17 UTC (rev 28600)
@@ -81,7 +81,7 @@
 				z->_type = (4 + _objectsNames->lookup(_tokens[2])) << 16;
 			}
 			int16 _si = _zoneTypeNames->lookup(_tokens[1]);
-			if (_si != -1) {
+			if (_si != Table::notFound) {
 				z->_type |= 1 << (_si - 1);
 				parseZoneTypeBlock(script, z);
 				continue;


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