瀏覽代碼

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
Lemongrass3110 5 年之前
父節點
當前提交
b10caa039b
共有 1 個文件被更改,包括 18 次插入1 次删除
  1. 18 1
      src/map/mob.cpp

+ 18 - 1
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);
 }