enforce attempting a DB deleting on broker, even if the item does not exist in the broker memory
This commit is contained in:
parent
e1a759a1a2
commit
74fa672e65
@ -236,15 +236,18 @@ void BrokerManager::SetSalePrice(int32 cid, int64 uid, int64 price)
|
||||
}
|
||||
}
|
||||
|
||||
void BrokerManager::RemoveItem(int32 cid, int64 uid, int16 qty)
|
||||
void BrokerManager::RemoveItem(int32 cid, int64 uid, int16 qty, bool shouldDelete)
|
||||
{
|
||||
bool didDelete = false;
|
||||
SaleItem snapshot;
|
||||
std::optional<SaleItem> snapshot;
|
||||
{
|
||||
std::unique_lock lock(mtx_);
|
||||
if (auto ait = active_items_by_char_.find(cid); ait != active_items_by_char_.end()) {
|
||||
auto& m = ait->second;
|
||||
if (auto it = m.find(uid); it != m.end()) {
|
||||
if(shouldDelete)
|
||||
qty = it->second.count;
|
||||
|
||||
it->second.count -= qty;
|
||||
if (it->second.count <= 0) {
|
||||
didDelete = true;
|
||||
@ -258,14 +261,14 @@ void BrokerManager::RemoveItem(int32 cid, int64 uid, int16 qty)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (didDelete) {
|
||||
if (didDelete || shouldDelete) {
|
||||
DeleteItemFromDB(cid, uid);
|
||||
peer_manager.sendPeersRemoveItemSale(cid, uid);
|
||||
}
|
||||
else if (snapshot.count > 0) {
|
||||
SaveItemToDB(snapshot);
|
||||
peer_manager.sendPeersAddItemSale(snapshot.character_id, snapshot.house_id, snapshot.item_id, snapshot.unique_id, snapshot.cost_copper, snapshot.inv_slot_id,
|
||||
snapshot.slot_id, snapshot.count, snapshot.from_inventory, snapshot.for_sale, snapshot.creator);
|
||||
else if (snapshot) {
|
||||
SaveItemToDB(*snapshot);
|
||||
peer_manager.sendPeersAddItemSale(snapshot->character_id, snapshot->house_id, snapshot->item_id, snapshot->unique_id, snapshot->cost_copper, snapshot->inv_slot_id,
|
||||
snapshot->slot_id, snapshot->count, snapshot->from_inventory, snapshot->for_sale, snapshot->creator);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ public:
|
||||
int64 GetSalePrice(int32 cid, int64 uid);
|
||||
|
||||
//–– Remove quantity
|
||||
void RemoveItem(int32 cid, int64 uid, int16 quantity = 1);
|
||||
void RemoveItem(int32 cid, int64 uid, int16 quantity = 1, bool shouldDelete = false);
|
||||
|
||||
//–– Attempt to buy (atomic DB + in-memory + broadcast)
|
||||
bool BuyItem(Client* buyer, int32 seller_cid, int64 uid, int32 quantity);
|
||||
|
@ -7115,7 +7115,7 @@ void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteComma
|
||||
return;
|
||||
}
|
||||
if(client->GetPlayer()->item_list.IsItemInSlotType(item, InventorySlotType::HOUSE_VAULT) || client->GetPlayer()->item_list.IsItemInSlotType(item, InventorySlotType::BASE_INVENTORY)) {
|
||||
broker.RemoveItem(client->GetPlayer()->GetCharacterID(), item->details.unique_id, item->details.count);
|
||||
broker.RemoveItem(client->GetPlayer()->GetCharacterID(), item->details.unique_id, item->details.count, true);
|
||||
}
|
||||
if(item->GetItemScript() && lua_interface)
|
||||
lua_interface->RunItemScript(item->GetItemScript(), "destroyed", item, client->GetPlayer());
|
||||
|
Loading…
x
Reference in New Issue
Block a user