mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 09:06:46 +00:00
[Loot] Remove from shared memory, simplification (#3988)
* First pass of pulling loot out of shared memory, functional * More code cleanup * More cleanup * More cleanup * More cleanup * Add loot reload type * Reload, logging * Update npc.h * Cleanup * Logging, don't load attempt to load loottable id 0 * Update worldserver.cpp * Update client.cpp * Update zone_loot.cpp * PR feedback * Update zone.cpp * Memory leak suggestion * Update CMakeLists.txt * Post rebase issues
This commit is contained in:
@@ -51,36 +51,37 @@ void command_lootsim(Client *c, const Seperator *sep)
|
||||
c->SendChatLineBreak();
|
||||
|
||||
// npc level loot table
|
||||
auto loot_table = database.GetLootTable(loottable_id);
|
||||
auto loot_table = zone->GetLootTable(loottable_id);
|
||||
if (!loot_table) {
|
||||
c->Message(Chat::Red, "Loot table not found");
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint32 i = 0; i < loot_table->NumEntries; i++) {
|
||||
auto le = loot_table->Entries[i];
|
||||
auto le = zone->GetLootTableEntries(loottable_id);
|
||||
|
||||
// translate above for loop using loot_table_entries
|
||||
for (auto &e: le) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"# Lootdrop ID [{}] drop_limit [{}] min_drop [{}] mult [{}] probability [{}]",
|
||||
le.lootdrop_id,
|
||||
le.droplimit,
|
||||
le.mindrop,
|
||||
le.multiplier,
|
||||
le.probability
|
||||
e.lootdrop_id,
|
||||
e.droplimit,
|
||||
e.mindrop,
|
||||
e.multiplier,
|
||||
e.probability
|
||||
).c_str()
|
||||
);
|
||||
|
||||
auto loot_drop = database.GetLootDrop(le.lootdrop_id);
|
||||
if (!loot_drop) {
|
||||
auto loot_drop = zone->GetLootdrop(e.lootdrop_id);
|
||||
if (!loot_drop.id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (uint32 ei = 0; ei < loot_drop->NumEntries; ei++) {
|
||||
auto e = loot_drop->Entries[ei];
|
||||
int rolled_count = npc->GetRolledItemCount(e.item_id);
|
||||
const EQ::ItemData *item = database.GetItem(e.item_id);
|
||||
auto loot_drop_entries = zone->GetLootdropEntries(e.lootdrop_id);
|
||||
for (auto &f: loot_drop_entries) {
|
||||
int rolled_count = npc->GetRolledItemCount(f.item_id);
|
||||
const EQ::ItemData *item = database.GetItem(f.item_id);
|
||||
|
||||
EQ::SayLinkEngine linker;
|
||||
linker.SetLinkType(EQ::saylink::SayLinkItemData);
|
||||
@@ -91,10 +92,10 @@ void command_lootsim(Client *c, const Seperator *sep)
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"-- [{}] item_id [{}] chance [{}] rolled_count [{}] ({:.2f}%) name [{}]",
|
||||
ei,
|
||||
e.item_id,
|
||||
e.chance,
|
||||
"-- lootdrop_id [{}] item_id [{}] chance [{}] rolled_count [{}] ({:.2f}%) name [{}]",
|
||||
f.lootdrop_id,
|
||||
f.item_id,
|
||||
f.chance,
|
||||
rolled_count,
|
||||
rolled_percentage,
|
||||
linker.GenerateLink()
|
||||
@@ -103,7 +104,6 @@ void command_lootsim(Client *c, const Seperator *sep)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// global loot
|
||||
auto tables = zone->GetGlobalLootTables(npc);
|
||||
if (!tables.empty()) {
|
||||
@@ -116,36 +116,37 @@ void command_lootsim(Client *c, const Seperator *sep)
|
||||
c->Message(Chat::White, fmt::format("# Global Loot Table ID [{}]", id).c_str());
|
||||
c->SendChatLineBreak();
|
||||
|
||||
loot_table = database.GetLootTable(id);
|
||||
loot_table = zone->GetLootTable(loottable_id);
|
||||
if (!loot_table) {
|
||||
c->Message(Chat::Red, fmt::format("Global Loot table not found [{}]", id).c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
for (uint32 i = 0; i < loot_table->NumEntries; i++) {
|
||||
auto le = loot_table->Entries[i];
|
||||
le = zone->GetLootTableEntries(loottable_id);
|
||||
|
||||
// translate above for loop using loot_table_entries
|
||||
for (auto &e: le) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"# Lootdrop ID [{}] drop_limit [{}] min_drop [{}] mult [{}] probability [{}]",
|
||||
le.lootdrop_id,
|
||||
le.droplimit,
|
||||
le.mindrop,
|
||||
le.multiplier,
|
||||
le.probability
|
||||
e.lootdrop_id,
|
||||
e.droplimit,
|
||||
e.mindrop,
|
||||
e.multiplier,
|
||||
e.probability
|
||||
).c_str()
|
||||
);
|
||||
|
||||
auto loot_drop = database.GetLootDrop(le.lootdrop_id);
|
||||
if (!loot_drop) {
|
||||
auto loot_drop = zone->GetLootdrop(e.lootdrop_id);
|
||||
if (!loot_drop.id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (uint32 ei = 0; ei < loot_drop->NumEntries; ei++) {
|
||||
auto e = loot_drop->Entries[ei];
|
||||
int rolled_count = npc->GetRolledItemCount(e.item_id);
|
||||
const EQ::ItemData *item = database.GetItem(e.item_id);
|
||||
auto loot_drop_entries = zone->GetLootdropEntries(e.lootdrop_id);
|
||||
for (auto &f: loot_drop_entries) {
|
||||
int rolled_count = npc->GetRolledItemCount(f.item_id);
|
||||
const EQ::ItemData *item = database.GetItem(f.item_id);
|
||||
|
||||
EQ::SayLinkEngine linker;
|
||||
linker.SetLinkType(EQ::saylink::SayLinkItemData);
|
||||
@@ -156,10 +157,10 @@ void command_lootsim(Client *c, const Seperator *sep)
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"-- [{}] item_id [{}] chance [{}] rolled_count [{}] ({:.2f}%) name [{}]",
|
||||
ei,
|
||||
e.item_id,
|
||||
e.chance,
|
||||
"-- lootdrop_id [{}] item_id [{}] chance [{}] rolled_count [{}] ({:.2f}%) name [{}]",
|
||||
f.lootdrop_id,
|
||||
f.item_id,
|
||||
f.chance,
|
||||
rolled_count,
|
||||
rolled_percentage,
|
||||
linker.GenerateLink()
|
||||
|
||||
@@ -118,7 +118,7 @@ void command_npcloot(Client *c, const Seperator *sep)
|
||||
uint16 gold = sep->IsNumber(3) ? EQ::Clamp(Strings::ToInt(sep->arg[3]), 0, 65535) : 0;
|
||||
uint16 silver = sep->IsNumber(4) ? EQ::Clamp(Strings::ToInt(sep->arg[4]), 0, 65535) : 0;
|
||||
uint16 copper = sep->IsNumber(5) ? EQ::Clamp(Strings::ToInt(sep->arg[5]), 0, 65535) : 0;
|
||||
target->AddCash(
|
||||
target->AddLootCash(
|
||||
copper,
|
||||
silver,
|
||||
gold,
|
||||
|
||||
@@ -25,6 +25,7 @@ void command_reload(Client *c, const Seperator *sep)
|
||||
bool is_ground_spawns = !strcasecmp(sep->arg[1], "ground_spawns");
|
||||
bool is_level_mods = !strcasecmp(sep->arg[1], "level_mods");
|
||||
bool is_logs = !strcasecmp(sep->arg[1], "logs") || is_logs_reload_alias;
|
||||
bool is_loot = !strcasecmp(sep->arg[1], "loot");
|
||||
bool is_merchants = !strcasecmp(sep->arg[1], "merchants");
|
||||
bool is_npc_emotes = !strcasecmp(sep->arg[1], "npc_emotes");
|
||||
bool is_objects = !strcasecmp(sep->arg[1], "objects");
|
||||
@@ -55,6 +56,7 @@ void command_reload(Client *c, const Seperator *sep)
|
||||
!is_ground_spawns &&
|
||||
!is_level_mods &&
|
||||
!is_logs &&
|
||||
!is_loot &&
|
||||
!is_merchants &&
|
||||
!is_npc_emotes &&
|
||||
!is_objects &&
|
||||
@@ -119,6 +121,9 @@ void command_reload(Client *c, const Seperator *sep)
|
||||
} else if (is_logs) {
|
||||
c->Message(Chat::White, "Attempting to reload Log Settings globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadLogs, 0);
|
||||
} else if (is_loot) {
|
||||
c->Message(Chat::White, "Attempting to reload Loot globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadLoot, 0);
|
||||
} else if (is_merchants) {
|
||||
c->Message(Chat::White, "Attempting to reload Merchants globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadMerchants, 0);
|
||||
|
||||
@@ -4,13 +4,13 @@ void ShowZoneLoot(Client *c, const Seperator *sep)
|
||||
{
|
||||
const uint32 search_item_id = sep->IsNumber(2) ? Strings::ToUnsignedInt(sep->arg[2]) : 0;
|
||||
|
||||
std::vector<std::pair<NPC *, ItemList>> v;
|
||||
std::vector<std::pair<NPC *, LootItems>> v;
|
||||
|
||||
uint32 loot_count = 0;
|
||||
uint32 loot_number = 1;
|
||||
|
||||
for (auto npc_entity: entity_list.GetNPCList()) {
|
||||
auto il = npc_entity.second->GetItemList();
|
||||
auto il = npc_entity.second->GetLootItems();
|
||||
v.emplace_back(std::make_pair(npc_entity.second, il));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user