summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authormomacabu <momacabu@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-11-12 02:46:28 +0000
committermomacabu <momacabu@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-11-12 02:46:28 +0000
commita1ad56d8c1e5d07c3dbe3b3d3d54c94650febeaa (patch)
tree50a71b098f2c89fb28df649f46221c2b2f7499a7 /src/map/npc.c
parent94898ebfcf8ccdae5b064fa27f843136c19e2a65 (diff)
downloadhercules-a1ad56d8c1e5d07c3dbe3b3d3d54c94650febeaa.tar.gz
hercules-a1ad56d8c1e5d07c3dbe3b3d3d54c94650febeaa.tar.bz2
hercules-a1ad56d8c1e5d07c3dbe3b3d3d54c94650febeaa.tar.xz
hercules-a1ad56d8c1e5d07c3dbe3b3d3d54c94650febeaa.zip
Modified @addwarp to accept a new optional parameter <npc name>. If <npc name> is specified, then the warp created will have that name.
Otherwise it will use a name chosen by the emulator. If there is already another warp with that name the generic name will be used instead. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16919 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c16
1 files changed, 13 insertions, 3 deletions
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));