From 71f3bdc9d000855ce363c8ef9f481c1526f8b480 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Wed, 20 Dec 2006 11:50:44 +0000 Subject: - Now root script functions calls can have parenthesis (will take any parenthesis after the function as the start of the argument list). This means "func (exp),exp;" isn't valid anymore and has to be changed to "func exp,exp;" or "func((exp),exp);" or something like that. - Updated swordman.txt and knight.txt accordingly. Only changed this because it was very annoying when I was creating the sample localized npc. Don't expect more changes unless something similar happens again. Bottom line: we're in soft feature freeze and moving to eApp... git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9536 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/script.c | 102 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 60 insertions(+), 42 deletions(-) (limited to 'src/map/script.c') diff --git a/src/map/script.c b/src/map/script.c index 8c46db172..4684d745c 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -102,7 +102,7 @@ static const char* error_pos; // for advanced scripting support ( nested if, switch, while, for, do-while, function, etc ) // [Eoe / jA 1080, 1081, 1094, 1164] -enum { TYPE_NULL = 0 , TYPE_IF , TYPE_SWITCH , TYPE_WHILE , TYPE_FOR , TYPE_DO , TYPE_USERFUNC}; +enum curly_type { TYPE_NULL = 0 , TYPE_IF , TYPE_SWITCH , TYPE_WHILE , TYPE_FOR , TYPE_DO , TYPE_USERFUNC}; static struct { struct { int type; @@ -442,11 +442,11 @@ void set_label(int l,int pos, const char* script_pos) if(str_data[l].type==C_INT || str_data[l].type==C_PARAM) { //Prevent overwriting constants values and parameters [Skotlex] - disp_error_message("invalid label name",script_pos); + disp_error_message("set_label: invalid label name",script_pos); return; } if(str_data[l].label!=-1){ - disp_error_message("dup label ",script_pos); + disp_error_message("set_label: dup label ",script_pos); return; } str_data[l].type=(str_data[l].type == C_USERFUNC ? C_USERFUNC_POS : C_POS); @@ -479,7 +479,7 @@ static const char *skip_space(const char *p) if(*p) ++p; else - disp_error_message("unexpected eof @ block comment",p); + disp_error_message("skip_space: unexpected eof @ block comment",p); } else break; } @@ -521,7 +521,7 @@ int add_word(const char *p) // Check for a word len = skip_word(p)-p; if( len == 0 ) - disp_error_message("expected a word",p); + disp_error_message("add_word: not a word",p); // Copy the word CREATE(word,char,len+1); @@ -559,12 +559,12 @@ const char* parse_simpleexpr(const char *p) ShowDebug("parse_simpleexpr %s\n",p); #endif if(*p==';' || *p==',') - disp_error_message("unexpected expr end",p); + disp_error_message("parse_simpleexpr: unexpected expr end",p); if(*p=='('){ p=parse_subexpr(p+1,-1); p=skip_space(p); if((*p++)!=')') - disp_error_message("unmatch ')'",p); + disp_error_message("parse_simpleexpr: unmatch ')'",p); } else if(isdigit(*p) || ((*p=='-' || *p=='+') && isdigit(p[1]))){ char *np; i=strtoul(p,&np,0); @@ -577,18 +577,18 @@ const char* parse_simpleexpr(const char *p) if(p[-1]<=0x7e && *p=='\\') p++; else if(*p=='\n') - disp_error_message("unexpected newline @ string",p); + disp_error_message("parse_simpleexpr: unexpected newline @ string",p); add_scriptb(*p++); } if(!*p) - disp_error_message("unexpected eof @ string",p); + disp_error_message("parse_simpleexpr: unexpected eof @ string",p); add_scriptb(0); p++; //'"' } else { int l; // label , register , function etc if(skip_word(p)==p) - disp_error_message("unexpected character",p); + disp_error_message("parse_simpleexpr: unexpected character",p); l=add_word(p); parse_cmd=l; // warn_*_mismatch_paramnumのために必要 @@ -603,7 +603,7 @@ const char* parse_simpleexpr(const char *p) p=parse_subexpr(p+1,-1); p=skip_space(p); if((*p++)!=']') - disp_error_message("unmatch ']'",p); + disp_error_message("parse_simpleexpr: unmatch ']'",p); add_scriptc(C_FUNC); } else if(str_data[l].type == C_USERFUNC || str_data[l].type == C_USERFUNC_POS) { add_scriptl(search_str("callsub")); @@ -688,7 +688,7 @@ const char* parse_subexpr(const char* p,int limit) parse_cmd = search_str("callsub"); i++; } else - disp_error_message("expect command, missing function name or calling undeclared function",tmpp); + disp_error_message("parse_subexpr: expect command, missing function name or calling undeclared function",tmpp); func=parse_cmd; p=skip_space(p); @@ -710,25 +710,23 @@ const char* parse_subexpr(const char* p,int limit) p++; // the next argument is valid, skip the comma } else if(*p!=')' && script_config.warn_func_no_comma){ - disp_error_message("expect ',' or ')' at func params",p); + disp_error_message("parse_subexpr: expect ',' or ')' at func params",p); } p=skip_space(p); i++; } plist[i]=p; - if(*(p++)!=')'){ - disp_error_message("func request '(' ')'",p); - //exit(1); - } + if(*(p++)!=')') + disp_error_message("parse_subexpr: func request '(' ')'",p); if(arg) { if( (arg[j]==0 && i!=j) || (arg[j]=='*' && i