summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/npc.cpp6
-rw-r--r--src/map/script.cpp12
-rw-r--r--src/map/script.hpp2
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