From 94c0059f64da9f0f2487b50a975214d1e2285a7e Mon Sep 17 00:00:00 2001 From: mekolat Date: Fri, 13 Nov 2015 09:21:03 -0500 Subject: make crashes more verbose --- src/map/script-call.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'src/map/script-call.cpp') diff --git a/src/map/script-call.cpp b/src/map/script-call.cpp index 0c67ba8..54f6c01 100644 --- a/src/map/script-call.cpp +++ b/src/map/script-call.cpp @@ -583,9 +583,8 @@ void run_func(ScriptState *st) start_sp--; if (start_sp == 0) { - if (battle_config.error_log) - PRINTF("function not found\n"_fmt); - st->state = ScriptEndState::END; + dumb_ptr nd = map_id_is_npc(st->oid); + PRINTF("run_func: function not found! @ %s\n"_fmt, nd ? nd->name : NpcName()); abort(); } } @@ -597,12 +596,8 @@ void run_func(ScriptState *st) if (!st->stack->stack_datav[st->start].is()) { dumb_ptr nd = map_id_is_npc(st->oid); - if(nd) - PRINTF("run_func: not a function or statement! @ %s\n"_fmt, nd->name); - else - PRINTF("run_func: not a function or statement! (no npc)\n"_fmt); - - st->state = ScriptEndState::END; + PRINTF("run_func: not a function or statement! @ %s\n"_fmt, + nd ? nd->name : NpcName()); abort(); } size_t func = st->stack->stack_datav[st->start].get_if()->numi; @@ -670,8 +665,9 @@ void run_func(ScriptState *st) if (st->defsp < 4 || !st->stack->stack_datav[st->defsp - 1].is()) { - PRINTF("script:run_func (return) return without callfunc or callsub!\n"_fmt); - st->state = ScriptEndState::END; + dumb_ptr nd = map_id_is_npc(st->oid); + PRINTF("run_func: return without callfunc or callsub! @ %s\n"_fmt, + nd ? nd->name : NpcName()); abort(); } assert (olddefsp == st->defsp); // pretty sure it hasn't changed yet @@ -766,8 +762,9 @@ void run_script_main(ScriptState *st, Borrowed rootscript) st->state = ScriptEndState::ZERO; if (st->freeloop != 1 && gotocount > 0 && (--gotocount) <= 0) { - PRINTF("run_script: infinity loop !\n"_fmt); - st->state = ScriptEndState::END; + dumb_ptr nd = map_id_is_npc(st->oid); + PRINTF("run_script: infinity loop! @ %s\n"_fmt, + nd ? nd->name : NpcName()); abort(); } } @@ -824,12 +821,12 @@ void run_script_main(ScriptState *st, Borrowed rootscript) } } abort(); - break; } if (st->freeloop != 1 && cmdcount > 0 && (--cmdcount) <= 0) { - PRINTF("run_script: infinity loop !\n"_fmt); - st->state = ScriptEndState::END; + dumb_ptr nd = map_id_is_npc(st->oid); + PRINTF("run_script: infinity loop! @ %s\n"_fmt, + nd ? nd->name : NpcName()); abort(); } } -- cgit v1.2.3-60-g2f50