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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon May 18 17:07:52 CEST 2009


Revision: 40691
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40691&view=rev
Author:   fingolfin
Date:     2009-05-18 15:07:51 +0000 (Mon, 18 May 2009)

Log Message:
-----------
SCI: Removed SCI_SIMPLE_SAID_CODE and the associated heavily bitrotted code

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kstring.cpp
    scummvm/trunk/engines/sci/engine/scriptdebug.cpp
    scummvm/trunk/engines/sci/engine/state.h
    scummvm/trunk/engines/sci/vocabulary.cpp
    scummvm/trunk/engines/sci/vocabulary.h

Modified: scummvm/trunk/engines/sci/engine/kstring.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kstring.cpp	2009-05-18 15:07:31 UTC (rev 40690)
+++ scummvm/trunk/engines/sci/engine/kstring.cpp	2009-05-18 15:07:51 UTC (rev 40691)
@@ -77,42 +77,7 @@
 /* Parser */
 /**********/
 
-#ifdef SCI_SIMPLE_SAID_CODE
-int vocab_match_simple(EngineState *s, HeapPtr addr) {
-	int nextitem;
-	int listpos = 0;
 
-	if (!s->parser_valid)
-		return SAID_NO_MATCH;
-
-	if (s->parser_valid == 2) { /* debug mode: sim_said */
-		do {
-			sciprintf("DEBUGMATCH: ");
-			nextitem = s->heap[addr++];
-
-			if (nextitem < 0xf0) {
-				nextitem = nextitem << 8 | s->heap[addr++];
-				if (s->parser_nodes[listpos].type
-				        || nextitem != s->parser_nodes[listpos++].content.value)
-					return SAID_NO_MATCH;
-			} else {
-
-				if (nextitem == 0xff)
-					return (s->parser_nodes[listpos++].type == -1) ? SAID_FULL_MATCH : SAID_NO_MATCH; /* Finished? */
-
-				if (s->parser_nodes[listpos].type != 1
-				        || nextitem != s->parser_nodes[listpos++].content.value)
-					return SAID_NO_MATCH;
-
-			}
-		} while (42);
-	} else { /* normal simple match mode */
-		return vocab_simple_said_test(s, addr);
-	}
-}
-#endif /* SCI_SIMPLE_SAID_CODE */
-
-
 reg_t kSaid(EngineState *s, int funct_nr, int argc, reg_t *argv) {
 	reg_t heap_said_block = argv[0];
 	byte *said_block;
@@ -137,31 +102,10 @@
 		return NULL_REG;
 	}
 
-#ifdef SCI_SIMPLE_SAID_CODE
+	new_lastmatch = said(s, said_block, (s->debug_mode & (1 << SCIkPARSER_NR)));
+	if (new_lastmatch  != SAID_NO_MATCH) { /* Build and possibly display a parse tree */
 
-	s->acc = 0;
-
-	if (s->parser_lastmatch_word == SAID_FULL_MATCH)
-		return; /* Matched before; we're not doing any more matching work today. */
-
-	if ((new_lastmatch = vocab_match_simple(s, said_block)) != SAID_NO_MATCH) {
-
 		if (s->debug_mode & (1 << SCIkPARSER_NR))
-			sciprintf("Match (simple).\n");
-		s->acc = 1;
-
-		if (new_lastmatch == SAID_FULL_MATCH) /* Finished matching? */
-			PUT_SELECTOR(s->parser_event, claimed, 1); /* claim event */
-		/* otherwise, we have a partial match: Set new lastmatch word in all cases. */
-
-		s->parser_lastmatch_word = new_lastmatch;
-	}
-
-#else /* !SCI_SIMPLE_SAID_CODE */
-	if ((new_lastmatch = said(s, said_block, (s->debug_mode & (1 << SCIkPARSER_NR))))
-	        != SAID_NO_MATCH) { /* Build and possibly display a parse tree */
-
-		if (s->debug_mode & (1 << SCIkPARSER_NR))
 			sciprintf("Match.\n");
 
 		s->r_acc = make_reg(0, 1);
@@ -175,7 +119,6 @@
 		s->parser_lastmatch_word = SAID_NO_MATCH;
 		return NULL_REG;
 	}
-#endif /* !SCI_SIMPLE_SAID_CODE */
 	return s->r_acc;
 }
 
