From 72bebf27fc6ecb32b6df6df114e6456cef91bfc8 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Wed, 20 Dec 2006 11:50:44 +0000 Subject: [PATCH] - 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://svn.code.sf.net/p/rathena/svn/trunk@9536 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 3 ++ npc/Changelog.txt | 3 ++ npc/jobs/1-1/swordman.txt | 2 +- npc/jobs/2-1/knight.txt | 2 +- src/map/script.c | 102 ++++++++++++++++++++++---------------- 5 files changed, 68 insertions(+), 44 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index b40cdcd3aa..275bc172dc 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,9 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2006/12/20 + * 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. * Replaced our fix for "mes ();" crashing by jA's version. * Merged the fix for & having the same precedence as << and >> from jA. * Merged the C_OP3 operator from jA: test ? if_true : if_false diff --git a/npc/Changelog.txt b/npc/Changelog.txt index e48d822582..380b4b97ba 100644 --- a/npc/Changelog.txt +++ b/npc/Changelog.txt @@ -34,6 +34,9 @@ KarLaeda Date Added ====== 2006/12/19 + * Now root functions calls can have parenthesis (will take any parenthesis + after the function as the start of the argument list). + - Updated swordman.txt and knight.txt accordingly. * Added year to the dates in this changelog. * Added sample localized NPC. [FlavioJS] 2006/12/17 diff --git a/npc/jobs/1-1/swordman.txt b/npc/jobs/1-1/swordman.txt index 85ffaaf1c2..4592463936 100644 --- a/npc/jobs/1-1/swordman.txt +++ b/npc/jobs/1-1/swordman.txt @@ -392,7 +392,7 @@ job_sword1.gat,223,167,2 script Mae 92,{ // -- First Section -- // - Left - job_sword1.gat,22,172,1 script 1green_1::green 139,0,0,{ - heal (-4),0; + heal -4,0; end; } diff --git a/npc/jobs/2-1/knight.txt b/npc/jobs/2-1/knight.txt index dfad3c601d..fcb0271d51 100644 --- a/npc/jobs/2-1/knight.txt +++ b/npc/jobs/2-1/knight.txt @@ -1081,7 +1081,7 @@ L_Knight: M_Yes: mes "^FF0000(SLAPP!! SMACK!! BASH!!)^000000"; emotion e_an; - percentheal (-10),0; + percentheal -10,0; next; mes "[Lady Amy Beatris]"; mes "How dare you!! Just what kind of girl do you take me for?"; diff --git a/src/map/script.c b/src/map/script.c index 8c46db1727..4684d745cc 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