mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-21 06:01:29 +00:00
Filter global_loot [skip ci]
This commit is contained in:
parent
152d985821
commit
f7d4e51da9
@ -26,32 +26,46 @@
|
|||||||
#include "../../string_util.h"
|
#include "../../string_util.h"
|
||||||
|
|
||||||
namespace ContentFilterCriteria {
|
namespace ContentFilterCriteria {
|
||||||
static std::string apply()
|
static std::string apply(std::string table_prefix = "")
|
||||||
{
|
{
|
||||||
std::string criteria;
|
std::string criteria;
|
||||||
|
|
||||||
|
if (!table_prefix.empty()) {
|
||||||
|
table_prefix = table_prefix + ".";
|
||||||
|
}
|
||||||
|
|
||||||
criteria += fmt::format(
|
criteria += fmt::format(
|
||||||
" AND (min_expansion <= {} OR min_expansion = 0)",
|
" AND ({}min_expansion <= {} OR {}min_expansion = 0)",
|
||||||
content_service.GetCurrentExpansion()
|
table_prefix,
|
||||||
|
content_service.GetCurrentExpansion(),
|
||||||
|
table_prefix
|
||||||
);
|
);
|
||||||
|
|
||||||
criteria += fmt::format(
|
criteria += fmt::format(
|
||||||
" AND (max_expansion >= {} OR max_expansion = 0)",
|
" AND ({}max_expansion >= {} OR {}max_expansion = 0)",
|
||||||
content_service.GetCurrentExpansion()
|
table_prefix,
|
||||||
|
content_service.GetCurrentExpansion(),
|
||||||
|
table_prefix
|
||||||
);
|
);
|
||||||
|
|
||||||
std::vector<std::string> flags = content_service.GetContentFlags();
|
std::vector<std::string> flags = content_service.GetContentFlags();
|
||||||
for (auto &flag: flags) {
|
|
||||||
|
for (auto &flag: flags) {
|
||||||
flag = "'" + flag + "'";
|
flag = "'" + flag + "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string flags_in_filter;
|
std::string flags_in_filter;
|
||||||
if (!flags.empty()) {
|
if (!flags.empty()) {
|
||||||
flags_in_filter = fmt::format(" OR content_flags IN ({})", implode(", ", flags));
|
flags_in_filter = fmt::format(
|
||||||
|
" OR {}content_flags IN ({})",
|
||||||
|
table_prefix,
|
||||||
|
implode(", ", flags)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
criteria += fmt::format(
|
criteria += fmt::format(
|
||||||
" AND (content_flags IS NULL{})",
|
" AND ({}content_flags IS NULL{})",
|
||||||
|
table_prefix,
|
||||||
flags_in_filter
|
flags_in_filter
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
#include "npc.h"
|
#include "npc.h"
|
||||||
#include "zonedb.h"
|
#include "zonedb.h"
|
||||||
#include "global_loot_manager.h"
|
#include "global_loot_manager.h"
|
||||||
|
#include "../common/repositories/criteria/content_filter_criteria.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -463,42 +464,70 @@ void NPC::CheckGlobalLootTables()
|
|||||||
|
|
||||||
void ZoneDatabase::LoadGlobalLoot()
|
void ZoneDatabase::LoadGlobalLoot()
|
||||||
{
|
{
|
||||||
auto query = StringFormat("SELECT id, loottable_id, description, min_level, max_level, rare, raid, race, "
|
auto query = fmt::format(
|
||||||
"class, bodytype, zone, hot_zone FROM global_loot WHERE enabled = 1");
|
SQL
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
loottable_id,
|
||||||
|
description,
|
||||||
|
min_level,
|
||||||
|
max_level,
|
||||||
|
rare,
|
||||||
|
raid,
|
||||||
|
race,
|
||||||
|
class,
|
||||||
|
bodytype,
|
||||||
|
zone,
|
||||||
|
hot_zone
|
||||||
|
FROM
|
||||||
|
global_loot
|
||||||
|
WHERE
|
||||||
|
enabled = 1
|
||||||
|
{}
|
||||||
|
),
|
||||||
|
ContentFilterCriteria::apply()
|
||||||
|
);
|
||||||
|
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
if (!results.Success() || results.RowCount() == 0)
|
if (!results.Success() || results.RowCount() == 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// we might need this, lets not keep doing it in a loop
|
// we might need this, lets not keep doing it in a loop
|
||||||
auto zoneid = std::to_string(zone->GetZoneID());
|
auto zoneid = std::to_string(zone->GetZoneID());
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
// checking zone limits
|
// checking zone limits
|
||||||
if (row[10]) {
|
if (row[10]) {
|
||||||
auto zones = SplitString(row[10], '|');
|
auto zones = SplitString(row[10], '|');
|
||||||
|
|
||||||
auto it = std::find(zones.begin(), zones.end(), zoneid);
|
auto it = std::find(zones.begin(), zones.end(), zoneid);
|
||||||
if (it == zones.end()) // not in here, skip
|
if (it == zones.end()) { // not in here, skip
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalLootEntry e(atoi(row[0]), atoi(row[1]), row[2] ? row[2] : "");
|
GlobalLootEntry e(atoi(row[0]), atoi(row[1]), row[2] ? row[2] : "");
|
||||||
|
|
||||||
auto min_level = atoi(row[3]);
|
auto min_level = atoi(row[3]);
|
||||||
if (min_level)
|
if (min_level) {
|
||||||
e.AddRule(GlobalLoot::RuleTypes::LevelMin, min_level);
|
e.AddRule(GlobalLoot::RuleTypes::LevelMin, min_level);
|
||||||
|
}
|
||||||
|
|
||||||
auto max_level = atoi(row[4]);
|
auto max_level = atoi(row[4]);
|
||||||
if (max_level)
|
if (max_level) {
|
||||||
e.AddRule(GlobalLoot::RuleTypes::LevelMax, max_level);
|
e.AddRule(GlobalLoot::RuleTypes::LevelMax, max_level);
|
||||||
|
}
|
||||||
|
|
||||||
// null is not used
|
// null is not used
|
||||||
if (row[5])
|
if (row[5]) {
|
||||||
e.AddRule(GlobalLoot::RuleTypes::Rare, atoi(row[5]));
|
e.AddRule(GlobalLoot::RuleTypes::Rare, atoi(row[5]));
|
||||||
|
}
|
||||||
|
|
||||||
// null is not used
|
// null is not used
|
||||||
if (row[6])
|
if (row[6]) {
|
||||||
e.AddRule(GlobalLoot::RuleTypes::Raid, atoi(row[6]));
|
e.AddRule(GlobalLoot::RuleTypes::Raid, atoi(row[6]));
|
||||||
|
}
|
||||||
|
|
||||||
if (row[7]) {
|
if (row[7]) {
|
||||||
auto races = SplitString(row[7], '|');
|
auto races = SplitString(row[7], '|');
|
||||||
@ -522,8 +551,9 @@ void ZoneDatabase::LoadGlobalLoot()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// null is not used
|
// null is not used
|
||||||
if (row[11])
|
if (row[11]) {
|
||||||
e.AddRule(GlobalLoot::RuleTypes::HotZone, atoi(row[11]));
|
e.AddRule(GlobalLoot::RuleTypes::HotZone, atoi(row[11]));
|
||||||
|
}
|
||||||
|
|
||||||
zone->AddGlobalLootEntry(e);
|
zone->AddGlobalLootEntry(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -551,32 +551,32 @@ void Zone::GetMerchantDataForZoneLoad() {
|
|||||||
std::string query = fmt::format(
|
std::string query = fmt::format(
|
||||||
SQL (
|
SQL (
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT ml.merchantid,
|
DISTINCT merchantlist.merchantid,
|
||||||
ml.slot,
|
merchantlist.slot,
|
||||||
ml.item,
|
merchantlist.item,
|
||||||
ml.faction_required,
|
merchantlist.faction_required,
|
||||||
ml.level_required,
|
merchantlist.level_required,
|
||||||
ml.alt_currency_cost,
|
merchantlist.alt_currency_cost,
|
||||||
ml.classes_required,
|
merchantlist.classes_required,
|
||||||
ml.probability
|
merchantlist.probability
|
||||||
FROM
|
FROM
|
||||||
merchantlist AS ml,
|
merchantlist,
|
||||||
npc_types AS nt,
|
npc_types,
|
||||||
spawnentry AS se,
|
spawnentry,
|
||||||
spawn2 AS s2
|
spawn2
|
||||||
WHERE
|
WHERE
|
||||||
nt.merchant_id = ml.merchantid
|
npc_types.merchant_id = merchantlist.merchantid
|
||||||
AND nt.id = se.npcid
|
AND npc_types.id = spawnentry.npcid
|
||||||
AND se.spawngroupid = s2.spawngroupid
|
AND spawnentry.spawngroupid = spawn2.spawngroupid
|
||||||
AND s2.zone = '{}'
|
AND spawn2.zone = '{}'
|
||||||
AND s2.version = {}
|
AND spawn2.version = {}
|
||||||
{}
|
{}
|
||||||
ORDER BY
|
ORDER BY
|
||||||
ml.slot
|
merchantlist.slot
|
||||||
),
|
),
|
||||||
GetShortName(),
|
GetShortName(),
|
||||||
GetInstanceVersion(),
|
GetInstanceVersion(),
|
||||||
ContentFilterCriteria::apply()
|
ContentFilterCriteria::apply("merchantlist")
|
||||||
);
|
);
|
||||||
|
|
||||||
auto results = content_db.QueryDatabase(query);
|
auto results = content_db.QueryDatabase(query);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user