summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-07-27 21:00:19 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-07-27 21:00:19 +0000
commit6384f1dd85e311f1456351388f9a94a32ac1fad4 (patch)
tree19209d56704842750a50114e386b8e5490df73ca /src/map/npc.c
parent3e29ca7edd4e8618fa24e6a2c65e35a3baeddad8 (diff)
downloadhercules-6384f1dd85e311f1456351388f9a94a32ac1fad4.tar.gz
hercules-6384f1dd85e311f1456351388f9a94a32ac1fad4.tar.bz2
hercules-6384f1dd85e311f1456351388f9a94a32ac1fad4.tar.xz
hercules-6384f1dd85e311f1456351388f9a94a32ac1fad4.zip
- Synced the script.c file with as much data as possible from jA's:
- A lot of functions were moved around, a bunch of indentation and space-usage changes were done to make it easier to diff against their files. - Miscellanous addition and corrections were applied. - Largest one is likely a restructuring of run_script_main, which hopes to solve the memory leaks. - script engine now uses the setjmp functions to restore memory state when there's an error parsing scripts, which means that script errors won't cause the map-server to inmediately bail out anymore. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7926 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index 626344881..6f5649654 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1023,9 +1023,6 @@ int npc_checknear2(struct map_session_data *sd,struct block_list *bl)
if(sd->state.using_fake_npc && sd->npc_id == bl->id)
return 0;
-// if (bl->type!=BL_NPC) //Disguised character or something else...
-// return 1;
-
if (status_get_class(bl)<0) //Class-less npc, enable click from anywhere.
return 0;
@@ -1817,7 +1814,7 @@ static int npc_skip_script (char *w1,char *w2,char *w3,char *w4,char *first_line
return 0;
}
-static int npc_parse_script (char *w1,char *w2,char *w3,char *w4,char *first_line,FILE *fp,int *lines)
+static int npc_parse_script(char *w1,char *w2,char *w3,char *w4,char *first_line,FILE *fp,int *lines,const char* file)
{
int x, y, dir = 0, m, xs = 0, ys = 0, class_ = 0; // [Valaris] thanks to fov
char mapname[MAP_NAME_LENGTH];
@@ -1840,7 +1837,7 @@ static int npc_parse_script (char *w1,char *w2,char *w3,char *w4,char *first_lin
// 引数の個数チェック
if (sscanf(w1, "%15[^,],%d,%d,%d", mapname, &x, &y, &dir) != 4 ||
(strcmp(w2, "script") == 0 && strchr(w4,',') == NULL)) {
- ShowError("bad script line (in file %s): %s\n", current_file, w3);
+ ShowError("bad script line (in file %s): %s\n", file, w3);
return 1;
}
m = map_mapname2mapid(mapname);
@@ -1876,11 +1873,11 @@ static int npc_parse_script (char *w1,char *w2,char *w3,char *w4,char *first_lin
strcat((char *) srcbuf, (const char *) line);
}
if(curly_count > 0) {
- ShowError("Missing right curly at file %s, line %d\n",current_file, *lines);
+ ShowError("Missing right curly at file %s, line %d\n",file, *lines);
script = NULL;
} else {
// printf("Ok line %d\n",*lines);
- script = parse_script((unsigned char *) srcbuf, startline);
+ script = parse_script((unsigned char *) srcbuf, file, startline);
}
if (script == NULL) {
// script parse error?
@@ -1892,11 +1889,11 @@ static int npc_parse_script (char *w1,char *w2,char *w3,char *w4,char *first_lin
char srcname[128];
struct npc_data *dnd;
if (sscanf(w2, "duplicate(%[^)])", srcname) != 1) {
- ShowError("bad duplicate name (in %s)! : %s", current_file, w2);
+ ShowError("bad duplicate name (in %s)! : %s", file, w2);
return 0;
}
if ((dnd = npc_name2id(srcname)) == NULL) {
- ShowError("bad duplicate name (in %s)! (not exist) : %s\n", current_file, srcname);
+ ShowError("bad duplicate name (in %s)! (not exist) : %s\n", file, srcname);
return 0;
}
script = dnd->u.scr.script;
@@ -2019,7 +2016,7 @@ static int npc_parse_script (char *w1,char *w2,char *w3,char *w4,char *first_lin
// and already overwritten if this is here is reached
// I leave the check anyway but place it correctly to npc_convertlabel_db
if (strlen(lname)>NAME_LENGTH-1) {
- ShowError("npc_parse_script: label name longer than %d chars! '%s' (%s)\n", NAME_LENGTH-1, lname, current_file);
+ ShowError("npc_parse_script: label name longer than %d chars! '%s' (%s)\n", NAME_LENGTH-1, lname, file);
exit(1);
} else {
struct event_data *ev;
@@ -2033,7 +2030,7 @@ static int npc_parse_script (char *w1,char *w2,char *w3,char *w4,char *first_lin
ev->nd=nd;
ev->pos=pos;
if (strdb_put(ev_db,buf,ev) != NULL) //There was already another event of the same name?
- ShowWarning("npc_parse_script : duplicate event %s (%s)\n",buf, current_file);
+ ShowWarning("npc_parse_script : duplicate event %s (%s)\n",buf, file);
}
}
}
@@ -2073,7 +2070,7 @@ static int npc_parse_script (char *w1,char *w2,char *w3,char *w4,char *first_lin
* function行解析
*------------------------------------------
*/
-static int npc_parse_function (char *w1, char *w2, char *w3, char *w4, char *first_line, FILE *fp, int *lines)
+static int npc_parse_function (char *w1, char *w2, char *w3, char *w4, char *first_line, FILE *fp, int *lines,const char* file)
{
unsigned char *srcbuf, *p;
struct script_code *script;
@@ -2112,10 +2109,10 @@ static int npc_parse_function (char *w1, char *w2, char *w3, char *w4, char *fir
strcat(srcbuf,line);
}
if(curly_count > 0) {
- ShowError("Missing right curly at file %s, line %d\n",current_file, *lines);
+ ShowError("Missing right curly at file %s, line %d\n",file, *lines);
script = NULL;
} else {
- script = parse_script(srcbuf, startline);
+ script = parse_script(srcbuf, file, startline);
}
if (script == NULL) {
// script parse error?
@@ -2516,7 +2513,7 @@ static int npc_parse_mapflag (char *w1, char *w2, char *w3, char *w4)
else if (strcmpi(w3,"nochat")==0) { // Skotlex
map[m].flag.nochat=state;
}
-
+
return 0;
}
@@ -2619,12 +2616,12 @@ void npc_parsesrcfile (char *name)
npc_parse_shop(w1,w2,w3,w4);
} else if (strcmpi(w2,"script") == 0 && count > 3) {
if (strcmpi(w1,"function") == 0) {
- npc_parse_function(w1,w2,w3,w4,line+w4pos,fp,&lines);
+ npc_parse_function(w1,w2,w3,w4,line+w4pos,fp,&lines,name);
} else {
- npc_parse_script(w1,w2,w3,w4,line+w4pos,fp,&lines);
+ npc_parse_script(w1,w2,w3,w4,line+w4pos,fp,&lines,name);
}
} else if ((i = 0, sscanf(w2,"duplicate%n",&i), (i > 0 && w2[i] == '(')) && count > 3) {
- npc_parse_script(w1,w2,w3,w4,line+w4pos,fp,&lines);
+ npc_parse_script(w1,w2,w3,w4,line+w4pos,fp,&lines,name);
} else if (strcmpi(w2,"monster") == 0 && count > 3) {
npc_parse_mob(w1,w2,w3,w4);
} else if (strcmpi(w2,"mapflag") == 0 && count >= 3) {