summaryrefslogtreecommitdiff
path: root/src/map/npc.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-02-07 00:07:47 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-02-07 00:07:47 +0000
commit1c388b20fe58a62b05aa7364def81f196a9d1146 (patch)
tree12aaa4d0ae4d9ce5838bbc6eb5916f477a9e0d33 /src/map/npc.c
parent666e165062c189847ee654e8ac22d98075f75fe5 (diff)
downloadhercules-1c388b20fe58a62b05aa7364def81f196a9d1146.tar.gz
hercules-1c388b20fe58a62b05aa7364def81f196a9d1146.tar.bz2
hercules-1c388b20fe58a62b05aa7364def81f196a9d1146.tar.xz
hercules-1c388b20fe58a62b05aa7364def81f196a9d1146.zip
- Fixed Freezing Trap doing no damage (changed type from misc to weapon)
- Changed suiton's element to water (apparently fixes not being able to use water-based skills on it) - Fixed Landmine doing no damage (decreased trigger range to 0 to match its splash range) - Fixed the disguise commands using the wrong variable when attempting to disguise as an npc. - Fixed a compilation warning on CELL_CHKNODAMAGE (which is a totally bad-ripoff of basilica cells anyway) - Corrected and optimized npc_remove_map's npc array cleanup (@reloadscripts no longer report 'too many npcs per map and related dangling pointer crashes are fixed) - Removed suspicious, yet totally unused npc_data variable 'n' - HP loss item scripts can no longer kill you. - Corrected the item-drop-rate check to avoid duplicate entries in @whodrops after a @reloadmobdb - Cleaned up and optimized map_addnpc (there are never any gaps in the npc array so npc_num always points to the last valid entry) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12180 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/npc.c')
-rw-r--r--src/map/npc.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/map/npc.c b/src/map/npc.c
index 27110a996..dbb190ebb 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -1211,10 +1211,11 @@ int npc_remove_map(struct npc_data* nd)
map_delblock(&nd->bl);
//Remove npc from map[].npc list. [Skotlex]
ARR_FIND( 0, map[m].npc_num, i, map[m].npc[i] == nd );
- if( i >= map[m].npc_num ) return 2; //failed to find it?
+ if( i == map[m].npc_num ) return 2; //failed to find it?
map[m].npc_num--;
- memmove(&map[m].npc[i], &map[m].npc[i+1], (map[m].npc_num-i)*sizeof(map[m].npc[0]));
+ map[m].npc[i] = map[m].npc[map[m].npc_num];
+ map[m].npc[map[m].npc_num] = NULL;
return 0;
}
@@ -1452,7 +1453,7 @@ struct npc_data* npc_add_warp(short from_mapid, short from_x, short from_y, shor
CREATE(nd, struct npc_data, 1);
nd->bl.id = npc_get_new_npc_id();
- nd->n = map_addnpc(from_mapid, nd);
+ map_addnpc(from_mapid, nd);
nd->bl.prev = nd->bl.next = NULL;
nd->bl.m = from_mapid;
nd->bl.x = from_x;
@@ -1514,7 +1515,7 @@ static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const
CREATE(nd, struct npc_data, 1);
nd->bl.id = npc_get_new_npc_id();
- nd->n = map_addnpc(m, nd);
+ map_addnpc(m, nd);
nd->bl.prev = nd->bl.next = NULL;
nd->bl.m = m;
nd->bl.x = x;
@@ -1622,7 +1623,7 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
nd->subtype = SHOP;
if( m >= 0 )
{// normal shop npc
- nd->n = map_addnpc(m,nd);
+ map_addnpc(m,nd);
map_addblock(&nd->bl);
status_set_viewdata(&nd->bl, nd->class_);
status_change_init(&nd->bl);
@@ -1858,7 +1859,7 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
if( m >= 0 )
{
- nd->n = map_addnpc(m, nd);
+ map_addnpc(m, nd);
status_change_init(&nd->bl);
unit_dataset(&nd->bl);
nd->ud.dir = dir;