diff --git a/src/map/map.cpp b/src/map/map.cpp index f3eb4c32b4..28908147b1 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -223,7 +223,7 @@ uint64 MapZoneDatabase::parseBodyNode(const ryml::NodeRef& node) { if (!exists) { zone = std::make_shared(); - zone->id = zone_id; + zone->id = static_cast(zone_id); } if (this->nodeExists(node, "DisabledCommands")) { @@ -537,27 +537,6 @@ void MapZoneDatabase::loadingFinished() { } } -/** - * Get the zone to a map. - * @param map_id: Map ID - * @return e_map_type on success or MAPTYPE_UNUSED otherwise - */ -e_map_type MapZoneDatabase::getMapZone(int16 map_id) { - map_data *mapdata = map_getmapdata(map_id); - - if (mapdata == nullptr) { - ShowError("MapZoneDatabase::getMapZone: Unknown map ID %d, skipping.\n", map_id); - return MAPTYPE_UNUSED; - } - - for (const auto &zone : map_zone_db) { - if (util::vector_exists(zone.second->maps, map_id)) - return static_cast(zone.second->id); - } - - return MAPTYPE_UNUSED; -} - /** * Set the zone to a map. * @param map_id: Map ID @@ -600,6 +579,22 @@ bool MapZoneDatabase::setZone(int16 map_id, e_map_type zone) { MapZoneDatabase map_zone_db; +/** + * Get the zone to a map. + * @param map_id: Map ID + * @return e_map_type on success or MAPTYPE_UNUSED otherwise + */ +e_map_type c_map_zone_data::getMapZone(int16 map_id) { + map_data *mapdata = map_getmapdata(map_id); + + if (mapdata == nullptr) { + ShowError("MapZoneDatabase::getMapZone: Unknown map ID %d, skipping.\n", map_id); + return MAPTYPE_UNUSED; + } + + return mapdata->zone->id; +} + /** * Check if a command is disabled on a map based on group level. * @param name: Command name diff --git a/src/map/map.hpp b/src/map/map.hpp index de24a4d6c9..033489cf57 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -815,13 +815,14 @@ struct iwall_data { class c_map_zone_data { public: - uint16 id; + e_map_type id; std::unordered_map disabled_commands; std::unordered_map> disabled_skills; std::unordered_map disabled_items; std::unordered_map disabled_statuses; std::unordered_map restricted_jobs; + e_map_type getMapZone(int16 map_id); bool isCommandDisabled(std::string name, map_session_data &sd); bool isSkillDisabled(uint16 skill_id, block_list &bl); bool isItemDisabled(t_itemid nameid, map_session_data &sd); @@ -905,7 +906,6 @@ public: void loadingFinished() override; // Others - e_map_type getMapZone(int16 map_id); bool setZone(int16 map_id, e_map_type zone); };