From 18abe168cedb8a332d69dabe661c0edf9847e229 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sun, 7 Nov 2004 15:11:04 +0000 Subject: Unstubbed SF_dropObject(). (Untested) svn-id: r15724 --- saga/sfuncs.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'saga') diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp index e1e0450e89..19f2e13262 100644 --- a/saga/sfuncs.cpp +++ b/saga/sfuncs.cpp @@ -158,6 +158,10 @@ int Script::SF_takeObject(SCRIPTFUNC_PARAMS) { SDataWord_T param = thread->pop(); int index = param & 0x1FFF; + if (index >= ARRAYSIZE(ObjectTable)) { + return FAILURE; + } + if (ObjectTable[index].sceneIndex != -1) { ObjectTable[index].sceneIndex = -1; _vm->_interface->addToInventory(index); @@ -551,10 +555,26 @@ int Script::SF_sceneEq(SCRIPTFUNC_PARAMS) { // Script function #32 (0x20) int Script::SF_dropObject(SCRIPTFUNC_PARAMS) { - for (int i = 0; i < nArgs; i++) - thread->pop(); + SDataWord_T obj_param = thread->pop(); + SDataWord_T sprite_param = thread->pop(); + SDataWord_T x_param = thread->pop(); + SDataWord_T y_param = thread->pop(); + + int index = obj_param & 0x1FFF; + + if (index >= ARRAYSIZE(ObjectTable)) { + return FAILURE; + } + + if (ObjectTable[index].sceneIndex == -1) { + _vm->_interface->removeFromInventory(index); + } + + ObjectTable[index].sceneIndex = _vm->_scene->currentSceneNumber(); + ObjectTable[index].spritelistRn = 9 + sprite_param; + ObjectTable[index].x = x_param; + ObjectTable[index].y = y_param; - debug(1, "stub: SF_dropObject(), %d args", nArgs); return SUCCESS; } -- cgit v1.2.3