diff --git a/src/map/script.cpp b/src/map/script.cpp index 604274ecde..913e6b19c5 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -4410,6 +4410,15 @@ void run_script_main(struct script_state *st) st->bk_st = NULL; } } 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. if ((sd = map_id2sd(st->rid))!=NULL) { //Restore previous stack and save char. @@ -9699,18 +9708,6 @@ BUILDIN_FUNC(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 ) st->mes_active = 0;