From 2efaedb29b3436c1eae03dad0fba59e2c72747d4 Mon Sep 17 00:00:00 2001 From: Arnaud Boutonné Date: Fri, 1 Oct 2010 06:16:24 +0000 Subject: HUGO: Fix crash using mouse Fix crash when clicking on objects without a default 'TAKE' action (like the hero, the eyes and the bat in the first screen) svn-id: r52962 --- engines/hugo/engine.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/engines/hugo/engine.cpp b/engines/hugo/engine.cpp index ab31f5da93..28ffd40649 100644 --- a/engines/hugo/engine.cpp +++ b/engines/hugo/engine.cpp @@ -770,12 +770,10 @@ bool HugoEngine::findObjectSpace(object_t *obj, int16 *destx, int16 *desty) { // Search background command list for this screen for supplied object. // Return first associated verb (not "look") or NULL if none found. char *HugoEngine::useBG(char *name) { - int i; - objectList_t p = _backgroundObjects[*_screen_p]; - debugC(1, kDebugEngine, "useBG(%s)", name); - for (i = 0; *_arrayVerbs[p[i].verbIndex]; i++) + objectList_t p = _backgroundObjects[*_screen_p]; + for (int i = 0; *_arrayVerbs[p[i].verbIndex]; i++) if ((name == _arrayNouns[p[i].nounIndex][0] && p[i].verbIndex != _look) && ((p[i].roomState == DONT_CARE) || (p[i].roomState == _screenStates[*_screen_p]))) @@ -799,12 +797,16 @@ void HugoEngine::useObject(int16 objId) { // Get or use objid directly if ((obj->genericCmd & TAKE) || obj->objValue) // Get collectible item sprintf(_line, "%s %s", _arrayVerbs[_take][0], _arrayNouns[obj->nounIndex][0]); - else if (obj->cmdIndex != 0) // Use non-collectible item if able + else if (obj->genericCmd & LOOK) // Look item + sprintf(_line, "%s %s", _arrayVerbs[_look][0], _arrayNouns[obj->nounIndex][0]); + else if (obj->genericCmd & DROP) // Drop item + sprintf(_line, "%s %s", _arrayVerbs[_drop][0], _arrayNouns[obj->nounIndex][0]); + else if (obj->cmdIndex != 0) // Use non-collectible item if able sprintf(_line, "%s %s", _arrayVerbs[_cmdList[obj->cmdIndex][1].verbIndex][0], _arrayNouns[obj->nounIndex][0]); else if ((verb = useBG(_arrayNouns[obj->nounIndex][0])) != NULL) sprintf(_line, "%s %s", verb, _arrayNouns[obj->nounIndex][0]); else - return; // Can't use object directly + return; // Can't use object directly } else { // Use status.objid on objid // Default to first cmd verb -- cgit v1.2.3