summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-11-12 04:15:18 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-11-12 04:15:18 +0000
commite9b4674c08837939dba88d8cfed7494931ac647a (patch)
tree272ec2980a7c43bba9f55b7352c1f6e6e5f363cf /src/map/npc.c
parent74b3120bb7776371ed815c6c038fd467ef4ac366 (diff)
downloadhercules-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/npc.c')
-rw-r--r--src/map/npc.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index 4752991c7..5d98f761e 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1481,8 +1481,49 @@ static void npc_parsename(struct npc_data* nd, const char* name, const char* sta
}
}
+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)
+{
+ int i;
+ struct npc_data *nd;
+
+ CREATE(nd, struct npc_data, 1);
+ nd->bl.id = npc_get_new_npc_id();
+ nd->n = map_addnpc(from_mapid, nd);
+ nd->bl.prev = nd->bl.next = NULL;
+ nd->bl.m = from_mapid;
+ nd->bl.x = from_x;
+ nd->bl.y = from_y;
+ safestrncpy(nd->name, "", ARRAYLENGTH(nd->name));// empty display name
+ 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);
+
+ if( battle_config.warp_point_debug )
+ nd->class_ = WARP_DEBUG_CLASS;
+ else
+ nd->class_ = WARP_CLASS;
+ nd->speed = 200;
+
+ nd->u.warp.mapindex = to_mapindex;
+ nd->u.warp.x = to_x;
+ nd->u.warp.y = to_y;
+ nd->u.warp.xs = xs+2;// TODO why +2? [FlavioJS]
+ nd->u.warp.ys = xs+2;
+ nd->bl.type = BL_NPC;
+ nd->bl.subtype = WARP;
+ npc_setcells(nd);
+ map_addblock(&nd->bl);
+ status_set_viewdata(&nd->bl, nd->class_);
+ status_change_init(&nd->bl);
+ unit_dataset(&nd->bl);
+ clif_spawn(&nd->bl);
+ strdb_put(npcname_db, nd->exname, nd);
+
+ return nd;
+}
+
/// Parses a warp npc.
-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 x, y, xs, ys, to_x, to_y, m;
unsigned short i;