Forráskód Böngészése

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://svn.code.sf.net/p/rathena/svn/trunk@16919 54d463be-8e91-2dee-dedb-b68131a5f0ec

momacabu 12 éve
szülő
commit
069793e804
4 módosított fájl, 20 hozzáadás és 9 törlés
  1. 1 1
      conf/msg_athena.conf
  2. 5 4
      src/map/atcommand.c
  3. 13 3
      src/map/npc.c
  4. 1 1
      src/map/npc.h

+ 1 - 1
conf/msg_athena.conf

@@ -984,7 +984,7 @@
 1155: NPC moved.
 
 // @addwarp
-1156: Usage: @addwarp <mapname> <X> <Y>
+1156: Usage: @addwarp <mapname> <X> <Y> {<npc name>}
 1157: Unknown map '%s'.
 1158: New warp NPC '%s' created.
 

+ 5 - 4
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;
 

+ 13 - 3
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));

+ 1 - 1
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);