diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2013-06-27 19:55:18 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2013-06-27 19:55:18 -0700 |
commit | 8b41b24415d56a008530a549e7df31b730d5d96c (patch) | |
tree | cba40613dbac49d597864932a55f619204bb5029 | |
parent | 204bfb1822cadd6ff0bc20820e02f36af98f9c64 (diff) | |
download | tmwa-8b41b24415d56a008530a549e7df31b730d5d96c.tar.gz tmwa-8b41b24415d56a008530a549e7df31b730d5d96c.tar.bz2 tmwa-8b41b24415d56a008530a549e7df31b730d5d96c.tar.xz tmwa-8b41b24415d56a008530a549e7df31b730d5d96c.zip |
Make callfunc/callsub in an if an error
Also make all errors fatal and clean up messages a bit.
-rw-r--r-- | src/map/npc.cpp | 6 | ||||
-rw-r--r-- | src/map/script.cpp | 12 | ||||
-rw-r--r-- | src/map/script.hpp | 2 |
3 files changed, 18 insertions, 2 deletions
diff --git a/src/map/npc.cpp b/src/map/npc.cpp index 37f3f62..68b5ad7 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -1800,5 +1800,11 @@ int do_init_npc(void) PRINTF("\rNPCs Loaded: %d [Warps:%d Shops:%d Scripts:%d Mobs:%d] %20s\n", npc_id - START_NPC_NUM, npc_warp, npc_shop, npc_script, npc_mob, ""); + if (script_errors) + { + PRINTF("Cowardly refusing to continue after %d errors\n", script_errors); + abort(); + } + return 0; } diff --git a/src/map/script.cpp b/src/map/script.cpp index 8957e60..854a42f 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -325,6 +325,7 @@ const char *startptr; static int startline; +int script_errors = 0; /*========================================== * エラーメッセージ出力 *------------------------------------------ @@ -332,6 +333,8 @@ int startline; static void disp_error_message(const char *mes, const char *pos_) { + script_errors++; + int line; const char *p; @@ -348,7 +351,7 @@ void disp_error_message(const char *mes, const char *pos_) } if (lineend == NULL || pos_ < lineend) { - PRINTF("%s line %d : ", mes, line); + PRINTF("\n%s\nline %d : ", mes, line); for (int i = 0; (linestart[i] != '\r') && (linestart[i] != '\n') && linestart[i]; i++) @@ -432,7 +435,12 @@ const char *ScriptBuffer::parse_simpleexpr(const char *p) disp_error_message("unexpected character", p); exit(1); } - str_data_t *ld = add_strp(std::string(p, p2)); + std::string word(p, p2); + if (parse_cmd_if && (word == "callsub" || word == "callfunc")) + { + disp_error_message("callsub/callfunc not allowed in an if statement", p); + } + str_data_t *ld = add_strp(word); parse_cmdp = ld; // warn_*_mismatch_paramnumのために必要 // why not just check l->str == "if" or std::string(p, p2) == "if"? diff --git a/src/map/script.hpp b/src/map/script.hpp index 0e63add..66939aa 100644 --- a/src/map/script.hpp +++ b/src/map/script.hpp @@ -157,4 +157,6 @@ void do_final_script(void); extern char mapreg_txt[256]; +extern int script_errors; + #endif // SCRIPT_HPP |