mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 14:41:28 +00:00
[Loot] Consolidate filtering logic (#4280)
* [Loot] Consolidate filtering logic * Log category
This commit is contained in:
parent
fcffc6b3d4
commit
4215a3b9d6
@ -126,49 +126,13 @@ void NPC::AddLootDropTable(uint32 lootdrop_id, uint8 drop_limit, uint8 min_drop)
|
|||||||
{
|
{
|
||||||
const auto l = zone->GetLootdrop(lootdrop_id);
|
const auto l = zone->GetLootdrop(lootdrop_id);
|
||||||
const auto le = zone->GetLootdropEntries(lootdrop_id);
|
const auto le = zone->GetLootdropEntries(lootdrop_id);
|
||||||
|
if (l.id == 0 || le.empty()) {
|
||||||
auto content_flags = ContentFlags{
|
|
||||||
.min_expansion = l.min_expansion,
|
|
||||||
.max_expansion = l.max_expansion,
|
|
||||||
.content_flags = l.content_flags,
|
|
||||||
.content_flags_disabled = l.content_flags_disabled
|
|
||||||
};
|
|
||||||
|
|
||||||
if (l.id == 0 || le.empty() || !content_service.DoesPassContentFiltering(content_flags)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if this lootdrop is droplimit=0 and mindrop 0, scan list once and return
|
// if this lootdrop is droplimit=0 and mindrop 0, scan list once and return
|
||||||
if (drop_limit == 0 && min_drop == 0) {
|
if (drop_limit == 0 && min_drop == 0) {
|
||||||
for (const auto &e: le) {
|
for (const auto &e: le) {
|
||||||
LogLootDetail(
|
|
||||||
"-- NPC [{}] Lootdrop [{}] Item [{}] ({}_ Chance [{}] Multiplier [{}]",
|
|
||||||
GetCleanName(),
|
|
||||||
lootdrop_id,
|
|
||||||
database.GetItem(e.item_id) ? database.GetItem(e.item_id)->Name : "Unknown",
|
|
||||||
e.item_id,
|
|
||||||
e.chance,
|
|
||||||
e.multiplier
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!content_service.DoesPassContentFiltering(
|
|
||||||
ContentFlags{
|
|
||||||
.min_expansion = e.min_expansion,
|
|
||||||
.max_expansion = e.max_expansion,
|
|
||||||
.content_flags = e.content_flags,
|
|
||||||
.content_flags_disabled = e.content_flags_disabled
|
|
||||||
}
|
|
||||||
)) {
|
|
||||||
LogLoot(
|
|
||||||
"-- NPC [{}] Lootdrop [{}] Item [{}] ({}) does not pass content filtering",
|
|
||||||
GetCleanName(),
|
|
||||||
lootdrop_id,
|
|
||||||
e.item_id,
|
|
||||||
database.GetItem(e.item_id) ? database.GetItem(e.item_id)->Name : "Unknown"
|
|
||||||
);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = 0; j < e.multiplier; ++j) {
|
for (int j = 0; j < e.multiplier; ++j) {
|
||||||
if (zone->random.Real(0.0, 100.0) <= e.chance && MeetsLootDropLevelRequirements(e, true)) {
|
if (zone->random.Real(0.0, 100.0) <= e.chance && MeetsLootDropLevelRequirements(e, true)) {
|
||||||
const EQ::ItemData *database_item = database.GetItem(e.item_id);
|
const EQ::ItemData *database_item = database.GetItem(e.item_id);
|
||||||
@ -234,24 +198,6 @@ void NPC::AddLootDropTable(uint32 lootdrop_id, uint8 drop_limit, uint8 min_drop)
|
|||||||
if (drops < min_drop || roll_table_chance_bypass || (float) zone->random.Real(0.0, 1.0) >= no_loot_prob) {
|
if (drops < min_drop || roll_table_chance_bypass || (float) zone->random.Real(0.0, 1.0) >= no_loot_prob) {
|
||||||
float roll = (float) zone->random.Real(0.0, roll_t);
|
float roll = (float) zone->random.Real(0.0, roll_t);
|
||||||
for (const auto &e: le) {
|
for (const auto &e: le) {
|
||||||
if (!content_service.DoesPassContentFiltering(
|
|
||||||
ContentFlags{
|
|
||||||
.min_expansion = e.min_expansion,
|
|
||||||
.max_expansion = e.max_expansion,
|
|
||||||
.content_flags = e.content_flags,
|
|
||||||
.content_flags_disabled = e.content_flags_disabled
|
|
||||||
}
|
|
||||||
)) {
|
|
||||||
LogLoot(
|
|
||||||
"-- NPC [{}] Lootdrop [{}] Item [{}] ({}) does not pass content filtering",
|
|
||||||
GetCleanName(),
|
|
||||||
lootdrop_id,
|
|
||||||
e.item_id,
|
|
||||||
database.GetItem(e.item_id) ? database.GetItem(e.item_id)->Name : "Unknown"
|
|
||||||
);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto *db_item = database.GetItem(e.item_id);
|
const auto *db_item = database.GetItem(e.item_id);
|
||||||
if (db_item) {
|
if (db_item) {
|
||||||
// if it doesn't meet the requirements do nothing
|
// if it doesn't meet the requirements do nothing
|
||||||
|
|||||||
@ -211,6 +211,21 @@ LoottableRepository::Loottable *Zone::GetLootTable(const uint32 loottable_id)
|
|||||||
{
|
{
|
||||||
for (auto &e: m_loottables) {
|
for (auto &e: m_loottables) {
|
||||||
if (e.id == loottable_id) {
|
if (e.id == loottable_id) {
|
||||||
|
if (!content_service.DoesPassContentFiltering(
|
||||||
|
ContentFlags{
|
||||||
|
.min_expansion = e.min_expansion,
|
||||||
|
.max_expansion = e.max_expansion,
|
||||||
|
.content_flags = e.content_flags,
|
||||||
|
.content_flags_disabled = e.content_flags_disabled
|
||||||
|
}
|
||||||
|
)) {
|
||||||
|
LogLootDetail(
|
||||||
|
"Loot table [{}] does not pass content filtering",
|
||||||
|
loottable_id
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
return &e;
|
return &e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,6 +249,21 @@ LootdropRepository::Lootdrop Zone::GetLootdrop(const uint32 lootdrop_id) const
|
|||||||
{
|
{
|
||||||
for (const auto &e: m_lootdrops) {
|
for (const auto &e: m_lootdrops) {
|
||||||
if (e.id == lootdrop_id) {
|
if (e.id == lootdrop_id) {
|
||||||
|
if (!content_service.DoesPassContentFiltering(
|
||||||
|
ContentFlags{
|
||||||
|
.min_expansion = e.min_expansion,
|
||||||
|
.max_expansion = e.max_expansion,
|
||||||
|
.content_flags = e.content_flags,
|
||||||
|
.content_flags_disabled = e.content_flags_disabled
|
||||||
|
}
|
||||||
|
)) {
|
||||||
|
LogLootDetail(
|
||||||
|
"Lootdrop table [{}] does not pass content filtering",
|
||||||
|
lootdrop_id
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -246,6 +276,23 @@ std::vector<LootdropEntriesRepository::LootdropEntries> Zone::GetLootdropEntries
|
|||||||
std::vector<LootdropEntriesRepository::LootdropEntries> entries = {};
|
std::vector<LootdropEntriesRepository::LootdropEntries> entries = {};
|
||||||
for (const auto &e: m_lootdrop_entries) {
|
for (const auto &e: m_lootdrop_entries) {
|
||||||
if (e.lootdrop_id == lootdrop_id) {
|
if (e.lootdrop_id == lootdrop_id) {
|
||||||
|
if (!content_service.DoesPassContentFiltering(
|
||||||
|
ContentFlags{
|
||||||
|
.min_expansion = e.min_expansion,
|
||||||
|
.max_expansion = e.max_expansion,
|
||||||
|
.content_flags = e.content_flags,
|
||||||
|
.content_flags_disabled = e.content_flags_disabled
|
||||||
|
}
|
||||||
|
)) {
|
||||||
|
LogLootDetail(
|
||||||
|
"Lootdrop [{}] Item [{}] ({}) does not pass content filtering",
|
||||||
|
lootdrop_id,
|
||||||
|
e.item_id,
|
||||||
|
database.GetItem(e.item_id) ? database.GetItem(e.item_id)->Name : "Unknown"
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
entries.emplace_back(e);
|
entries.emplace_back(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user