diff options
author | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-11-12 04:15:18 +0000 |
---|---|---|
committer | FlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2007-11-12 04:15:18 +0000 |
commit | e9b4674c08837939dba88d8cfed7494931ac647a (patch) | |
tree | 272ec2980a7c43bba9f55b7352c1f6e6e5f363cf /src/map/atcommand.c | |
parent | 74b3120bb7776371ed815c6c038fd467ef4ac366 (diff) | |
download | hercules-e9b4674c08837939dba88d8cfed7494931ac647a.tar.gz hercules-e9b4674c08837939dba88d8cfed7494931ac647a.tar.bz2 hercules-e9b4674c08837939dba88d8cfed7494931ac647a.tar.xz hercules-e9b4674c08837939dba88d8cfed7494931ac647a.zip |
* Fixed @addwarp crashing the map server (bugreport:390).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11719 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r-- | src/map/atcommand.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 32a07e132..ed16dcdf1 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -5492,27 +5492,33 @@ int atcommand_npcmove(const int fd, struct map_session_data* sd, const char* com *------------------------------------------*/ int atcommand_addwarp(const int fd, struct map_session_data* sd, const char* command, const char* message) { - char w1[64], w3[64], w4[64]; - int x,y,ret=0; + char mapname[32]; + int x,y; + unsigned short m; + struct npc_data* nd; + nullpo_retr(-1, sd); - if (!message || !*message || sscanf(message, "%23s %d %d[^\n]", atcmd_player_name, &x, &y) < 3) { + if (!message || !*message || sscanf(message, "%31s %d %d", mapname, &x, &y) < 3) { clif_displaymessage(fd, "usage: @addwarp <mapname> <X> <Y>."); return -1; } - sprintf(w1,"%s,%d,%d", mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y); - sprintf(w3,"%s%d%d%d%d", atcmd_player_name,sd->bl.x, sd->bl.y, x, y); - sprintf(w4,"1,1,%s,%d,%d", atcmd_player_name, x, y); - - // FIXME check if it failed [FlavioJS] - npc_parse_warp(w1, "warp", w3, w4, NULL, NULL, "console"); + m = mapindex_name2id(mapname); + if( m == 0 ) + { + sprintf(atcmd_output, "Unknown map '%s'.", mapname); + clif_displaymessage(fd, atcmd_output); + return -1; + } - sprintf(atcmd_output, "New warp NPC => %s",w3); + nd = npc_add_warp(sd->bl.m, sd->bl.x, sd->bl.y, 1, 1, m, x, y); + if( nd == NULL ) + return -1; + sprintf(atcmd_output, "New warp NPC '%s' created.", nd->exname); clif_displaymessage(fd, atcmd_output); - - return ret; + return 0; } /*========================================== |