Adds ability to clear mapflags
* Added the Clear label to allow mapflags to be removed for importing use. * Converts mapflag storage into multimap.
This commit is contained in:
parent
e9beffea50
commit
941085e826
@ -73,4 +73,4 @@ Mapflags: Mapflags that are applies to a zone. By default, the Value label is 1/
|
|||||||
- Flag: Skill_Duration
|
- Flag: Skill_Duration
|
||||||
Value: AL_SANCTUARY,400 # Sets the 'skill_duration' mapflag to the zone.
|
Value: AL_SANCTUARY,400 # Sets the 'skill_duration' mapflag to the zone.
|
||||||
- Flag: NoMemo # Removes the 'nomemo' mapflag to the zone. Useful for import.
|
- Flag: NoMemo # Removes the 'nomemo' mapflag to the zone. Useful for import.
|
||||||
Value: 0
|
Clear: true
|
||||||
|
|||||||
@ -449,9 +449,6 @@ uint64 MapZoneDatabase::parseBodyNode(const ryml::NodeRef& node) {
|
|||||||
if (this->nodeExists(node, "Mapflags")) {
|
if (this->nodeExists(node, "Mapflags")) {
|
||||||
const auto &mapflagNode = node["Mapflags"];
|
const auto &mapflagNode = node["Mapflags"];
|
||||||
|
|
||||||
// Mapflags are stored as double-key so that duplicate mapflags can be parsed.
|
|
||||||
uint16 mapflag_index = 0;
|
|
||||||
|
|
||||||
for (const auto &it : mapflagNode) {
|
for (const auto &it : mapflagNode) {
|
||||||
std::string flag_name;
|
std::string flag_name;
|
||||||
|
|
||||||
@ -474,8 +471,28 @@ uint64 MapZoneDatabase::parseBodyNode(const ryml::NodeRef& node) {
|
|||||||
} else
|
} else
|
||||||
value = "1";
|
value = "1";
|
||||||
|
|
||||||
zone->mapflags.insert({ std::pair<int16, uint16>(static_cast<int16>(flag), mapflag_index), value });
|
bool clear = false;
|
||||||
mapflag_index++;
|
|
||||||
|
if (this->nodeExists(it, "Clear")) {
|
||||||
|
if (!this->asBool(it, "Clear", clear))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!clear) {
|
||||||
|
zone->mapflags.insert({ std::pair<int16, std::string>(static_cast<int16>(flag), value) });
|
||||||
|
} else {
|
||||||
|
// Get all mapflag keys that match
|
||||||
|
auto mapflagit = zone->mapflags.equal_range(static_cast<int16>(flag));
|
||||||
|
|
||||||
|
// Iterate over the mapflags to get their values
|
||||||
|
for (std::multimap<int16, std::string>::iterator it = mapflagit.first; it != mapflagit.second; ++it) {
|
||||||
|
// Compare parse value with what's already in memory
|
||||||
|
if (it->second.find(value) == 0) {
|
||||||
|
zone->mapflags.erase(it);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -888,7 +888,7 @@ struct s_map_zone {
|
|||||||
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;
|
||||||
std::vector<int16> maps;
|
std::vector<int16> maps;
|
||||||
std::map<std::pair<int16, uint16>, std::string> mapflags;
|
std::multimap<int16, std::string> mapflags;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MapZoneDatabase : public TypesafeYamlDatabase<uint16, s_map_zone> {
|
class MapZoneDatabase : public TypesafeYamlDatabase<uint16, s_map_zone> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user