[gamecode] Save return ptr for chained calls

It turns out the return pointer still needs to be saved even when a
builtin sets up a chain call to progs, but rather than the pointer being
simply restored, it needs to be saved in the call stack exactly as if
the function was called directly by progs. This fixes the invalid self
issue quite thoroughly: parameter state seems to be correct across all
calls now.

I should set up an automated test now that I know and understand the
situation.
This commit is contained in:
Bill Currie 2022-01-31 23:32:38 +09:00
parent 92711e778c
commit 712d800491

View file

@ -457,6 +457,8 @@ PR_CallFunction (progs_t *pr, pr_func_t fnum, pr_type_t *return_ptr)
f->func (pr);
if (builtin_depth == pr->pr_depth) {
pr->pr_return = saved_return;
} else if (builtin_depth < pr->pr_depth) {
pr->pr_stack[builtin_depth].return_ptr = saved_return;
}
return 0;
} else {