mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-19 21:02:41 +00:00
Merge pull request #84 from Valorith/copilot/sub-pr-80-yet-again
Fix partial inventory write: rollback transaction on PutItemInInventory failure
This commit is contained in:
commit
4663353699
@ -4745,15 +4745,30 @@ bool Client::PutItemInInventoryWithStacking(EQ::ItemInstance *inst)
|
||||
}
|
||||
|
||||
if (!queue.empty()) {
|
||||
bool success = true;
|
||||
database.TransactionBegin();
|
||||
for (auto const &i: queue) {
|
||||
auto bag_inst = GetInv().GetItem(i.slot_id);
|
||||
if (!bag_inst) {
|
||||
LogError("Client inventory error occurred. Character ID {} Slot_ID {}", CharacterID(), i.slot_id);
|
||||
continue;
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
bag_inst->SetCharges(i.quantity + bag_inst->GetCharges());
|
||||
PutItemInInventory(i.slot_id, *bag_inst, true);
|
||||
if (!PutItemInInventory(i.slot_id, *bag_inst, true)) {
|
||||
LogError(
|
||||
"Failed to save stacked item to inventory. Character ID {} Slot_ID {}",
|
||||
CharacterID(),
|
||||
i.slot_id
|
||||
);
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
database.TransactionRollback();
|
||||
return false;
|
||||
}
|
||||
|
||||
database.TransactionCommit();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user