|
@@ -3846,7 +3846,8 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short
|
|
|
|
|
|
/**
|
|
/**
|
|
* Parses a warp npc.
|
|
* Parses a warp npc.
|
|
- * Line definition <from mapname>,<fromX>,<fromY>,<facing>%TAB%warp%TAB%<warp name>%TAB%<spanx>,<spany>,<to mapname>,<toX>,<toY>
|
|
|
|
|
|
+ * Line definition <from mapname>,<fromX>,<fromY>,<facing>%TAB%warp(<state)%TAB%<warp name>%TAB%<spanx>,<spany>,<to mapname>,<toX>,<toY>
|
|
|
|
+ * Line definition <from mapname>,<fromX>,<fromY>,<facing>%TAB%warp2(<state)%TAB%<warp name>%TAB%<spanx>,<spany>,<to mapname>,<toX>,<toY>
|
|
* @param w1 : word 1 before tab (<from map name>,<fromX>,<fromY>,<facing>)
|
|
* @param w1 : word 1 before tab (<from map name>,<fromX>,<fromY>,<facing>)
|
|
* @param w2 : word 2 before tab (warp), keyword that sent us in this parsing
|
|
* @param w2 : word 2 before tab (warp), keyword that sent us in this parsing
|
|
* @param w3 : word 3 before tab (<warp name>)
|
|
* @param w3 : word 3 before tab (<warp name>)
|
|
@@ -3858,25 +3859,20 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short
|
|
*/
|
|
*/
|
|
static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
|
|
static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
|
|
{
|
|
{
|
|
- int m;
|
|
|
|
short x, y, xs, ys, to_x, to_y;
|
|
short x, y, xs, ys, to_x, to_y;
|
|
- unsigned short i;
|
|
|
|
char mapname[MAP_NAME_LENGTH_EXT], to_mapname[MAP_NAME_LENGTH_EXT];
|
|
char mapname[MAP_NAME_LENGTH_EXT], to_mapname[MAP_NAME_LENGTH_EXT];
|
|
- struct npc_data *nd;
|
|
|
|
|
|
|
|
// w1=<from map name>,<fromX>,<fromY>,<facing>
|
|
// w1=<from map name>,<fromX>,<fromY>,<facing>
|
|
// w4=<spanx>,<spany>,<to map name>,<toX>,<toY>
|
|
// w4=<spanx>,<spany>,<to map name>,<toX>,<toY>
|
|
- if( sscanf(w1, "%15[^,],%6hd,%6hd", mapname, &x, &y) != 3
|
|
|
|
- || sscanf(w4, "%6hd,%6hd,%15[^,],%6hd,%6hd", &xs, &ys, to_mapname, &to_x, &to_y) != 5 )
|
|
|
|
- {
|
|
|
|
|
|
+ if( sscanf(w1, "%15[^,],%6hd,%6hd", mapname, &x, &y) != 3 || sscanf(w4, "%6hd,%6hd,%15[^,],%6hd,%6hd", &xs, &ys, to_mapname, &to_x, &to_y) != 5 ) {
|
|
ShowError("npc_parse_warp: Invalid warp definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
|
|
ShowError("npc_parse_warp: Invalid warp definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
|
|
return strchr(start,'\n');// skip and continue
|
|
return strchr(start,'\n');// skip and continue
|
|
}
|
|
}
|
|
|
|
|
|
- m = map_mapname2mapid(mapname);
|
|
|
|
- i = mapindex_name2id(to_mapname);
|
|
|
|
- if( i == 0 )
|
|
|
|
- {
|
|
|
|
|
|
+ int m = map_mapname2mapid(mapname);
|
|
|
|
+ unsigned short i = mapindex_name2id(to_mapname);
|
|
|
|
+
|
|
|
|
+ if( i == 0 ) {
|
|
ShowError("npc_parse_warp: Unknown destination map in file '%s', line '%d' : %s\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), to_mapname, w1, w2, w3, w4);
|
|
ShowError("npc_parse_warp: Unknown destination map in file '%s', line '%d' : %s\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), to_mapname, w1, w2, w3, w4);
|
|
return strchr(start,'\n');// skip and continue
|
|
return strchr(start,'\n');// skip and continue
|
|
}
|
|
}
|
|
@@ -3887,9 +3883,11 @@ static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const
|
|
ShowWarning("npc_parse_warp: coordinates %d/%d are out of bounds in map %s(%dx%d), in file '%s', line '%d'\n", x, y, mapdata->name, mapdata->xs, mapdata->ys,filepath,strline(buffer,start-buffer));
|
|
ShowWarning("npc_parse_warp: coordinates %d/%d are out of bounds in map %s(%dx%d), in file '%s', line '%d'\n", x, y, mapdata->name, mapdata->xs, mapdata->ys,filepath,strline(buffer,start-buffer));
|
|
}
|
|
}
|
|
|
|
|
|
- nd = npc_create_npc(m, x, y);
|
|
|
|
|
|
+ struct npc_data *nd = npc_create_npc(m, x, y);
|
|
npc_parsename(nd, w3, start, buffer, filepath);
|
|
npc_parsename(nd, w3, start, buffer, filepath);
|
|
|
|
|
|
|
|
+ bool is_type_warp2 = (strncasecmp(w2, "warp2", 5) == 0);
|
|
|
|
+
|
|
if (!battle_config.warp_point_debug)
|
|
if (!battle_config.warp_point_debug)
|
|
nd->class_ = JT_WARPNPC;
|
|
nd->class_ = JT_WARPNPC;
|
|
else
|
|
else
|
|
@@ -3909,7 +3907,7 @@ static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const
|
|
npc_warp++;
|
|
npc_warp++;
|
|
nd->bl.type = BL_NPC;
|
|
nd->bl.type = BL_NPC;
|
|
nd->subtype = NPCTYPE_WARP;
|
|
nd->subtype = NPCTYPE_WARP;
|
|
- if (strcasecmp("warp2", w2) == 0)
|
|
|
|
|
|
+ if (is_type_warp2)
|
|
nd->trigger_on_hidden = true;
|
|
nd->trigger_on_hidden = true;
|
|
else
|
|
else
|
|
nd->trigger_on_hidden = false;
|
|
nd->trigger_on_hidden = false;
|
|
@@ -3924,6 +3922,30 @@ static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const
|
|
clif_spawn(&nd->bl);
|
|
clif_spawn(&nd->bl);
|
|
strdb_put(npcname_db, nd->exname, nd);
|
|
strdb_put(npcname_db, nd->exname, nd);
|
|
|
|
|
|
|
|
+ // Check if there is a <state> in w2
|
|
|
|
+ if (is_type_warp2 && strcasecmp("warp2", w2) < 0 || !is_type_warp2 && strcasecmp("warp", w2) < 0) {
|
|
|
|
+ char state_name[128];
|
|
|
|
+ size_t length = strlen(w2);
|
|
|
|
+ int shift = (is_type_warp2 ? 6 : 5);
|
|
|
|
+
|
|
|
|
+ // state name
|
|
|
|
+ if (w2[shift-1] != '(' || w2[length-1] != ')' || length <= shift || length-shift >= sizeof(state_name))
|
|
|
|
+ ShowWarning("npc_parse_warp: Invalid npc state in file '%s', line '%d', defaulting to visible. w2=%s\n", filepath, strline(buffer,start-buffer), w2);
|
|
|
|
+ else {
|
|
|
|
+ safestrncpy(state_name, w2+shift, length-shift);
|
|
|
|
+ if (strcasecmp("CLOAKED", state_name) == 0)
|
|
|
|
+ nd->state = NPCVIEW_CLOAKON;
|
|
|
|
+ else if (strcasecmp("HIDDEN", state_name) == 0)
|
|
|
|
+ nd->state = NPCVIEW_HIDEON;
|
|
|
|
+ else if (strcasecmp("DISABLED", state_name) == 0)
|
|
|
|
+ nd->state = NPCVIEW_DISABLE;
|
|
|
|
+ else
|
|
|
|
+ ShowWarning("npc_parse_warp: Invalid npc state in file '%s', line '%d', defaulting to visible. w2=%s\n", filepath, strline(buffer,start-buffer), w2);
|
|
|
|
+ if (nd->state != NPCVIEW_ENABLE)
|
|
|
|
+ npc_enable_target(*nd, 0, nd->state);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
return strchr(start,'\n');// continue
|
|
return strchr(start,'\n');// continue
|
|
}
|
|
}
|
|
|
|
|
|
@@ -4313,8 +4335,8 @@ static const char* npc_skip_script(const char* start, const char* buffer, const
|
|
/**
|
|
/**
|
|
* Parses a npc script.
|
|
* Parses a npc script.
|
|
* Line definition :
|
|
* Line definition :
|
|
- * <map name>,<x>,<y>,<facing>%TAB%script%TAB%<NPC Name>%TAB%<sprite id>,{<code>}
|
|
|
|
- * <map name>,<x>,<y>,<facing>%TAB%script%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY>,{<code>} * @TODO missing cashshop line definition
|
|
|
|
|
|
+ * <map name>,<x>,<y>,<facing>%TAB%script(<state)%TAB%<NPC Name>%TAB%<sprite id>,{<code>}
|
|
|
|
+ * <map name>,<x>,<y>,<facing>%TAB%script(<state)%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY>,{<code>} * @TODO missing cashshop line definition
|
|
* @param w1 : word 1 before tab (<from map name>,<x>,<y>,<facing>)
|
|
* @param w1 : word 1 before tab (<from map name>,<x>,<y>,<facing>)
|
|
* @param w2 : word 2 before tab (script), keyword that sent us in this parsing
|
|
* @param w2 : word 2 before tab (script), keyword that sent us in this parsing
|
|
* @param w3 : word 3 before tab (<NPC Name>)
|
|
* @param w3 : word 3 before tab (<NPC Name>)
|
|
@@ -4424,6 +4446,30 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
|
|
}
|
|
}
|
|
strdb_put(npcname_db, nd->exname, nd);
|
|
strdb_put(npcname_db, nd->exname, nd);
|
|
|
|
|
|
|
|
+ // Check if there is a <state> in w2
|
|
|
|
+ if (strcasecmp("script", w2) < 0) {
|
|
|
|
+ char state_name[128];
|
|
|
|
+ size_t length = strlen(w2);
|
|
|
|
+ int shift = 7;
|
|
|
|
+
|
|
|
|
+ // state name
|
|
|
|
+ if (w2[shift-1] != '(' || w2[length-1] != ')' || length <= shift || length-shift >= sizeof(state_name))
|
|
|
|
+ ShowWarning("npc_parse_script: Invalid npc state in file '%s', line '%d', defaulting to visible. w2=%s\n", filepath, strline(buffer,start-buffer), w2);
|
|
|
|
+ else {
|
|
|
|
+ safestrncpy(state_name, w2+shift, length-shift);
|
|
|
|
+ if (strcasecmp("CLOAKED", state_name) == 0)
|
|
|
|
+ nd->state = NPCVIEW_CLOAKON;
|
|
|
|
+ else if (strcasecmp("HIDDEN", state_name) == 0)
|
|
|
|
+ nd->state = NPCVIEW_HIDEON;
|
|
|
|
+ else if (strcasecmp("DISABLED", state_name) == 0)
|
|
|
|
+ nd->state = NPCVIEW_DISABLE;
|
|
|
|
+ else
|
|
|
|
+ ShowWarning("npc_parse_script: Invalid npc state in file '%s', line '%d', defaulting to visible. w2=%s\n", filepath, strline(buffer,start-buffer), w2);
|
|
|
|
+ if (nd->state != NPCVIEW_ENABLE)
|
|
|
|
+ npc_enable_target(*nd, 0, nd->state);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//-----------------------------------------
|
|
//-----------------------------------------
|
|
// Loop through labels to export them as necessary
|
|
// Loop through labels to export them as necessary
|
|
for (i = 0; i < nd->u.scr.label_list_num; i++) {
|
|
for (i = 0; i < nd->u.scr.label_list_num; i++) {
|
|
@@ -4578,6 +4624,11 @@ const char* npc_parse_duplicate( char* w1, char* w2, char* w3, char* w4, const c
|
|
if( type != NPCTYPE_SCRIPT )
|
|
if( type != NPCTYPE_SCRIPT )
|
|
return end;
|
|
return end;
|
|
|
|
|
|
|
|
+ // copy the original npc state
|
|
|
|
+ if (dnd->state != NPCVIEW_ENABLE)
|
|
|
|
+ npc_enable_target(*nd, 0, dnd->state);
|
|
|
|
+ nd->state = dnd->state;
|
|
|
|
+
|
|
//-----------------------------------------
|
|
//-----------------------------------------
|
|
// Loop through labels to export them as necessary
|
|
// Loop through labels to export them as necessary
|
|
for (i = 0; i < nd->u.scr.label_list_num; i++) {
|
|
for (i = 0; i < nd->u.scr.label_list_num; i++) {
|
|
@@ -4655,6 +4706,11 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) {
|
|
if( map_getmapdata(wnd->bl.m)->users )
|
|
if( map_getmapdata(wnd->bl.m)->users )
|
|
clif_spawn(&wnd->bl);
|
|
clif_spawn(&wnd->bl);
|
|
strdb_put(npcname_db, wnd->exname, wnd);
|
|
strdb_put(npcname_db, wnd->exname, wnd);
|
|
|
|
+
|
|
|
|
+ // copy the original npc state
|
|
|
|
+ if (snd->state != NPCVIEW_ENABLE)
|
|
|
|
+ npc_enable_target(*wnd, 0, snd->state);
|
|
|
|
+ wnd->state = snd->state;
|
|
} else {
|
|
} else {
|
|
static char w1[128], w2[128], w3[128], w4[128];
|
|
static char w1[128], w2[128], w3[128], w4[128];
|
|
const char* stat_buf = "- call from instancing subsystem -\n";
|
|
const char* stat_buf = "- call from instancing subsystem -\n";
|
|
@@ -5512,33 +5568,24 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con
|
|
*/
|
|
*/
|
|
int npc_parsesrcfile(const char* filepath)
|
|
int npc_parsesrcfile(const char* filepath)
|
|
{
|
|
{
|
|
- int16 m, x, y;
|
|
|
|
- int lines = 0;
|
|
|
|
- FILE* fp;
|
|
|
|
- size_t len;
|
|
|
|
- char* buffer;
|
|
|
|
- const char* p;
|
|
|
|
-
|
|
|
|
- if(check_filepath(filepath)!=2) { //this is not a file
|
|
|
|
|
|
+ if (check_filepath(filepath) != 2) { //this is not a file
|
|
ShowDebug("npc_parsesrcfile: Path doesn't seem to be a file skipping it : '%s'.\n", filepath);
|
|
ShowDebug("npc_parsesrcfile: Path doesn't seem to be a file skipping it : '%s'.\n", filepath);
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
// read whole file to buffer
|
|
// read whole file to buffer
|
|
- fp = fopen(filepath, "rb");
|
|
|
|
- if( fp == NULL )
|
|
|
|
- {
|
|
|
|
|
|
+ FILE* fp = fopen(filepath, "rb");
|
|
|
|
+ if (fp == nullptr) {
|
|
ShowError("npc_parsesrcfile: File not found '%s'.\n", filepath);
|
|
ShowError("npc_parsesrcfile: File not found '%s'.\n", filepath);
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
fseek(fp, 0, SEEK_END);
|
|
fseek(fp, 0, SEEK_END);
|
|
- len = ftell(fp);
|
|
|
|
- buffer = (char*)aMalloc(len+1);
|
|
|
|
|
|
+ size_t len = ftell(fp);
|
|
|
|
+ char* buffer = (char*)aMalloc(len+1);
|
|
fseek(fp, 0, SEEK_SET);
|
|
fseek(fp, 0, SEEK_SET);
|
|
len = fread(buffer, 1, len, fp);
|
|
len = fread(buffer, 1, len, fp);
|
|
buffer[len] = '\0';
|
|
buffer[len] = '\0';
|
|
- if( ferror(fp) )
|
|
|
|
- {
|
|
|
|
|
|
+ if (ferror(fp)) {
|
|
ShowError("npc_parsesrcfile: Failed to read file '%s' - %s\n", filepath, strerror(errno));
|
|
ShowError("npc_parsesrcfile: Failed to read file '%s' - %s\n", filepath, strerror(errno));
|
|
aFree(buffer);
|
|
aFree(buffer);
|
|
fclose(fp);
|
|
fclose(fp);
|
|
@@ -5557,25 +5604,27 @@ int npc_parsesrcfile(const char* filepath)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ int lines = 0;
|
|
|
|
+
|
|
// parse buffer
|
|
// parse buffer
|
|
- for( p = skip_space(buffer); p && *p ; p = skip_space(p) )
|
|
|
|
- {
|
|
|
|
|
|
+ for ( const char* p = skip_space(buffer); p && *p ; p = skip_space(p) ) {
|
|
int pos[9];
|
|
int pos[9];
|
|
- char w1[2048], w2[2048], w3[2048], w4[2048];
|
|
|
|
- int i, count;
|
|
|
|
lines++;
|
|
lines++;
|
|
|
|
|
|
// w1<TAB>w2<TAB>w3<TAB>w4
|
|
// w1<TAB>w2<TAB>w3<TAB>w4
|
|
- count = sv_parse(p, len+buffer-p, 0, '\t', pos, ARRAYLENGTH(pos), (e_svopt)(SV_TERMINATE_LF|SV_TERMINATE_CRLF));
|
|
|
|
- if( count < 0 )
|
|
|
|
- {
|
|
|
|
|
|
+ int count = sv_parse(p, len+buffer-p, 0, '\t', pos, ARRAYLENGTH(pos), (e_svopt)(SV_TERMINATE_LF|SV_TERMINATE_CRLF));
|
|
|
|
+
|
|
|
|
+ if (count < 0) {
|
|
ShowError("npc_parsesrcfile: Parse error in file '%s', line '%d'. Stopping...\n", filepath, strline(buffer,p-buffer));
|
|
ShowError("npc_parsesrcfile: Parse error in file '%s', line '%d'. Stopping...\n", filepath, strline(buffer,p-buffer));
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ char w1[2048], w2[2048], w3[2048], w4[2048];
|
|
|
|
+
|
|
// fill w1
|
|
// fill w1
|
|
if( pos[3]-pos[2] > ARRAYLENGTH(w1)-1 )
|
|
if( pos[3]-pos[2] > ARRAYLENGTH(w1)-1 )
|
|
ShowWarning("npc_parsesrcfile: w1 truncated, too much data (%d) in file '%s', line '%d'.\n", pos[3]-pos[2], filepath, strline(buffer,p-buffer));
|
|
ShowWarning("npc_parsesrcfile: w1 truncated, too much data (%d) in file '%s', line '%d'.\n", pos[3]-pos[2], filepath, strline(buffer,p-buffer));
|
|
- i = min(pos[3]-pos[2], ARRAYLENGTH(w1)-1);
|
|
|
|
|
|
+ int i = min(pos[3]-pos[2], ARRAYLENGTH(w1)-1);
|
|
memcpy(w1, p+pos[2], i*sizeof(char));
|
|
memcpy(w1, p+pos[2], i*sizeof(char));
|
|
w1[i] = '\0';
|
|
w1[i] = '\0';
|
|
// fill w2
|
|
// fill w2
|
|
@@ -5593,8 +5642,7 @@ int npc_parsesrcfile(const char* filepath)
|
|
// fill w4 (to end of line)
|
|
// fill w4 (to end of line)
|
|
if( pos[1]-pos[8] > ARRAYLENGTH(w4)-1 )
|
|
if( pos[1]-pos[8] > ARRAYLENGTH(w4)-1 )
|
|
ShowWarning("npc_parsesrcfile: w4 truncated, too much data (%d) in file '%s', line '%d'.\n", pos[1]-pos[8], filepath, strline(buffer,p-buffer));
|
|
ShowWarning("npc_parsesrcfile: w4 truncated, too much data (%d) in file '%s', line '%d'.\n", pos[1]-pos[8], filepath, strline(buffer,p-buffer));
|
|
- if( pos[8] != -1 )
|
|
|
|
- {
|
|
|
|
|
|
+ if (pos[8] != -1) {
|
|
i = min(pos[1]-pos[8], ARRAYLENGTH(w4)-1);
|
|
i = min(pos[1]-pos[8], ARRAYLENGTH(w4)-1);
|
|
memcpy(w4, p+pos[8], i*sizeof(char));
|
|
memcpy(w4, p+pos[8], i*sizeof(char));
|
|
w4[i] = '\0';
|
|
w4[i] = '\0';
|
|
@@ -5602,82 +5650,74 @@ int npc_parsesrcfile(const char* filepath)
|
|
else
|
|
else
|
|
w4[0] = '\0';
|
|
w4[0] = '\0';
|
|
|
|
|
|
- if( count < 3 )
|
|
|
|
- {// Unknown syntax
|
|
|
|
|
|
+ if (count < 3) {// Unknown syntax
|
|
ShowError("npc_parsesrcfile: Unknown syntax in file '%s', line '%d'. Stopping...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,p-buffer), w1, w2, w3, w4);
|
|
ShowError("npc_parsesrcfile: Unknown syntax in file '%s', line '%d'. Stopping...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,p-buffer), w1, w2, w3, w4);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
- if( strcmp(w1,"-") !=0 && strcasecmp(w1,"function") != 0 )
|
|
|
|
- {// w1 = <map name>,<x>,<y>,<facing>
|
|
|
|
|
|
+ // Whether w2 contains word "script"
|
|
|
|
+ bool has_script = false;
|
|
|
|
+
|
|
|
|
+ if (count > 3 && strncasecmp(w2, "script", 6) == 0)
|
|
|
|
+ has_script = true;
|
|
|
|
+
|
|
|
|
+ if (strcmp(w1, "-") != 0 && strcasecmp(w1, "function") != 0) {// check the data of w1 = <map name>,<x>,<y>,<facing>
|
|
char mapname[MAP_NAME_LENGTH_EXT];
|
|
char mapname[MAP_NAME_LENGTH_EXT];
|
|
- int count2;
|
|
|
|
|
|
+ int16 x, y;
|
|
|
|
+ int count2 = sscanf(w1,"%15[^,],%6hd,%6hd[^,]",mapname,&x,&y);
|
|
|
|
|
|
- count2 = sscanf(w1,"%15[^,],%6hd,%6hd[^,]",mapname,&x,&y);
|
|
|
|
-
|
|
|
|
- if ( count2 < 1 ) {
|
|
|
|
|
|
+ if (count2 < 1) {
|
|
ShowError("npc_parsesrcfile: Invalid script definition in file '%s', line '%d'. Skipping line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,p-buffer), w1, w2, w3, w4);
|
|
ShowError("npc_parsesrcfile: Invalid script definition in file '%s', line '%d'. Skipping line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,p-buffer), w1, w2, w3, w4);
|
|
- if (strcasecmp(w2,"script") == 0 && count > 3) {
|
|
|
|
- if ((p = npc_skip_script(p,buffer,filepath)) == NULL)
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ if (has_script && (p = npc_skip_script(p,buffer,filepath)) == nullptr)
|
|
|
|
+ break;
|
|
p = strchr(p,'\n');// next line
|
|
p = strchr(p,'\n');// next line
|
|
continue;
|
|
continue;
|
|
- }else if( count2 < 3 ){
|
|
|
|
|
|
+ }
|
|
|
|
+ else if (count2 < 3) {
|
|
// If we were not able to parse any x and y coordinates(usually used by mapflags)
|
|
// If we were not able to parse any x and y coordinates(usually used by mapflags)
|
|
x = y = 0;
|
|
x = y = 0;
|
|
}
|
|
}
|
|
|
|
|
|
- if( !mapindex_name2id(mapname) )
|
|
|
|
- {// Incorrect map, we must skip the script info...
|
|
|
|
|
|
+ if (!mapindex_name2id(mapname)) {// Incorrect map, we must skip the script info...
|
|
ShowError("npc_parsesrcfile: Unknown map '%s' in file '%s', line '%d'. Skipping line...\n", mapname, filepath, strline(buffer,p-buffer));
|
|
ShowError("npc_parsesrcfile: Unknown map '%s' in file '%s', line '%d'. Skipping line...\n", mapname, filepath, strline(buffer,p-buffer));
|
|
- if( strcasecmp(w2,"script") == 0 && count > 3 )
|
|
|
|
- {
|
|
|
|
- if((p = npc_skip_script(p,buffer,filepath)) == NULL)
|
|
|
|
- {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (has_script && (p = npc_skip_script(p,buffer,filepath)) == nullptr)
|
|
|
|
+ break;
|
|
p = strchr(p,'\n');// next line
|
|
p = strchr(p,'\n');// next line
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- m = map_mapname2mapid(mapname);
|
|
|
|
- if( m < 0 )
|
|
|
|
- {// "mapname" is not assigned to this server, we must skip the script info...
|
|
|
|
- if( strcasecmp(w2,"script") == 0 && count > 3 )
|
|
|
|
- {
|
|
|
|
- if((p = npc_skip_script(p,buffer,filepath)) == NULL)
|
|
|
|
- {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ int16 m = map_mapname2mapid(mapname);
|
|
|
|
+ if (m < 0) {// "mapname" is not assigned to this server, we must skip the script info...
|
|
|
|
+ if (has_script && (p = npc_skip_script(p,buffer,filepath)) == nullptr)
|
|
|
|
+ break;
|
|
p = strchr(p,'\n');// next line
|
|
p = strchr(p,'\n');// next line
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- struct map_data *mapdata = map_getmapdata(m);
|
|
|
|
|
|
+ map_data *mapdata = map_getmapdata(m);
|
|
|
|
|
|
if (x < 0 || x >= mapdata->xs || y < 0 || y >= mapdata->ys) {
|
|
if (x < 0 || x >= mapdata->xs || y < 0 || y >= mapdata->ys) {
|
|
ShowError("npc_parsesrcfile: Unknown coordinates ('%d', '%d') for map '%s' in file '%s', line '%d'. Skipping line...\n", x, y, mapname, filepath, strline(buffer,p-buffer));
|
|
ShowError("npc_parsesrcfile: Unknown coordinates ('%d', '%d') for map '%s' in file '%s', line '%d'. Skipping line...\n", x, y, mapname, filepath, strline(buffer,p-buffer));
|
|
- if( strcasecmp(w2,"script") == 0 && count > 3 )
|
|
|
|
- {
|
|
|
|
- if((p = npc_skip_script(p,buffer,filepath)) == NULL)
|
|
|
|
- {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (has_script && (p = npc_skip_script(p,buffer,filepath)) == nullptr)
|
|
|
|
+ break;
|
|
p = strchr(p,'\n');// next line
|
|
p = strchr(p,'\n');// next line
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if((strcasecmp(w2,"warp") == 0 || strcasecmp(w2,"warp2") == 0) && count > 3)
|
|
|
|
|
|
+ // parse the data according to w2
|
|
|
|
+ if ((strncasecmp(w2, "warp", 4) == 0 || strncasecmp(w2, "warp2", 5) == 0) && count > 3)
|
|
p = npc_parse_warp(w1,w2,w3,w4, p, buffer, filepath);
|
|
p = npc_parse_warp(w1,w2,w3,w4, p, buffer, filepath);
|
|
- else if( (!strcasecmp(w2,"shop") || !strcasecmp(w2,"cashshop") || !strcasecmp(w2,"itemshop") || !strcasecmp(w2,"pointshop") || !strcasecmp(w2,"marketshop") ) && count > 3 )
|
|
|
|
|
|
+ else if ((!strcasecmp(w2,"shop") || !strcasecmp(w2,"cashshop") || !strcasecmp(w2,"itemshop") || !strcasecmp(w2,"pointshop") || !strcasecmp(w2,"marketshop") ) && count > 3)
|
|
p = npc_parse_shop(w1,w2,w3,w4, p, buffer, filepath);
|
|
p = npc_parse_shop(w1,w2,w3,w4, p, buffer, filepath);
|
|
- else if( strcasecmp(w2,"script") == 0 && count > 3 ) {
|
|
|
|
- if( strcasecmp(w1,"function") == 0 )
|
|
|
|
- p = npc_parse_function(w1, w2, w3, w4, p, buffer, filepath);
|
|
|
|
|
|
+ else if (has_script) {
|
|
|
|
+ if (strcasecmp(w1,"function") == 0) {
|
|
|
|
+ if (strcasecmp(w2,"script") == 0)
|
|
|
|
+ p = npc_parse_function(w1, w2, w3, w4, p, buffer, filepath);
|
|
|
|
+ else {
|
|
|
|
+ ShowError("npc_parsesrcfile: Unable to parse, probably a missing or extra TAB in file '%s', line '%d'. Skipping line...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,p-buffer), w1, w2, w3, w4);
|
|
|
|
+ p = strchr(p,'\n');// skip and continue
|
|
|
|
+ }
|
|
|
|
+ }
|
|
else
|
|
else
|
|
p = npc_parse_script(w1,w2,w3,w4, p, buffer, filepath);
|
|
p = npc_parse_script(w1,w2,w3,w4, p, buffer, filepath);
|
|
}
|
|
}
|