From 1da444ee4f4c92bc69c9e2e897e0bf4674e52bc8 Mon Sep 17 00:00:00 2001 From: toms Date: Thu, 10 Aug 2006 23:34:35 +0000 Subject: Code cleanup on homunc, they stay in memory until player disconnect or homunc destruction git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8241 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/unit.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'src/map/unit.c') diff --git a/src/map/unit.c b/src/map/unit.c index c9a7c5176..d7c512714 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1605,6 +1605,30 @@ int unit_remove_map(struct block_list *bl, int clrtype) { map_freeblock_unlock(); return 0; } + } else if (bl->type == BL_HOM) { + struct homun_data *hd = (struct homun_data *) bl; + struct map_session_data *sd = hd->master; + + // Desactive timers + merc_hom_hungry_timer_delete(hd); + merc_natural_heal_timer_delete(hd); + + if(!sd) { + map_delblock(bl); + unit_free(bl); + map_freeblock_unlock(); + return 0; + } + + // Homunc was deleted or player is leaving the server, remove it from memory + if (sd->homunculus.hom_id == 0 || sd->state.waitingdisconnect) + { //Remove pet. + map_delblock(bl); + unit_free(bl); + sd->hd = NULL; + map_freeblock_unlock(); + return 1; + } } map_delblock(bl); map_freeblock_unlock(); @@ -1770,16 +1794,6 @@ int unit_free(struct block_list *bl) { } if(mob_is_clone(md->class_)) mob_clone_delete(md->class_); - } else if( bl->type == BL_HOM ) { //[orn] - struct homun_data *hd = (struct homun_data*)bl; - struct map_session_data *sd = hd->master; - merc_hom_hungry_timer_delete(hd); - merc_natural_heal_timer_delete(hd) ; - if (sd) { -// if(hd->intimacy > 0) -// intif_save_mercdata(sd->status.account_id,&sd->hom); - sd->hd = NULL; - } } skill_clear_unitgroup(bl); -- cgit v1.2.3-60-g2f50