summaryrefslogtreecommitdiff
path: root/src/map/mob.c
diff options
context:
space:
mode:
authorgreenboxal2 <greenboxal2@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-06-18 21:51:08 +0000
committergreenboxal2 <greenboxal2@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-06-18 21:51:08 +0000
commit380cf32eb6eab01d1d6786f9a1255a68a5f9aa1a (patch)
tree238e6d2fdffe627e0e4e89e91aee1396dad9bc11 /src/map/mob.c
parent55cb028a87b11bd7cbc06a3fcdba4f77032fa6c6 (diff)
downloadhercules-380cf32eb6eab01d1d6786f9a1255a68a5f9aa1a.tar.gz
hercules-380cf32eb6eab01d1d6786f9a1255a68a5f9aa1a.tar.bz2
hercules-380cf32eb6eab01d1d6786f9a1255a68a5f9aa1a.tar.xz
hercules-380cf32eb6eab01d1d6786f9a1255a68a5f9aa1a.zip
Little optimization on MVP tombstone system, maybe fix insane CPU usage spikes(bugreport:5968).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16318 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/mob.c')
-rw-r--r--src/map/mob.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index b3316b5e9..86eee36f5 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -131,9 +131,12 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time)
{
struct npc_data *nd;
+ if (md->tomb_npc != NULL)
+ mvptomb_destroy(md);
+
CREATE(nd, struct npc_data, 1);
- nd->bl.id = md->tomb_nid = npc_get_new_npc_id();
+ nd->bl.id = npc_get_new_npc_id();
nd->ud.dir = md->ud.dir;
nd->bl.m = md->bl.m;
@@ -161,16 +164,18 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time)
status_change_init(&nd->bl);
unit_dataset(&nd->bl);
clif_spawn(&nd->bl);
+
+ md->tomb_npc = nd;
}
void mvptomb_destroy(struct mob_data *md)
{
- struct npc_data *nd = (struct npc_data *)map_id2bl(md->tomb_nid);
+ struct npc_data *nd = md->tomb_npc;
if (nd)
npc_unload(nd,true);
- md->tomb_nid = 0;
+ md->tomb_npc = NULL;
}
/*==========================================
@@ -966,7 +971,7 @@ int mob_spawn (struct mob_data *md)
md->sc.option = md->db->option;
// MvP tomb [GreenBox]
- if (md->tomb_nid)
+ if (md->tomb_npc)
mvptomb_destroy(md);
map_addblock(&md->bl);