diff options
Diffstat (limited to 'saga/sfuncs.cpp')
-rw-r--r-- | saga/sfuncs.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp index ce458c0640..0d413ac18b 100644 --- a/saga/sfuncs.cpp +++ b/saga/sfuncs.cpp @@ -65,7 +65,7 @@ void Script::setupScriptFuncList(void) { OPCODE(SF_gotoScene), OPCODE(SF_setObjImage), OPCODE(SF_setObjName), - OPCODE(SF_getObjName), + OPCODE(SF_getObjImage), OPCODE(SF_getNumber), OPCODE(SF_openDoor), OPCODE(SF_closeDoor), @@ -365,19 +365,30 @@ int Script::SF_setObjImage(SCRIPTFUNC_PARAMS) { // Script function #18 (0x12) int Script::SF_setObjName(SCRIPTFUNC_PARAMS) { - for (int i = 0; i < nArgs; i++) - thread->pop(); + SDataWord_T obj_param = thread->pop(); + SDataWord_T name_param = thread->pop(); + + int index = obj_param & 0x1FFF; + + if (index >= ARRAYSIZE(ObjectTable)) { + return FAILURE; + } - debug(1, "stub: SF_setObjName(), %d args", nArgs); + ObjectTable[index].nameIndex = name_param; return SUCCESS; } // Script function #19 (0x13) -int Script::SF_getObjName(SCRIPTFUNC_PARAMS) { - for (int i = 0; i < nArgs; i++) - thread->pop(); +int Script::SF_getObjImage(SCRIPTFUNC_PARAMS) { + SDataWord_T param = thread->pop(); + int index = param & 0x1FFF; + + if (index >= ARRAYSIZE(ObjectTable)) { + thread->retVal = 0; + return FAILURE; + } - debug(1, "stub: SF_getObjName(), %d args", nArgs); + thread->retVal = ObjectTable[index].spritelistRn; return SUCCESS; } |