fix: use CMSG_OPEN_ITEM for locked containers (lockboxes)

Right-clicking a locked container (e.g. Dead-Tooth's Strong Box) was
sending CMSG_USE_ITEM with spellId=0, which the server rejects. Locked
containers (itemClass==1, inventoryType==0) now send CMSG_OPEN_ITEM
instead, letting the server auto-check the keyring for the required key.
This commit is contained in:
Kelsi 2026-03-18 06:06:29 -07:00
parent 2fb7901cca
commit 25138b5648
5 changed files with 50 additions and 2 deletions

View file

@ -2356,7 +2356,14 @@ void InventoryScreen::renderItemSlot(game::Inventory& inventory, const game::Ite
} else if (item.inventoryType > 0) {
gameHandler_->autoEquipItemBySlot(backpackIndex);
} else {
gameHandler_->useItemBySlot(backpackIndex);
// itemClass==1 (Container) with inventoryType==0 means a lockbox;
// use CMSG_OPEN_ITEM so the server checks keyring automatically.
auto* info = gameHandler_->getItemInfo(item.itemId);
if (info && info->valid && info->itemClass == 1) {
gameHandler_->openItemBySlot(backpackIndex);
} else {
gameHandler_->useItemBySlot(backpackIndex);
}
}
} else if (kind == SlotKind::BACKPACK && isBagSlot) {
LOG_INFO("Right-click bag item: name='", item.name,
@ -2369,7 +2376,12 @@ void InventoryScreen::renderItemSlot(game::Inventory& inventory, const game::Ite
} else if (item.inventoryType > 0) {
gameHandler_->autoEquipItemInBag(bagIndex, bagSlotIndex);
} else {
gameHandler_->useItemInBag(bagIndex, bagSlotIndex);
auto* info = gameHandler_->getItemInfo(item.itemId);
if (info && info->valid && info->itemClass == 1) {
gameHandler_->openItemInBag(bagIndex, bagSlotIndex);
} else {
gameHandler_->useItemInBag(bagIndex, bagSlotIndex);
}
}
}
}