summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-11-11 10:59:41 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-11-11 10:59:41 +0000
commitcf9a1c007ff068ab5cdbbd93c689b00e2b5c4912 (patch)
tree9647685d0d35f5b2637393a81f11eaea153ca230
parenta2af1f425fb90746191f5ae8ae1ee8624739c441 (diff)
downloadhercules-cf9a1c007ff068ab5cdbbd93c689b00e2b5c4912.tar.gz
hercules-cf9a1c007ff068ab5cdbbd93c689b00e2b5c4912.tar.bz2
hercules-cf9a1c007ff068ab5cdbbd93c689b00e2b5c4912.tar.xz
hercules-cf9a1c007ff068ab5cdbbd93c689b00e2b5c4912.zip
Applied Rayce's improvements to the npc script parser (see bugreport:387 for details).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11715 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt1
-rw-r--r--src/map/script.c26
2 files changed, 16 insertions, 11 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 6545c6806..94803ac18 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -4,6 +4,7 @@ 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.
2007/11/12
+ * Applied Rayce's improvements to the npc script parser [ultramage]
* Made on-touch areas work with walking npcs (is somewhat process
intensive, but people do not really care about that, do they?) [Skotlex]
* Fixed a bug in r11384 letting you bypass requirements for some skills
diff --git a/src/map/script.c b/src/map/script.c
index 77d7e44bb..13352e192 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -1047,8 +1047,8 @@ const char* parse_line(const char* p)
p=skip_space(p);
if(*p==';') {
// if(); for(); while(); のために閉じ判定
- p = parse_syntax_close(p);
- return p+1;
+ p = parse_syntax_close(p + 1);
+ return p;
}
if(*p==')' && parse_syntax_for_flag)
return p+1;
@@ -1178,10 +1178,8 @@ const char* parse_syntax(const char* p)
syntax.curly_count--;
}
p = skip_space(p2);
- if(*p != ';') {
+ if(*p != ';')
disp_error_message("parse_syntax: need ';'",p);
- }
- p++;
// if, for , while の閉じ判定
p = parse_syntax_close(p + 1);
return p;
@@ -1292,7 +1290,6 @@ const char* parse_syntax(const char* p)
p = skip_space(p2);
if(*p != ';')
disp_error_message("parse_syntax: need ';'",p);
- p++;
// if, for , while の閉じ判定
p = parse_syntax_close(p + 1);
return p;
@@ -1436,16 +1433,19 @@ const char* parse_syntax(const char* p)
p = skip_word(func_name);
if( p == func_name )
disp_error_message("parse_syntax:function: function name is missing or invalid", p);
- if( *skip_space(p) == ';' )
+ p2 = skip_space(p);
+ if( *p2 == ';' )
{// function <name> ;
// function declaration - just register the name
int l;
l = add_word(func_name);
if( str_data[l].type == C_NOP )//## ??? [FlavioJS]
str_data[l].type = C_USERFUNC;
- return skip_space(p) + 1;
- }
- else
+
+ // if, for , while の閉じ判定
+ p = parse_syntax_close(p2 + 1);
+ return p; }
+ else if(*p2 == '{')
{// function <name> <line/block of code>
char label[256];
int l;
@@ -1472,6 +1472,10 @@ const char* parse_syntax(const char* p)
strdb_put(scriptlabel_db, GETSTRING(str_data[l].str), (void*)script_pos);
return skip_space(p);
}
+ else
+ {
+ disp_error_message("expect ';' or '{' at function syntax",p);
+ }
}
break;
case 'i':
@@ -1727,7 +1731,7 @@ const char* parse_syntax_close_sub(const char* p,int* flag)
l=add_str(label);
set_label(l,script_pos,p);
syntax.curly_count--;
- return p + 1;
+ return p;
} else {
*flag = 0;
return p;