@@ -275,10 +218,6 @@
 		                           s->parser_rules))
 			syntax_fail = 1; /* Building a tree failed */
 
-#ifdef SCI_SIMPLE_SAID_CODE
-		vocab_build_simple_parse_tree(&(s->parser_nodes[0]), words);
-#endif /* SCI_SIMPLE_SAID_CODE */
-
 		if (syntax_fail) {
 
 			s->r_acc = make_reg(0, 1);
@@ -292,10 +231,8 @@
 		} else {
 			s->parser_valid = 1;
 			PUT_SEL32V(event, claimed, 0);
-#ifndef SCI_SIMPLE_SAID_CODE
 			if (s->debug_mode & (1 << SCIkPARSER_NR))
 				vocab_dump_parse_tree("Parse-tree", s->parser_nodes);
-#endif /* !SCI_SIMPLE_SAID_CODE */
 		}
 
 	} else {

Modified: scummvm/trunk/engines/sci/engine/scriptdebug.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-05-18 15:07:31 UTC (rev 40690)
+++ scummvm/trunk/engines/sci/engine/scriptdebug.cpp	2009-05-18 15:07:51 UTC (rev 40691)
@@ -3062,14 +3062,6 @@
 			                 "SEE ALSO\n"
 			                 "  debuglog.1, sfx_debuglog.1\n");
 
-#ifdef SCI_SIMPLE_SAID_CODE
-			con_hook_command(c_sim_parse, "simparse", "s*", "Simulates a parsed entity.\n\nUSAGE\n  Call this"
-			                 " function with a list of\n  Said operators, words, and word group"
-			                 "\n  numbers to match Said() specs\n  that look identical.\n"
-			                 "\n  Note that opening braces and\n  everything behind them are\n"
-			                 "\n  removed from all non-operator\n  parameter tokens.\n"
-			                 "\n  simparse without parameters\n  removes the entity.\n");
-#endif /* SCI_SIMPLE_SAID_CODE */
 #ifdef GFXW_DEBUG_WIDGETS
 			con_hook_command(c_gfx_print_widget, "gfx_print_widget", "i*", "If called with no parameters, it\n  shows which widgets are active.\n"
 			                 "  With parameters, it lists the\n  widget corresponding to the\n  numerical index specified (for\n  each parameter).");

Modified: scummvm/trunk/engines/sci/engine/state.h
===================================================================
--- scummvm/trunk/engines/sci/engine/state.h	2009-05-18 15:07:31 UTC (rev 40690)
+++ scummvm/trunk/engines/sci/engine/state.h	2009-05-18 15:07:51 UTC (rev 40691)
@@ -228,7 +228,7 @@
 	reg_t parser_event; /**< The event passed to Parse() and later used by Said() */
 	Script *script_000;  /**< script 000, e.g. for globals */
 	
-	uint16 currentRoomNumber() { return KP_UINT(script_000->locals_block->_locals[13]); }
+	uint16 currentRoomNumber() const { return KP_UINT(script_000->locals_block->_locals[13]); }
 
 	int parser_lastmatch_word; /**< Position of the input word the parser last matched on, or SAID_NO_MATCH */
 

Modified: scummvm/trunk/engines/sci/vocabulary.cpp
===================================================================
--- scummvm/trunk/engines/sci/vocabulary.cpp	2009-05-18 15:07:31 UTC (rev 40690)
+++ scummvm/trunk/engines/sci/vocabulary.cpp	2009-05-18 15:07:51 UTC (rev 40691)
@@ -336,102 +336,6 @@
 	sciprintf("\n");
 }
 
