Adjust getMapZone
* Change the lookup method for getMapZone to utilize the value stored in the map_data rather than looking through map_zone memory bringing faster results.
This commit is contained in:
parent
73ea1ac54d
commit
394d502e1b
@ -223,7 +223,7 @@ uint64 MapZoneDatabase::parseBodyNode(const ryml::NodeRef& node) {
|
|||||||
|
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
zone = std::make_shared<c_map_zone>();
|
zone = std::make_shared<c_map_zone>();
|
||||||
zone->id = zone_id;
|
zone->id = static_cast<e_map_type>(zone_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->nodeExists(node, "DisabledCommands")) {
|
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<e_map_type>(zone.second->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return MAPTYPE_UNUSED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the zone to a map.
|
* Set the zone to a map.
|
||||||
* @param map_id: Map ID
|
* @param map_id: Map ID
|
||||||
@ -600,6 +579,22 @@ bool MapZoneDatabase::setZone(int16 map_id, e_map_type zone) {
|
|||||||
|
|
||||||
MapZoneDatabase map_zone_db;
|
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.
|
* Check if a command is disabled on a map based on group level.
|
||||||
* @param name: Command name
|
* @param name: Command name
|
||||||
|
|||||||
@ -815,13 +815,14 @@ struct iwall_data {
|
|||||||
|
|
||||||
class c_map_zone_data {
|
class c_map_zone_data {
|
||||||
public:
|
public:
|
||||||
uint16 id;
|
e_map_type id;
|
||||||
std::unordered_map<std::string, uint16> disabled_commands;
|
std::unordered_map<std::string, uint16> disabled_commands;
|
||||||
std::unordered_map<uint16, std::pair<uint16, uint16>> disabled_skills;
|
std::unordered_map<uint16, std::pair<uint16, uint16>> disabled_skills;
|
||||||
std::unordered_map<t_itemid, uint16> disabled_items;
|
std::unordered_map<t_itemid, uint16> disabled_items;
|
||||||
std::unordered_map<sc_type, uint16> disabled_statuses;
|
std::unordered_map<sc_type, uint16> disabled_statuses;
|
||||||
std::unordered_map<int32, uint16> restricted_jobs;
|
std::unordered_map<int32, uint16> restricted_jobs;
|
||||||
|
|
||||||
|
e_map_type getMapZone(int16 map_id);
|
||||||
bool isCommandDisabled(std::string name, map_session_data &sd);
|
bool isCommandDisabled(std::string name, map_session_data &sd);
|
||||||
bool isSkillDisabled(uint16 skill_id, block_list &bl);
|
bool isSkillDisabled(uint16 skill_id, block_list &bl);
|
||||||
bool isItemDisabled(t_itemid nameid, map_session_data &sd);
|
bool isItemDisabled(t_itemid nameid, map_session_data &sd);
|
||||||
@ -905,7 +906,6 @@ public:
|
|||||||
void loadingFinished() override;
|
void loadingFinished() override;
|
||||||
|
|
||||||
// Others
|
// Others
|
||||||
e_map_type getMapZone(int16 map_id);
|
|
||||||
bool setZone(int16 map_id, e_map_type zone);
|
bool setZone(int16 map_id, e_map_type zone);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user