From 58c312d9e9ac5d78e39ee2ddbb40305bba689aec Mon Sep 17 00:00:00 2001 From: uruk Date: Sat, 14 Jun 2014 20:13:08 +0200 Subject: CGE2: Implement snReach() and connected functions. --- engines/cge2/hero.cpp | 23 ++++++++++++++++++++--- engines/cge2/snail.cpp | 18 ++++++++++++++++-- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/engines/cge2/hero.cpp b/engines/cge2/hero.cpp index f68cf82539..2090d497c1 100644 --- a/engines/cge2/hero.cpp +++ b/engines/cge2/hero.cpp @@ -360,12 +360,29 @@ void Hero::park() { } bool Hero::lower(Sprite * spr) { - warning("STUB: Hero::lower()"); - return false; + return (spr->_pos3D._y + (spr->_siz.y >> 2) < 10); } void Hero::reach(int mode) { - warning("STUB: Hero::reach()"); + Sprite *spr = nullptr; + if (mode >= 4) { + spr = _vm->_vga->_showQ->locate(mode); + if (spr) { + mode = !spr->_flags._east; // 0-1 + if (lower(spr)) // 2-3 + mode += 2; + } + } + // note: insert SNAIL commands in reverse order + _vm->_commandHandler->insertCommand(kCmdPause, -1, 24, nullptr); + _vm->_commandHandler->insertCommand(kCmdSeq, -1, _reachStart + _reachCycle * mode, this); + if (spr) { + _vm->_commandHandler->insertCommand(kCmdWait, -1, -1, this); + _vm->_commandHandler->insertCommand(kCmdWalk, -1, spr->_ref, this); + } + // sequence is not finished, + // now it is just at sprite appear (disappear) point + resetFun(); } void Hero::fun() { diff --git a/engines/cge2/snail.cpp b/engines/cge2/snail.cpp index bf9108df26..f8664b4ea0 100644 --- a/engines/cge2/snail.cpp +++ b/engines/cge2/snail.cpp @@ -559,7 +559,8 @@ void CGE2Engine::snWalk(Sprite *spr, int val) { } void CGE2Engine::snReach(Sprite *spr, int val) { - warning("STUB: CGE2Engine::snReach()"); + if (isHero(spr)) + ((Hero *)spr)->reach(val); } void CGE2Engine::snSound(Sprite *spr, int wav) { @@ -647,7 +648,20 @@ void CommandHandler::addCallback(CommandType com, int ref, int val, CallbackType } void CommandHandler::insertCommand(CommandType com, int ref, int val, void *ptr) { - warning("STUB: CommandHandler::insertCommand()"); + if (ref == -2) + ref = 142 - _vm->_sex; + --_tail; + Command *tailCmd = &_commandList[_tail]; + tailCmd->_commandType = com; + tailCmd->_ref = ref; + tailCmd->_val = val; + tailCmd->_spritePtr = ptr; + tailCmd->_cbType = kNullCB; + if (com == kCmdClear) { + _tail = _head; + _vm->killText(); + _timerExpiry = 0; + } } bool CommandHandler::idle() { -- cgit v1.2.3