-
-#ifdef SCI_SIMPLE_SAID_CODE
-
-static const short _related_words[][2] = { // 0 is backwards, 1 is forward
-	{0x800, 0x180}, // preposition
-	{0x000, 0x180}, // article
-	{0x000, 0x180}, // adjective
-	{0x800, 0x000}, // pronoun
-	{0x800, 0x180}, // noun
-	{0x000, 0x800}, // auxiliary verb
-	{0x800, 0x800}, // adverb
-	{0x000, 0x180}, // verb
-	{0x000, 0x180} // number
-};
-
-int vocab_build_simple_parse_tree(parse_tree_node_t *nodes, WordMap &words) {
-	int i, length, pos = 0;
-
-	for (i = 0; i < words.size(); ++i) {
-		if (words[i]._class != VOCAB_CLASS_ANYWORD) {
-			nodes[pos].type = words[i]._class;
-			nodes[pos].content.value = words[i]._group;
-			pos += 2; // Link information is filled in below
-		}
-	}
-	nodes[pos].type = -1; // terminate
-	length = pos >> 1;
-
-	// now find all referenced words
-#ifdef SCI_SIMPLE_SAID_DEBUG
-	sciprintf("Semantic references:\n");
-#endif
-
-	for (i = 0; i < length; i++) {
-		int j;
-		int searchmask;
-		int type;
-
-		pos = (i << 1);
-		type = sci_ffs(nodes[pos].type);
-
-		if (type) {
-			int found = -1;
-
-			type -= 5; // 1 because ffs starts counting at 1, 4 because nodes[pos].type is a nibble off
-			if (type < 0)
-				type = 0;
-#ifdef SCI_SIMPLE_SAID_DEBUG
-			sciprintf("#%d: Word %04x: type %04x\n", i, nodes[pos].content.value, type);
-#endif
-
-			// search backwards
-			searchmask = _related_words[type][0];
-			if (searchmask) {
-				for (j = i - 1; j >= 0; j--)
-					if (nodes[j << 1].type & searchmask) {
-						found = j << 1;
-						break;
-					}
-			}
-			nodes[pos+1].content.branches[0] = found;
-#ifdef SCI_SIMPLE_SAID_DEBUG
-			if (found > -1)
-				sciprintf("  %d <\n", found >> 1);
-#endif
-
-			// search forward
-			found = -1;
-			searchmask = _related_words[type][1];
-			if (searchmask) {
-				for (j = i + 1; j < length; j++)
-					if (nodes[j << 1].type & searchmask) {
-						found = j << 1;
-						break;
-					}
-			}
-#ifdef SCI_SIMPLE_SAID_DEBUG
-			if (found > -1)
-				sciprintf("  > %d\n", found >> 1);
-#endif
-		} else {
-#ifdef SCI_SIMPLE_SAID_DEBUG
-			sciprintf("#%d: Untypified word\n", i); /* Weird, but not fatal */
-#endif
-			nodes[pos + 1].content.branches[0] = -1;
-			nodes[pos + 1].content.branches[1] = -1;
-		}
-	}
-#ifdef SCI_SIMPLE_SAID_DEBUG
-	sciprintf("/Semantic references.\n");
-#endif
-
-	return 0;
-}
-#endif
-
 bool vocab_tokenize_string(ResultWordList &retval, const char *sentence, const WordMap &words,
 	const SuffixList &suffixes, char **error) {
 	const char *lastword = sentence;

Modified: scummvm/trunk/engines/sci/vocabulary.h
===================================================================
--- scummvm/trunk/engines/sci/vocabulary.h	2009-05-18 15:07:31 UTC (rev 40690)
+++ scummvm/trunk/engines/sci/vocabulary.h	2009-05-18 15:07:51 UTC (rev 40691)
@@ -38,7 +38,6 @@
 class ResourceManager;
 
 /*#define VOCABULARY_DEBUG */
-/*#define SCI_SIMPLE_SAID_CODE */ /* Whether the simplified Said() matching should be used */
 /*#define SCI_SIMPLE_SAID_DEBUG */ /* uncomment to enable simple said debugging */
 
 


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