summaryrefslogtreecommitdiff
path: root/src/map/script.cpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2013-06-27 19:55:18 -0700
committerBen Longbons <b.r.longbons@gmail.com>2013-06-27 19:55:18 -0700
commit8b41b24415d56a008530a549e7df31b730d5d96c (patch)
treecba40613dbac49d597864932a55f619204bb5029 /src/map/script.cpp
parent204bfb1822cadd6ff0bc20820e02f36af98f9c64 (diff)
downloadtmwa-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.
Diffstat (limited to 'src/map/script.cpp')
-rw-r--r--src/map/script.cpp12
1 files changed, 10 insertions, 2 deletions
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"?