mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-13 10:58:20 +00:00
[Bots] Optimize inventory loading. (#2588)
* [Bots] Optimize inventory loading. # Notes - Bots previously were running 23 individual queries to load their inventory versus grabbing their inventory all at once and referencing it in memory. * Typo. * Update bot_database.cpp * Update bot_database.cpp * Update bot.cpp
This commit is contained in:
+26
-1
@@ -24,6 +24,8 @@
|
||||
#include "../common/strings.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
|
||||
#include "../common/repositories/bot_inventories_repository.h"
|
||||
|
||||
#include "zonedb.h"
|
||||
#include "../common/zone_store.h"
|
||||
#include "bot.h"
|
||||
@@ -1360,6 +1362,30 @@ bool BotDatabase::LoadItemBySlot(const uint32 bot_id, const uint32 slot_id, uint
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BotDatabase::LoadItemSlots(const uint32 bot_id, std::map<uint16, uint32>& m)
|
||||
{
|
||||
if (!bot_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto& l = BotInventoriesRepository::GetWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
"bot_id = {}",
|
||||
bot_id
|
||||
)
|
||||
);
|
||||
if (l.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const auto& e : l) {
|
||||
m.insert(std::pair<uint16, uint32>(e.slot_id, e.item_id));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BotDatabase::SaveItemBySlot(Bot* bot_inst, const uint32 slot_id, const EQ::ItemInstance* item_inst)
|
||||
{
|
||||
if (!bot_inst || !bot_inst->GetBotID() || slot_id > EQ::invslot::EQUIPMENT_END)
|
||||
@@ -3276,7 +3302,6 @@ const char* BotDatabase::fail::QueryInventoryCount() { return "Failed to query i
|
||||
const char* BotDatabase::fail::LoadItems() { return "Failed to load items"; }
|
||||
const char* BotDatabase::fail::SaveItems() { return "Failed to save items"; }
|
||||
const char* BotDatabase::fail::DeleteItems() { return "Failed to delete items"; }
|
||||
const char* BotDatabase::fail::LoadItemBySlot() { return "Failed to load item by slot"; }
|
||||
const char* BotDatabase::fail::SaveItemBySlot() { return "Failed to save item by slot"; }
|
||||
const char* BotDatabase::fail::DeleteItemBySlot() { return "Failed to delete item by slot"; }
|
||||
const char* BotDatabase::fail::LoadEquipmentColor() { return "Failed to load equipment color"; }
|
||||
|
||||
Reference in New Issue
Block a user