summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWushin <pasekei@gmail.com>2015-05-23 15:57:50 -0500
committerWushin <pasekei@gmail.com>2015-05-23 15:57:50 -0500
commitbf8c3eb1475a041e31cb2f19a24f8a08a5633b32 (patch)
tree7db3afc5f050564d9dcbdbac25d18563a879f666
parent29ce27e1557404b6cd03eaab2367c5a698e6ab44 (diff)
parentab836451986e596d66df6aadd6af7a955ae8ff4e (diff)
downloadtmwa-bf8c3eb1475a041e31cb2f19a24f8a08a5633b32.tar.gz
tmwa-bf8c3eb1475a041e31cb2f19a24f8a08a5633b32.tar.bz2
tmwa-bf8c3eb1475a041e31cb2f19a24f8a08a5633b32.tar.xz
tmwa-bf8c3eb1475a041e31cb2f19a24f8a08a5633b32.zip
Merge pull request #96 from mekolat/debug
add debug info for crash
-rw-r--r--src/map/script-call.cpp28
-rw-r--r--src/map/script-fun.cpp8
2 files changed, 21 insertions, 15 deletions
diff --git a/src/map/script-call.cpp b/src/map/script-call.cpp
index 7092dbc..83b6f24 100644
--- a/src/map/script-call.cpp
+++ b/src/map/script-call.cpp
@@ -586,8 +586,7 @@ void run_func(ScriptState *st)
if (battle_config.error_log)
PRINTF("function not found\n"_fmt);
st->state = ScriptEndState::END;
- runflag = 0;
- return;
+ abort();
}
}
// the func is before the arg
@@ -599,8 +598,7 @@ void run_func(ScriptState *st)
{
PRINTF("run_func: not function and command! \n"_fmt);
st->state = ScriptEndState::END;
- runflag = 0;
- return;
+ abort();
}
size_t func = st->stack->stack_datav[st->start].get_if<ScriptDataFuncRef>()->numi;
@@ -669,8 +667,7 @@ void run_func(ScriptState *st)
{
PRINTF("script:run_func (return) return without callfunc or callsub!\n"_fmt);
st->state = ScriptEndState::END;
- runflag = 0;
- return;
+ abort();
}
assert (olddefsp == st->defsp); // pretty sure it hasn't changed yet
st->scriptp.code = Some(conv_script(st, &st->stack->stack_datav[olddefsp - 1])); // スクリプトを復元
@@ -766,7 +763,7 @@ void run_script_main(ScriptState *st, Borrowed<const ScriptBuffer> rootscript)
{
PRINTF("run_script: infinity loop !\n"_fmt);
st->state = ScriptEndState::END;
- runflag = 0;
+ abort();
}
}
break;
@@ -807,17 +804,28 @@ void run_script_main(ScriptState *st, Borrowed<const ScriptBuffer> rootscript)
default:
if (battle_config.error_log)
+ {
PRINTF("unknown command : %d @ %zu\n"_fmt,
c, st->scriptp.pos);
- st->state = ScriptEndState::END;
- runflag = 0;
+ if (st->oid)
+ {
+ dumb_ptr<npc_data> nd = map_id_is_npc(st->oid);
+ PRINTF("NPC => %s\n"_fmt, nd->name);
+ }
+ if (st->rid)
+ {
+ dumb_ptr<map_session_data> sd = script_rid2sd(st);
+ PRINTF("PC => %s\n"_fmt, sd->status_key.name.to__actual());
+ }
+ }
+ abort();
break;
}
if (st->freeloop != 1 && cmdcount > 0 && (--cmdcount) <= 0)
{
PRINTF("run_script: infinity loop !\n"_fmt);
st->state = ScriptEndState::END;
- runflag = 0;
+ abort();
}
}
switch (st->state)
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index 7617e0d..3949627 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -110,8 +110,7 @@ void builtin_goto(ScriptState *st)
{
PRINTF("fatal: script: goto: not label !\n"_fmt);
st->state = ScriptEndState::END;
- runflag = 0;
- return;
+ abort();
}
st->scriptp.pos = conv_num(st, &AARG(0));
@@ -152,7 +151,7 @@ void builtin_callfunc(ScriptState *st)
{
PRINTF("fatal: script: callfunc: function not found! [%s]\n"_fmt, str);
st->state = ScriptEndState::END;
- runflag = 0;
+ abort();
}
}
OMATCH_END ();
@@ -296,8 +295,7 @@ void builtin_menu(ScriptState *st)
{
PRINTF("fatal: script:menu: not a label\n"_fmt);
st->state = ScriptEndState::END;
- runflag = 0;
- return;
+ abort();
}
st->scriptp.pos = AARG(arg_index).get_if<ScriptDataPos>()->numi;
st->state = ScriptEndState::GOTO;