diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 9f1ef2db8a..0c52d4a79b 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -7865,17 +7865,20 @@ ACMD_FUNC(whereis) snprintf(atcmd_output, sizeof atcmd_output, msg_txt(sd,1289), mob->jname); // %s spawns in: clif_displaymessage(fd, atcmd_output); - const std::vector spawns = mob->get_spawns(); - for(auto& spawn : spawns) - { - int16 mapid = map_mapindex2mapid(spawn.mapindex); - if (mapid < 0) - continue; - snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[mapid].name, spawn.qty); - clif_displaymessage(fd, atcmd_output); + const std::vector spawns = mob_get_spawns(mob_id); + if (spawns.size() <= 0) { + // This monster does not spawn normally. + clif_displaymessage(fd, msg_txt(sd,1290)); + } else { + for(auto& spawn : spawns) + { + int16 mapid = map_mapindex2mapid(spawn.mapindex); + if (mapid < 0) + continue; + snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[mapid].name, spawn.qty); + clif_displaymessage(fd, atcmd_output); + } } - if (spawns.size() <= 0) - clif_displaymessage(fd, msg_txt(sd,1290)); // This monster does not spawn normally. } return 0; diff --git a/src/map/mob.cpp b/src/map/mob.cpp index 64b24c5cad..386e82ea1a 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -303,7 +303,7 @@ static bool mobdb_searchname_sub(uint16 mob_id, const char * const str, bool ful if( mobdb_checkid(mob_id) <= 0 ) return false; // invalid mob_id (includes clone check) - if(!mob->base_exp && !mob->job_exp && !mob->has_spawn()) + if(!mob->base_exp && !mob->job_exp && !mob_has_spawn(mob_id)) return false; // Monsters with no base/job exp and no spawn point are, by this criteria, considered "slave mobs" and excluded from search results if( full_cmp ) { // str must equal the db value @@ -531,7 +531,7 @@ int mob_get_random_id(int type, int flag, int lv) (flag&0x01 && (entry->rate < 1000000 && entry->rate <= rnd() % 1000000)) || (flag&0x02 && lv < mob->lv) || (flag&0x04 && status_has_mode(&mob->status,MD_STATUS_IMMUNE) ) || - (flag&0x08 && !mob->has_spawn()) || + (flag&0x08 && !mob_has_spawn(mob_id)) || (flag&0x10 && status_has_mode(&mob->status,MD_IGNOREMELEE|MD_IGNOREMAGIC|MD_IGNORERANGED|MD_IGNOREMISC) ) ) && (i++) < MAX_MOB_DB && msummon->count > 1); @@ -3150,10 +3150,11 @@ int mob_random_class(int *value, size_t count) /** * Returns the SpawnInfos of the mob_db entry (mob_spawn_data[mobid]) * if mobid is not in mob_spawn_data returns empty spawn_info vector +* @param mob_id - Looking for spawns of this Monster ID */ -const std::vector mob_db::get_spawns() const +const std::vector mob_get_spawns(uint16 mob_id) { - auto mob_spawn_it = mob_spawn_data.find(this->get_mobid()); + auto mob_spawn_it = mob_spawn_data.find(mob_id); if ( mob_spawn_it != mob_spawn_data.end() ) return mob_spawn_it->second; return std::vector(); @@ -3161,12 +3162,13 @@ const std::vector mob_db::get_spawns() const /** * Checks if a monster is spawned. Returns true if yes, false otherwise. + * @param mob_id - Monster ID which is checked */ -bool mob_db::has_spawn() const +bool mob_has_spawn(uint16 mob_id) { // It's enough to check if the monster is in mob_spawn_data, because // none or empty spawns are ignored. Thus the monster is spawned. - return mob_spawn_data.find(this->get_mobid()) != mob_spawn_data.end(); + return mob_spawn_data.find(mob_id) != mob_spawn_data.end(); } /** diff --git a/src/map/mob.hpp b/src/map/mob.hpp index b25254eee0..adc107f958 100644 --- a/src/map/mob.hpp +++ b/src/map/mob.hpp @@ -155,9 +155,6 @@ struct mob_db { unsigned int option; int maxskill; struct mob_skill skill[MAX_MOBSKILL]; - bool has_spawn() const; - const std::vector get_spawns() const; - uint16 get_mobid() const {return vd.class_; } // Simple wrapper. The MobID is saved in vd, noone wants to remind that }; struct mob_data { @@ -352,6 +349,8 @@ int mob_clone_delete(struct mob_data *md); void mob_reload_itemmob_data(void); void mob_reload(void); void mob_add_spawn(uint16 mob_id, const struct spawn_info& new_spawn); +const std::vector mob_get_spawns(uint16 mob_id); +bool mob_has_spawn(uint16 mob_id); // MvP Tomb System int mvptomb_setdelayspawn(struct npc_data *nd);