summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/atcommand.c9
-rw-r--r--src/map/npc.c16
-rw-r--r--src/map/npc.h2
3 files changed, 19 insertions, 8 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 25fc3182d..5d032c457 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -5259,15 +5259,16 @@ ACMD_FUNC(npcmove)
*------------------------------------------*/
ACMD_FUNC(addwarp)
{
- char mapname[32];
+ char mapname[32], warpname[NAME_LENGTH+1];
int x,y;
unsigned short m;
struct npc_data* nd;
nullpo_retr(-1, sd);
+ memset(warpname, '\0', sizeof(warpname));
- if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) {
- clif_displaymessage(fd, msg_txt(1156)); // Usage: @addwarp <mapname> <X> <Y>
+ if (!message || !*message || sscanf(message, "%31s %d %d %23[^\n]", mapname, &x, &y, warpname) < 3) {
+ clif_displaymessage(fd, msg_txt(1156)); // Usage: @addwarp <mapname> <X> <Y> {<npc name>}
return -1;
}
@@ -5279,7 +5280,7 @@ ACMD_FUNC(addwarp)
return -1;
}
- nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
+ nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
if( nd == NULL )
return -1;
diff --git a/src/map/npc.c b/src/map/npc.c
index 62a263e5a..0ed3dd68b 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -2008,9 +2008,9 @@ static void npc_parsename(struct npc_data* nd, const char* name, const char* sta
}
//Add then display an npc warp on map
-struct npc_data* npc_add_warp(short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y)
+struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y)
{
- int i;
+ int i, flag = 0;
struct npc_data *nd;
CREATE(nd, struct npc_data, 1);
@@ -2020,7 +2020,17 @@ struct npc_data* npc_add_warp(short from_mapid, short from_x, short from_y, shor
nd->bl.m = from_mapid;
nd->bl.x = from_x;
nd->bl.y = from_y;
- snprintf(nd->exname, ARRAYLENGTH(nd->exname), "warp_%d_%d_%d", from_mapid, from_x, from_y);
+
+ if (name)
+ {
+ safestrncpy(nd->exname, name, ARRAYLENGTH(nd->exname));
+ if (npc_name2id(nd->exname) != NULL)
+ flag = 1;
+ }
+
+ if (name[0] == '\0' || flag == 1)
+ snprintf(nd->exname, ARRAYLENGTH(nd->exname), "warp_%d_%d_%d", from_mapid, from_x, from_y);
+
for( i = 0; npc_name2id(nd->exname) != NULL; ++i )
snprintf(nd->exname, ARRAYLENGTH(nd->exname), "warp%d_%d_%d_%d", i, from_mapid, from_x, from_y);
safestrncpy(nd->name, nd->exname, ARRAYLENGTH(nd->name));
diff --git a/src/map/npc.h b/src/map/npc.h
index 29cf39c77..0379ae634 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -120,7 +120,7 @@ int npc_buysellsel(struct map_session_data* sd, int id, int type);
int npc_buylist(struct map_session_data* sd,int n, unsigned short* item_list);
int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list);
void npc_parse_mob2(struct spawn_data* mob);
-struct npc_data* npc_add_warp(short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y);
+struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y);
int npc_globalmessage(const char* name,const char* mes);
void npc_setcells(struct npc_data* nd);