diff options
author | Haru <haru@dotalux.com> | 2015-12-31 21:12:31 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2016-06-25 17:29:43 +0200 |
commit | d7db381921c0d6c6b1cdaa4b2083aa1d877046f5 (patch) | |
tree | 5db24958d8600b6cc64e1c66eec5f3a671fbb3a0 | |
parent | ba035696cf0927624b02db5573c617566cdd645f (diff) | |
download | hercules-d7db381921c0d6c6b1cdaa4b2083aa1d877046f5.tar.gz hercules-d7db381921c0d6c6b1cdaa4b2083aa1d877046f5.tar.bz2 hercules-d7db381921c0d6c6b1cdaa4b2083aa1d877046f5.tar.xz hercules-d7db381921c0d6c6b1cdaa4b2083aa1d877046f5.zip |
Improved handling of nested function calls by the HULD
Signed-off-by: Haru <haru@dotalux.com>
-rw-r--r-- | src/map/script.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/src/map/script.c b/src/map/script.c index d97dacb89..46116f75a 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -803,18 +803,13 @@ const char* parse_callfunc(const char* p, int require_paren, int is_custom) char *arg = NULL; char null_arg = '\0'; int func; - bool nested_call = false, macro = false; + bool macro = false; // is need add check for arg null pointer below? func = script->add_word(p); - if( script->str_data[func].type == C_FUNC ) { - /** only when unset (-1), valid values are >= 0 **/ - if( script->syntax.last_func == -1 ) - script->syntax.last_func = script->str_data[func].val; - else { //Nested function call - script->syntax.nested_call++; - nested_call = true; - + if (script->str_data[func].type == C_FUNC) { + script->syntax.nested_call++; + if (script->syntax.last_func != -1) { if( script->str_data[func].val == script->buildin_lang_macro_offset ) { script->syntax.lang_macro_active = true; macro = true; @@ -823,6 +818,7 @@ const char* parse_callfunc(const char* p, int require_paren, int is_custom) if( !macro ) { // buildin function + script->syntax.last_func = script->str_data[func].val; script->addl(func); script->addc(C_ARG); } @@ -915,14 +911,11 @@ const char* parse_callfunc(const char* p, int require_paren, int is_custom) script->syntax.lang_macro_active = false; } - if( nested_call ) - script->syntax.nested_call--; - - if( !script->syntax.nested_call ) - script->syntax.last_func = -1; - - if( !macro ) + if (!macro) { + if (0 == --script->syntax.nested_call) + script->syntax.last_func = -1; script->addc(C_FUNC); + } return p; } @@ -1058,6 +1051,8 @@ const char* parse_variable(const char* p) } // push the set function onto the stack + script->syntax.nested_call++; + script->syntax.last_func = script->str_data[script->buildin_set_ref].val; script->addl(script->buildin_set_ref); script->addc(C_ARG); @@ -1109,6 +1104,8 @@ const char* parse_variable(const char* p) // close the script by appending the function operator script->addc(C_FUNC); + if (--script->syntax.nested_call == 0) + script->syntax.last_func = -1; // push the buffer from the method return p; @@ -1295,7 +1292,7 @@ const char* parse_simpleexpr(const char *p) if( script->lang_export_fp && !duplicate && ( ( ( script->syntax.last_func == script->buildin_mes_offset || - script->syntax.last_func == script->buildin_select_offset ) && !script->syntax.nested_call + script->syntax.last_func == script->buildin_select_offset ) ) || script->syntax.lang_macro_active ) ) { const char *line_start = start_point; const char *line_end = start_point; |