From b10caa039b2faef0354d82d3b50552691fb8278d Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Tue, 2 Jun 2020 19:36:49 +0200 Subject: [PATCH] Fixed slave recalculation on reloadmobdb Slaves sometimes ended up with weird status calculations or insane speed, because their status got recalculated before their master and this way their speed could not be copied from the master. Thanks to @Daegaladh --- src/map/mob.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/map/mob.cpp b/src/map/mob.cpp index 56c914c67e..53be39c348 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -5647,6 +5647,20 @@ void mob_reload_itemmob_data(void) { * @return 0 */ static int mob_reload_sub( struct mob_data *md, va_list args ){ + bool slaves_only = va_arg( args, bool ); + + if( slaves_only ){ + if( md->master_id == 0 ){ + // Only slaves should be processed now + return 0; + } + }else{ + if( md->master_id != 0 ){ + // Slaves will be processed later + return 0; + } + } + // Relink the mob to the new database entry md->db = mob_db(md->mob_id); @@ -5695,7 +5709,10 @@ static int mob_reload_sub_npc( struct npc_data *nd, va_list args ){ void mob_reload(void) { do_final_mob(true); mob_db_load(true); - map_foreachmob(mob_reload_sub); + // First only normal monsters + map_foreachmob( mob_reload_sub, false ); + // Then slaves only + map_foreachmob( mob_reload_sub, true ); map_foreachnpc(mob_reload_sub_npc); }