diff options
author | uruk | 2014-06-19 11:43:01 +0200 |
---|---|---|
committer | uruk | 2014-06-19 11:43:01 +0200 |
commit | ff99cb9658eacdcf9bf0cafb22b0529e76a4b3f9 (patch) | |
tree | e88080981ab58cc57b6d7709acda6103cb61658d | |
parent | 56c7df46d3f713bdf8817217807570bcf0d976c9 (diff) | |
download | scummvm-rg350-ff99cb9658eacdcf9bf0cafb22b0529e76a4b3f9.tar.gz scummvm-rg350-ff99cb9658eacdcf9bf0cafb22b0529e76a4b3f9.tar.bz2 scummvm-rg350-ff99cb9658eacdcf9bf0cafb22b0529e76a4b3f9.zip |
CGE2: Implement Sprite::works().
Now Anna is also reachable/playable.
-rw-r--r-- | engines/cge2/hero.cpp | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/engines/cge2/hero.cpp b/engines/cge2/hero.cpp index 2090d497c1..0958563395 100644 --- a/engines/cge2/hero.cpp +++ b/engines/cge2/hero.cpp @@ -563,20 +563,38 @@ void Hero::operator--() { } bool Sprite::works(Sprite *spr) { - //if (!spr || !spr->_ext) - // return false; - - //CommandHandler::Command *c = spr->_ext->_take; - //if (c != NULL) { - // c += spr->_takePtr; - // if (c->_ref == _ref) - // if (c->_commandType != kCmdLabel || (c->_val == 0 || c->_val == _vm->_now)) - // return true; - //} - - warning("STUB: Sprite::works()"); - - return false; + if (!spr || !spr->_ext) + return false; + + bool ok = false; + + Action a = _vm->_heroTab[_vm->_sex]->_ptr->action(); + CommandHandler::Command *ct = spr->_ext->_actions[a]; + if (ct) { + int i = spr->_actionCtrl[a]._ptr; + int n = spr->_actionCtrl[a]._cnt; + while (i < n && !ok) { + CommandHandler::Command *c = &ct[i++]; + if (c->_commandType != kCmdUse) + break; + ok = (c->_ref == _ref); + if (c->_val > 255) { + if (ok) { + int p = spr->labVal(a, c->_val >> 8); + if (p >= 0) + spr->_actionCtrl[a]._ptr = p; + else + ok = false; + } + } else { + if (c->_val && c->_val != _vm->_now) + ok = false; + break; + } + } + } + + return ok; } } // End of namespace CGE2 |