From 07b67fe44b20f8f1c9dcdf659f5e2666d69834f4 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Wed, 28 Jul 2010 19:03:49 +0000 Subject: SCI: Fix using the parser in SCI Fan Games Get a pointer to the said spec instead of copying to a buffer. The fan games use a said spec with size < 64. Also, make said() take a const pointer as the spec cannot change. Thanks to waltervn and wjp. svn-id: r51432 --- engines/sci/graphics/menu.cpp | 10 +++++++--- engines/sci/parser/said.cpp | 4 ++-- engines/sci/parser/vocabulary.h | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/graphics/menu.cpp b/engines/sci/graphics/menu.cpp index 92c0e92f48..120c43f379 100644 --- a/engines/sci/graphics/menu.cpp +++ b/engines/sci/graphics/menu.cpp @@ -397,7 +397,6 @@ reg_t GfxMenu::kernelSelect(reg_t eventObject, bool pauseSound) { GuiMenuItemEntry *itemEntry = NULL; bool forceClaimed = false; EngineState *s; - byte saidSpec[64]; switch (eventType) { case SCI_EVENT_KEYBOARD: @@ -437,8 +436,13 @@ reg_t GfxMenu::kernelSelect(reg_t eventObject, bool pauseSound) { itemEntry = *itemIterator; if (!itemEntry->saidVmPtr.isNull()) { - // TODO: get a pointer to saidVmPtr or make said() work on VmPtrs - _segMan->memcpy(saidSpec, itemEntry->saidVmPtr, 64); + byte *saidSpec = _segMan->derefBulkPtr(itemEntry->saidVmPtr, 0); + + if (!saidSpec) { + warning("Could not dereference saidSpec"); + continue; + } + if (said(s, saidSpec, 0) != SAID_NO_MATCH) break; } diff --git a/engines/sci/parser/said.cpp b/engines/sci/parser/said.cpp index 0411952f2a..9c07be2dff 100644 --- a/engines/sci/parser/said.cpp +++ b/engines/sci/parser/said.cpp @@ -657,7 +657,7 @@ static bool buildSaidTree() { return true; } -static int said_parse_spec(byte *spec) { +static int said_parse_spec(const byte *spec) { int nextitem; said_token = 0; @@ -996,7 +996,7 @@ static int augment_parse_nodes(ParseTreeNode *parseT, ParseTreeNode *saidT) { /**** Main code ****/ /*******************/ -int said(EngineState *s, byte *spec, bool verbose) { +int said(EngineState *s, const byte *spec, bool verbose) { int retval; Vocabulary *voc = g_sci->getVocabulary(); diff --git a/engines/sci/parser/vocabulary.h b/engines/sci/parser/vocabulary.h index a20508e191..d4df8af715 100644 --- a/engines/sci/parser/vocabulary.h +++ b/engines/sci/parser/vocabulary.h @@ -345,7 +345,7 @@ void vocab_dump_parse_tree(const char *tree_name, ParseTreeNode *nodes); * @param verbose Whether to display the parse tree after building it * @return 1 on a match, 0 otherwise */ -int said(EngineState *s, byte *spec, bool verbose); +int said(EngineState *s, const byte *spec, bool verbose); } // End of namespace Sci -- cgit v1.2.3