diff options
author | Haru <haru@dotalux.com> | 2014-05-09 07:37:53 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2014-05-09 07:40:43 +0200 |
commit | 5f1529083ad1f35a3ac66cc041ee74d6db2f3552 (patch) | |
tree | 32c4d73a7f68cd7a1a963e14e3972333758bb541 /src/map/script.c | |
parent | 581ff22b9bad7567a27980df31636f0c75ba5fc2 (diff) | |
download | hercules-5f1529083ad1f35a3ac66cc041ee74d6db2f3552.tar.gz hercules-5f1529083ad1f35a3ac66cc041ee74d6db2f3552.tar.bz2 hercules-5f1529083ad1f35a3ac66cc041ee74d6db2f3552.tar.xz hercules-5f1529083ad1f35a3ac66cc041ee74d6db2f3552.zip |
Return EXIT_FAILURE if a script parse error occurred.
- This affects normal execution as well as ./script-checker runs.
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/map/script.c b/src/map/script.c index aea4d978f..aecdf9b28 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2242,8 +2242,7 @@ void script_warning(const char* src, const char* file, int start_line, const cha /*========================================== * Analysis of the script *------------------------------------------*/ -struct script_code* parse_script(const char *src,const char *file,int line,int options) -{ +struct script_code* parse_script(const char *src,const char *file,int line,int options, int *retval) { const char *p,*tmpp; int i; struct script_code* code = NULL; @@ -2289,6 +2288,7 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o script->parser_current_file = NULL; script->parser_current_line = 0; #endif // ENABLE_CASE_CHECK + if (retval) *retval = EXIT_FAILURE; return NULL; } @@ -2315,8 +2315,10 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o } else {// requires brackets around the script - if( *p != '{' ) + if( *p != '{' ) { disp_error_message("not found '{'",p); + if (retval) *retval = EXIT_FAILURE; + } p = script->skip_space(p+1); if( *p == '}' && !(options&SCRIPT_RETURN_EMPTY_SCRIPT) ) {// empty script and can return NULL @@ -2391,13 +2393,14 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o else if( script->str_data[i].type == C_USERFUNC ) {// 'function name;' without follow-up code ShowError("parse_script: function '%s' declared but not defined.\n", script->str_buf+script->str_data[i].str); + if (retval) *retval = EXIT_FAILURE; unresolved_names = true; } } - if( unresolved_names ) - { + if( unresolved_names ) { disp_error_message("parse_script: unresolved function references", p); + if (retval) *retval = EXIT_FAILURE; } #ifdef SCRIPT_DEBUG_DISP @@ -4203,7 +4206,7 @@ void script_run_autobonus(const char *autobonus, int id, int pos) void script_add_autobonus(const char *autobonus) { if( strdb_get(script->autobonus_db, autobonus) == NULL ) { - struct script_code *scriptroot = script->parse(autobonus, "autobonus", 0, 0); + struct script_code *scriptroot = script->parse(autobonus, "autobonus", 0, 0, NULL); if( scriptroot ) strdb_put(script->autobonus_db, autobonus, scriptroot); @@ -11041,7 +11044,7 @@ BUILDIN(setmapflag) { char empty[1] = "\0"; char params[MAP_ZONE_MAPFLAG_LENGTH]; memcpy(params, val2, MAP_ZONE_MAPFLAG_LENGTH); - npc->parse_mapflag(map->list[m].name, empty, zone, params, empty, empty, empty); + npc->parse_mapflag(map->list[m].name, empty, zone, params, empty, empty, empty, NULL); } break; case MF_NOCOMMAND: map->list[m].nocommand = (val <= 0) ? 100 : val; break; @@ -15100,7 +15103,7 @@ BUILDIN(setitemscript) if(*dstscript) script->free_code(*dstscript); - *dstscript = new_bonus_script[0] ? script->parse(new_bonus_script, "script_setitemscript", 0, 0) : NULL; + *dstscript = new_bonus_script[0] ? script->parse(new_bonus_script, "script_setitemscript", 0, 0, NULL) : NULL; script_pushint(st,1); return true; } |