CGE2: Implement snReach() and connected functions.

This commit is contained in:
uruk 2014-06-14 20:13:08 +02:00
parent 3d63184fee
commit 58c312d9e9
2 changed files with 36 additions and 5 deletions

View File

@ -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() {

View File

@ -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() {