Преглед на файлове

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);
 }