Properly free function script counter (#4269)
* Fixes #3613. * Script functions will now properly reset the script instance counter when the function terminates the script. Thanks to @Tokeiburu!
This commit is contained in:
parent
3dd388ac66
commit
8050f7c84e
@ -4410,6 +4410,15 @@ void run_script_main(struct script_state *st)
|
|||||||
st->bk_st = NULL;
|
st->bk_st = NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (st->stack && st->stack->defsp >= 1 && st->stack->stack_data[st->stack->defsp - 1].type == C_RETINFO) {
|
||||||
|
for (int i = 0; i < st->stack->sp; i++) {
|
||||||
|
if (st->stack->stack_data[i].type == C_RETINFO) { // Grab the first, aka the original
|
||||||
|
st->script = st->stack->stack_data[i].u.ri->script;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Dispose of script.
|
//Dispose of script.
|
||||||
if ((sd = map_id2sd(st->rid))!=NULL)
|
if ((sd = map_id2sd(st->rid))!=NULL)
|
||||||
{ //Restore previous stack and save char.
|
{ //Restore previous stack and save char.
|
||||||
@ -9699,18 +9708,6 @@ BUILDIN_FUNC(end)
|
|||||||
|
|
||||||
st->state = END;
|
st->state = END;
|
||||||
|
|
||||||
if (st->stack->defsp >= 1 && st->stack->stack_data[st->stack->defsp-1].type == C_RETINFO) {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for(i = 0; i < st->stack->sp; i++) {
|
|
||||||
if (st->stack->stack_data[i].type == C_RETINFO) { // Grab the first, aka the original
|
|
||||||
struct script_retinfo *ri = st->stack->stack_data[i].u.ri;
|
|
||||||
st->script = ri->script;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( st->mes_active )
|
if( st->mes_active )
|
||||||
st->mes_active = 0;
|
st->mes_active = 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user