From e148bd3a6360f7789dbee13fbb81f64ee550c134 Mon Sep 17 00:00:00 2001 From: Jey Date: Thu, 16 Nov 2017 11:17:58 +0100 Subject: [PATCH] Follow up to ba9314cba590f831c88b7a6a69afb62f4d51fe59 * Now mob_get_spawn does not add empty vectors to mob_spawn_data, when the mobid does not exist in mob_spawn_data * Saves a bit more memory space * Thanks to @Lemongrass3110 for the suggestion --- src/map/mob.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/map/mob.cpp b/src/map/mob.cpp index 211de72814..5052582a48 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -3129,12 +3129,15 @@ int mob_random_class(int *value, size_t count) } /** -* Returns the SpawnInfos of the mob_db entry +* 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 */ const std::vector mob_db::get_spawns() const { - // Returns an empty std::vector if mob_id is not in mob_spawn_data - return mob_spawn_data[this->get_mobid()]; + auto mob_spawn_it = mob_spawn_data.find(this->get_mobid()); + if ( mob_spawn_it != mob_spawn_data.end() ) + return mob_spawn_it->second; + return std::vector(); } /**