From b2720eebfb21f9334137749cdbac19f4bfc4bc3d Mon Sep 17 00:00:00 2001 From: Emistry Haoyan Date: Wed, 10 Jul 2019 02:27:58 +0800 Subject: Update atreloadmob to update living mobs - fix living mobs aren't updated by latest mob_db upon updated. from https://github.com/rathena/rathena/issues/3783 --- src/map/mob.c | 25 +++++++++++++++++++++++++ src/map/mob.h | 1 + 2 files changed, 26 insertions(+) diff --git a/src/map/mob.c b/src/map/mob.c index 8511f8523..404a240c9 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -5547,6 +5547,29 @@ static int mob_final_ratio_sub(union DBKey key, struct DBData *data, va_list ap) return 0; } +static int mob_reload_sub_mob(struct mob_data *md, va_list args) +{ + nullpo_ret(md); + md->db = mob_db(md->class_); + + status_calc_mob(md, SCO_FIRST); + + // If the view data was not overwritten manually + if (md->vd != NULL) { + // Get the new view data from the mob database + md->vd = mob_get_viewdata(md->class_); + + // If they are spawned right now + if (md->bl.prev != NULL) { + // Respawn all mobs on client side so that they are displayed correctly(if their view id changed) + clif->clearunit_area(&md->bl, CLR_OUTSIGHT); + clif->spawn(&md->bl); + } + } + + return 0; +} + static void mob_reload(void) { int i; @@ -5570,6 +5593,7 @@ static void mob_reload(void) mob->destroy_drop_groups(); mob->load(false); + map->foreachmob(mob->reload_sub_mob); } /** @@ -5726,6 +5750,7 @@ void mob_defaults(void) /* */ mob->reload = mob_reload; + mob->reload_sub_mob = mob_reload_sub_mob; mob->init = do_init_mob; mob->final = do_final_mob; /* */ diff --git a/src/map/mob.h b/src/map/mob.h index b63efd272..0a7489c47 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -488,6 +488,7 @@ struct mob_interface { int (*init) (bool mimimal); int (*final) (void); void (*reload) (void); + int (*reload_sub_mob) (struct mob_data *md, va_list args); /* */ struct mob_db* (*db) (int index); struct mob_chat* (*chat) (short id); -- cgit v1.2.3-60-g2f50