diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/script-call.cpp | 8 | ||||
-rw-r--r-- | src/map/script-fun.cpp | 32 | ||||
-rw-r--r-- | src/map/script-parse.cpp | 14 |
3 files changed, 45 insertions, 9 deletions
diff --git a/src/map/script-call.cpp b/src/map/script-call.cpp index c3c6aa1..7092dbc 100644 --- a/src/map/script-call.cpp +++ b/src/map/script-call.cpp @@ -28,6 +28,8 @@ #include "../mmo/cxxstdio_enums.hpp" +#include "../high/core.hpp" + #include "battle.hpp" #include "battle_conf.hpp" #include "globals.hpp" @@ -584,6 +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; } } @@ -596,6 +599,7 @@ void run_func(ScriptState *st) { PRINTF("run_func: not function and command! \n"_fmt); st->state = ScriptEndState::END; + runflag = 0; return; } size_t func = st->stack->stack_datav[st->start].get_if<ScriptDataFuncRef>()->numi; @@ -665,6 +669,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; } assert (olddefsp == st->defsp); // pretty sure it hasn't changed yet @@ -761,6 +766,7 @@ void run_script_main(ScriptState *st, Borrowed<const ScriptBuffer> rootscript) { PRINTF("run_script: infinity loop !\n"_fmt); st->state = ScriptEndState::END; + runflag = 0; } } break; @@ -804,12 +810,14 @@ void run_script_main(ScriptState *st, Borrowed<const ScriptBuffer> rootscript) PRINTF("unknown command : %d @ %zu\n"_fmt, c, st->scriptp.pos); st->state = ScriptEndState::END; + runflag = 0; break; } if (st->freeloop != 1 && cmdcount > 0 && (--cmdcount) <= 0) { PRINTF("run_script: infinity loop !\n"_fmt); st->state = ScriptEndState::END; + runflag = 0; } } switch (st->state) diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 3291cfc..4c20555 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -108,8 +108,9 @@ void builtin_goto(ScriptState *st) { if (!AARG(0).is<ScriptDataPos>()) { - PRINTF("script: goto: that's not a label!\n"_fmt); + PRINTF("fatal: script: goto: not label !\n"_fmt); st->state = ScriptEndState::END; + runflag = 0; return; } @@ -149,8 +150,9 @@ void builtin_callfunc(ScriptState *st) } OMATCH_CASE_NONE () { - PRINTF("script: callfunc: function not found! [%s]\n"_fmt, str); + PRINTF("fatal: script: callfunc: function not found! [%s]\n"_fmt, str); st->state = ScriptEndState::END; + runflag = 0; } } OMATCH_END (); @@ -188,6 +190,14 @@ void builtin_callsub(ScriptState *st) static void builtin_return(ScriptState *st) { + if (!(st->stack->stack_datav[st->defsp - 1].is<ScriptDataRetInfo>())) + { + dumb_ptr<npc_data> nd = map_id_is_npc(st->oid); + if(nd) + PRINTF("Deprecated: return outside of callfunc or callsub! @ %s\n"_fmt, nd->name); + else + PRINTF("Deprecated: return outside of callfunc or callsub! (no npc)\n"_fmt); + } #if 0 if (HARG(0)) { // 戻り値有り @@ -215,6 +225,14 @@ void builtin_next(ScriptState *st) static void builtin_close(ScriptState *st) { + if (st->stack->stack_datav[st->defsp - 1].is<ScriptDataRetInfo>()) + { + dumb_ptr<npc_data> nd = map_id_is_npc(st->oid); + if(nd) + PRINTF("Deprecated: close in a callfunc or callsub! @ %s\n"_fmt, nd->name); + else + PRINTF("Deprecated: close in a callfunc or callsub! (no npc)\n"_fmt); + } st->state = ScriptEndState::END; clif_scriptclose(script_rid2sd(st), st->oid); } @@ -276,7 +294,9 @@ void builtin_menu(ScriptState *st) int arg_index = (sd->npc_menu - 1) * 2 + 1; if (!AARG(arg_index).is<ScriptDataPos>()) { + PRINTF("fatal: script:menu: not a label\n"_fmt); st->state = ScriptEndState::END; + runflag = 0; return; } st->scriptp.pos = AARG(arg_index).get_if<ScriptDataPos>()->numi; @@ -1239,6 +1259,14 @@ void builtin_getgmlevel(ScriptState *st) static void builtin_end(ScriptState *st) { + if (st->stack->stack_datav[st->defsp - 1].is<ScriptDataRetInfo>()) + { + dumb_ptr<npc_data> nd = map_id_is_npc(st->oid); + if(nd) + PRINTF("Deprecated: close in a callfunc or callsub! @ %s\n"_fmt, nd->name); + else + PRINTF("Deprecated: close in a callfunc or callsub! (no npc)\n"_fmt); + } st->state = ScriptEndState::END; } diff --git a/src/map/script-parse.cpp b/src/map/script-parse.cpp index fb306c5..2c7305b 100644 --- a/src/map/script-parse.cpp +++ b/src/map/script-parse.cpp @@ -451,7 +451,7 @@ ZString::iterator ScriptBuffer::parse_subexpr(ZString::iterator p, int limit) ZString::iterator tmpp = skip_space(p + 1); if (*tmpp == ';' || *tmpp == ',') { - --script_errors; disp_error_message("deprecated: implicit 'next statement' label"_s, p); + disp_error_message("error: implicit 'next statement' label"_s, p); add_scriptl(borrow(LABEL_NEXTLINE_)); p++; return p; @@ -752,7 +752,7 @@ void ScriptBuffer::parse_script(ZString src, int line, bool implicit_end) { if (can_step) { - --script_errors; disp_error_message("deprecated: implicit fallthrough"_s, p); + disp_error_message("error: implicit fallthrough"_s, p); } can_step = true; @@ -777,7 +777,7 @@ void ScriptBuffer::parse_script(ZString src, int line, bool implicit_end) if (!can_step) { - --script_errors; disp_error_message("deprecated: unreachable statement"_s, p); + disp_error_message("error: unreachable statement"_s, p); } // 他は全部一緒くた p = parse_line(p, &can_step); @@ -792,7 +792,7 @@ void ScriptBuffer::parse_script(ZString src, int line, bool implicit_end) if (can_step && !implicit_end) { - --script_errors; disp_error_message("deprecated: implicit end"_s, p); + disp_error_message("error: implicit end"_s, p); } add_scriptc(ByteCode::NOP); @@ -824,14 +824,14 @@ void ScriptBuffer::parse_script(ZString src, int line, bool implicit_end) if (key.startswith("On"_s)) continue; if (!(key.startswith("L_"_s) || key.startswith("S_"_s))) - PRINTF("Warning: ugly label: %s\n"_fmt, key); + disp_error_message(STRPRINTF("error: ugly label: %s\n"_fmt, key),p); else if (!probable_labels.count(key)) - PRINTF("Warning: unused label: %s\n"_fmt, key); + disp_error_message(STRPRINTF("error: unused label: %s\n"_fmt, key),p); } for (ScriptLabel used : probable_labels) { if (scriptlabel_db.search(used).is_none()) - PRINTF("Warning: no such label: %s\n"_fmt, used); + disp_error_message(STRPRINTF("error: no such label: %s\n"_fmt, used),p); } probable_labels.clear(); |