Expansion filtering for doors

This commit is contained in:
Akkadius 2020-04-04 05:51:21 -05:00
parent c1e58673b2
commit 8a711f3c64
2 changed files with 14 additions and 6 deletions

View File

@ -31,23 +31,28 @@ namespace ContentFilterCriteria {
std::string criteria;
criteria += fmt::format(
" AND (min_expansion >= {} OR min_expansion = 0)",
" AND (min_expansion <= {} OR min_expansion = 0)",
content_service.GetCurrentExpansion()
);
criteria += fmt::format(
" AND (max_expansion <= {} OR max_expansion = 0)",
" AND (max_expansion >= {} OR max_expansion = 0)",
content_service.GetCurrentExpansion()
);
std::vector<std::string> flags = content_service.GetContentFlags();
for (auto &flag: flags) {
for (auto &flag: flags) {
flag = "'" + flag + "'";
}
std::string flags_in_filter;
if (!flags.empty()) {
flags_in_filter = fmt::format("OR content_flags IN ({})", implode(", ", flags));
}
criteria += fmt::format(
" AND (content_flags IS NULL OR content_flags IN ({}))",
implode(", ", flags)
" AND (content_flags IS NULL {})",
flags_in_filter
);
return std::string(criteria);

View File

@ -28,6 +28,7 @@
#include "string_ids.h"
#include "worldserver.h"
#include "zonedb.h"
#include "../common/repositories/criteria/content_filter_criteria.h"
#include <iostream>
#include <string.h>
@ -716,10 +717,12 @@ bool ZoneDatabase::LoadDoors(int32 door_count, Door *into, const char *zone_name
" WHERE "
" zone = '%s' "
" AND ( version = % u OR version = - 1 ) "
" %s "
" ORDER BY "
" doorid ASC ",
zone_name,
version
version,
ContentFilterCriteria::apply().c_str()
);
auto results = QueryDatabase(query);
if (!results.Success()) {