fix(loot): gate auto-loot sends per loot session

This commit is contained in:
Kelsi 2026-03-14 07:31:15 -07:00
parent c1baffadf0
commit 9cd52c4dd7
2 changed files with 5 additions and 2 deletions

View file

@ -2829,6 +2829,7 @@ private:
struct LocalLootState {
LootResponseData data;
bool moneyTaken = false;
bool itemAutoLootSent = false;
};
std::unordered_map<uint64_t, LocalLootState> localLootState_;
struct PendingLootRetry {

View file

@ -19582,7 +19582,8 @@ void GameHandler::handleLootResponse(network::Packet& packet) {
std::remove_if(pendingGameObjectLootOpens_.begin(), pendingGameObjectLootOpens_.end(),
[&](const PendingLootOpen& p) { return p.guid == currentLoot.lootGuid; }),
pendingGameObjectLootOpens_.end());
localLootState_[currentLoot.lootGuid] = LocalLootState{currentLoot, false};
auto& localLoot = localLootState_[currentLoot.lootGuid];
localLoot.data = currentLoot;
// Query item info so loot window can show names instead of IDs
for (const auto& item : currentLoot.items) {
@ -19607,11 +19608,12 @@ void GameHandler::handleLootResponse(network::Packet& packet) {
}
// Auto-loot items when enabled
if (autoLoot_ && state == WorldState::IN_WORLD && socket) {
if (autoLoot_ && state == WorldState::IN_WORLD && socket && !localLoot.itemAutoLootSent) {
for (const auto& item : currentLoot.items) {
auto pkt = AutostoreLootItemPacket::build(item.slotIndex);
socket->send(pkt);
}
localLoot.itemAutoLootSent = true;
}
}