mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51:29 +00:00
Filter loot tables and drops [skip ci]
This commit is contained in:
parent
6e3922b7cc
commit
152d985821
@ -26,8 +26,10 @@
|
|||||||
#include "../../common/crash.h"
|
#include "../../common/crash.h"
|
||||||
#include "../../common/rulesys.h"
|
#include "../../common/rulesys.h"
|
||||||
#include "../../common/string_util.h"
|
#include "../../common/string_util.h"
|
||||||
|
#include "../../common/content/world_content_service.h"
|
||||||
|
|
||||||
EQEmuLogSys LogSys;
|
EQEmuLogSys LogSys;
|
||||||
|
WorldContentService content_service;
|
||||||
|
|
||||||
void ExportSpells(SharedDatabase *db);
|
void ExportSpells(SharedDatabase *db);
|
||||||
void ExportSkillCaps(SharedDatabase *db);
|
void ExportSkillCaps(SharedDatabase *db);
|
||||||
|
|||||||
@ -24,8 +24,10 @@
|
|||||||
#include "../../common/crash.h"
|
#include "../../common/crash.h"
|
||||||
#include "../../common/rulesys.h"
|
#include "../../common/rulesys.h"
|
||||||
#include "../../common/string_util.h"
|
#include "../../common/string_util.h"
|
||||||
|
#include "../../common/content/world_content_service.h"
|
||||||
|
|
||||||
EQEmuLogSys LogSys;
|
EQEmuLogSys LogSys;
|
||||||
|
WorldContentService content_service;
|
||||||
|
|
||||||
void ImportSpells(SharedDatabase *db);
|
void ImportSpells(SharedDatabase *db);
|
||||||
void ImportSkillCaps(SharedDatabase *db);
|
void ImportSkillCaps(SharedDatabase *db);
|
||||||
|
|||||||
@ -38,6 +38,7 @@
|
|||||||
#include "shareddb.h"
|
#include "shareddb.h"
|
||||||
#include "string_util.h"
|
#include "string_util.h"
|
||||||
#include "eqemu_config.h"
|
#include "eqemu_config.h"
|
||||||
|
#include "repositories/criteria/content_filter_criteria.h"
|
||||||
|
|
||||||
namespace ItemField
|
namespace ItemField
|
||||||
{
|
{
|
||||||
@ -1996,7 +1997,11 @@ void SharedDatabase::GetLootTableInfo(uint32 &loot_table_count, uint32 &max_loot
|
|||||||
loot_table_count = 0;
|
loot_table_count = 0;
|
||||||
max_loot_table = 0;
|
max_loot_table = 0;
|
||||||
loot_table_entries = 0;
|
loot_table_entries = 0;
|
||||||
const std::string query = "SELECT COUNT(*), MAX(id), (SELECT COUNT(*) FROM loottable_entries) FROM loottable";
|
const std::string query =
|
||||||
|
fmt::format(
|
||||||
|
"SELECT COUNT(*), MAX(id), (SELECT COUNT(*) FROM loottable_entries) FROM loottable WHERE TRUE {}",
|
||||||
|
ContentFilterCriteria::apply()
|
||||||
|
);
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return;
|
return;
|
||||||
@ -2017,7 +2022,11 @@ void SharedDatabase::GetLootDropInfo(uint32 &loot_drop_count, uint32 &max_loot_d
|
|||||||
max_loot_drop = 0;
|
max_loot_drop = 0;
|
||||||
loot_drop_entries = 0;
|
loot_drop_entries = 0;
|
||||||
|
|
||||||
const std::string query = "SELECT COUNT(*), MAX(id), (SELECT COUNT(*) FROM lootdrop_entries) FROM lootdrop";
|
const std::string query = fmt::format(
|
||||||
|
"SELECT COUNT(*), MAX(id), (SELECT COUNT(*) FROM lootdrop_entries) FROM lootdrop WHERE TRUE {}",
|
||||||
|
ContentFilterCriteria::apply()
|
||||||
|
);
|
||||||
|
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return;
|
return;
|
||||||
@ -2039,10 +2048,28 @@ void SharedDatabase::LoadLootTables(void *data, uint32 size) {
|
|||||||
uint8 loot_table[sizeof(LootTable_Struct) + (sizeof(LootTableEntries_Struct) * 128)];
|
uint8 loot_table[sizeof(LootTable_Struct) + (sizeof(LootTableEntries_Struct) * 128)];
|
||||||
LootTable_Struct *lt = reinterpret_cast<LootTable_Struct*>(loot_table);
|
LootTable_Struct *lt = reinterpret_cast<LootTable_Struct*>(loot_table);
|
||||||
|
|
||||||
const std::string query = "SELECT loottable.id, loottable.mincash, loottable.maxcash, loottable.avgcoin, "
|
const std::string query = fmt::format(
|
||||||
"loottable_entries.lootdrop_id, loottable_entries.multiplier, loottable_entries.droplimit, "
|
SQL(
|
||||||
"loottable_entries.mindrop, loottable_entries.probability FROM loottable LEFT JOIN loottable_entries "
|
SELECT
|
||||||
"ON loottable.id = loottable_entries.loottable_id ORDER BY id";
|
loottable.id,
|
||||||
|
loottable.mincash,
|
||||||
|
loottable.maxcash,
|
||||||
|
loottable.avgcoin,
|
||||||
|
loottable_entries.lootdrop_id,
|
||||||
|
loottable_entries.multiplier,
|
||||||
|
loottable_entries.droplimit,
|
||||||
|
loottable_entries.mindrop,
|
||||||
|
loottable_entries.probability
|
||||||
|
FROM
|
||||||
|
loottable
|
||||||
|
LEFT JOIN loottable_entries ON loottable.id = loottable_entries.loottable_id
|
||||||
|
WHERE TRUE {}
|
||||||
|
ORDER BY
|
||||||
|
id
|
||||||
|
),
|
||||||
|
ContentFilterCriteria::apply()
|
||||||
|
);
|
||||||
|
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return;
|
return;
|
||||||
@ -2054,8 +2081,12 @@ void SharedDatabase::LoadLootTables(void *data, uint32 size) {
|
|||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
uint32 id = static_cast<uint32>(atoul(row[0]));
|
uint32 id = static_cast<uint32>(atoul(row[0]));
|
||||||
if (id != current_id) {
|
if (id != current_id) {
|
||||||
if(current_id != 0)
|
if (current_id != 0) {
|
||||||
hash.insert(current_id, loot_table, (sizeof(LootTable_Struct) + (sizeof(LootTableEntries_Struct) * lt->NumEntries)));
|
hash.insert(
|
||||||
|
current_id,
|
||||||
|
loot_table,
|
||||||
|
(sizeof(LootTable_Struct) + (sizeof(LootTableEntries_Struct) * lt->NumEntries)));
|
||||||
|
}
|
||||||
|
|
||||||
memset(loot_table, 0, sizeof(LootTable_Struct) + (sizeof(LootTableEntries_Struct) * 128));
|
memset(loot_table, 0, sizeof(LootTable_Struct) + (sizeof(LootTableEntries_Struct) * 128));
|
||||||
current_entry = 0;
|
current_entry = 0;
|
||||||
@ -2065,11 +2096,13 @@ void SharedDatabase::LoadLootTables(void *data, uint32 size) {
|
|||||||
lt->avgcoin = static_cast<uint32>(atoul(row[3]));
|
lt->avgcoin = static_cast<uint32>(atoul(row[3]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(current_entry > 128)
|
if (current_entry > 128) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if(!row[4])
|
if (!row[4]) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
lt->Entries[current_entry].lootdrop_id = static_cast<uint32>(atoul(row[4]));
|
lt->Entries[current_entry].lootdrop_id = static_cast<uint32>(atoul(row[4]));
|
||||||
lt->Entries[current_entry].multiplier = static_cast<uint8>(atoi(row[5]));
|
lt->Entries[current_entry].multiplier = static_cast<uint8>(atoi(row[5]));
|
||||||
@ -2081,8 +2114,13 @@ void SharedDatabase::LoadLootTables(void *data, uint32 size) {
|
|||||||
++current_entry;
|
++current_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(current_id != 0)
|
if (current_id != 0) {
|
||||||
hash.insert(current_id, loot_table, (sizeof(LootTable_Struct) + (sizeof(LootTableEntries_Struct) * lt->NumEntries)));
|
hash.insert(
|
||||||
|
current_id,
|
||||||
|
loot_table,
|
||||||
|
(sizeof(LootTable_Struct) + (sizeof(LootTableEntries_Struct) * lt->NumEntries))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2092,10 +2130,28 @@ void SharedDatabase::LoadLootDrops(void *data, uint32 size) {
|
|||||||
uint8 loot_drop[sizeof(LootDrop_Struct) + (sizeof(LootDropEntries_Struct) * 1260)];
|
uint8 loot_drop[sizeof(LootDrop_Struct) + (sizeof(LootDropEntries_Struct) * 1260)];
|
||||||
LootDrop_Struct *ld = reinterpret_cast<LootDrop_Struct*>(loot_drop);
|
LootDrop_Struct *ld = reinterpret_cast<LootDrop_Struct*>(loot_drop);
|
||||||
|
|
||||||
const std::string query = "SELECT lootdrop.id, lootdrop_entries.item_id, lootdrop_entries.item_charges, "
|
const std::string query = fmt::format(
|
||||||
"lootdrop_entries.equip_item, lootdrop_entries.chance, lootdrop_entries.minlevel, "
|
SQL(
|
||||||
"lootdrop_entries.maxlevel, lootdrop_entries.multiplier FROM lootdrop JOIN lootdrop_entries "
|
SELECT
|
||||||
"ON lootdrop.id = lootdrop_entries.lootdrop_id ORDER BY lootdrop_id";
|
lootdrop.id,
|
||||||
|
lootdrop_entries.item_id,
|
||||||
|
lootdrop_entries.item_charges,
|
||||||
|
lootdrop_entries.equip_item,
|
||||||
|
lootdrop_entries.chance,
|
||||||
|
lootdrop_entries.minlevel,
|
||||||
|
lootdrop_entries.maxlevel,
|
||||||
|
lootdrop_entries.multiplier
|
||||||
|
FROM
|
||||||
|
lootdrop
|
||||||
|
JOIN lootdrop_entries ON lootdrop.id = lootdrop_entries.lootdrop_id
|
||||||
|
WHERE
|
||||||
|
TRUE {}
|
||||||
|
ORDER BY
|
||||||
|
lootdrop_id
|
||||||
|
),
|
||||||
|
ContentFilterCriteria::apply()
|
||||||
|
);
|
||||||
|
|
||||||
auto results = QueryDatabase(query);
|
auto results = QueryDatabase(query);
|
||||||
if (!results.Success()) {
|
if (!results.Success()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -33,8 +33,10 @@
|
|||||||
#include "skill_caps.h"
|
#include "skill_caps.h"
|
||||||
#include "spells.h"
|
#include "spells.h"
|
||||||
#include "base_data.h"
|
#include "base_data.h"
|
||||||
|
#include "../common/content/world_content_service.h"
|
||||||
|
|
||||||
EQEmuLogSys LogSys;
|
EQEmuLogSys LogSys;
|
||||||
|
WorldContentService content_service;
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
@ -139,6 +141,39 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rules: TODO: Remove later
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
std::string tmp;
|
||||||
|
if (database.GetVariable("RuleSet", tmp)) {
|
||||||
|
LogInfo("Loading rule set [{}]", tmp.c_str());
|
||||||
|
if (!RuleManager::Instance()->LoadRules(&database, tmp.c_str(), false)) {
|
||||||
|
LogError("Failed to load ruleset [{}], falling back to defaults", tmp.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!RuleManager::Instance()->LoadRules(&database, "default", false)) {
|
||||||
|
LogInfo("No rule set configured, using default rules");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LogInfo("Loaded default rule set 'default'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EQEmu::InitializeDynamicLookups();
|
||||||
|
LogInfo("Initialized dynamic dictionary entries");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
content_service.SetCurrentExpansion(RuleI(Expansion, CurrentExpansion));
|
||||||
|
|
||||||
|
LogInfo(
|
||||||
|
"Current expansion is [{}] ({})",
|
||||||
|
content_service.GetCurrentExpansion(),
|
||||||
|
Expansion::ExpansionName[content_service.GetCurrentExpansion()]
|
||||||
|
);
|
||||||
|
|
||||||
std::string hotfix_name = "";
|
std::string hotfix_name = "";
|
||||||
|
|
||||||
bool load_all = true;
|
bool load_all = true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user