aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--saga/script.h2
-rw-r--r--saga/sfuncs.cpp27
2 files changed, 20 insertions, 9 deletions
diff --git a/saga/script.h b/saga/script.h
index 19bb4122d5..3cf7c37358 100644
--- a/saga/script.h
+++ b/saga/script.h
@@ -270,7 +270,7 @@ private:
int SF_gotoScene(SCRIPTFUNC_PARAMS);
int SF_setObjImage(SCRIPTFUNC_PARAMS);
int SF_setObjName(SCRIPTFUNC_PARAMS);
- int SF_getObjName(SCRIPTFUNC_PARAMS);
+ int SF_getObjImage(SCRIPTFUNC_PARAMS);
int SF_getNumber(SCRIPTFUNC_PARAMS);
int SF_openDoor(SCRIPTFUNC_PARAMS);
int SF_closeDoor(SCRIPTFUNC_PARAMS);
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;
}