Fix Model Vault (#870)

Allow pets, rockets and racecars to be stored in vault
This commit is contained in:
David Markowitz 2022-12-04 14:25:25 -08:00 committed by GitHub
parent ab5adea24c
commit de3e53de6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 9 deletions

View File

@ -330,7 +330,9 @@ void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType in
const auto lot = item->GetLot(); const auto lot = item->GetLot();
if (item->GetConfig().empty() && !item->GetBound() || (item->GetBound() && item->GetInfo().isBOP)) { const auto subkey = item->GetSubKey();
if (subkey == LWOOBJID_EMPTY && item->GetConfig().empty() && (!item->GetBound() || (item->GetBound() && item->GetInfo().isBOP))) {
auto left = std::min<uint32_t>(count, origin->GetLotCount(lot)); auto left = std::min<uint32_t>(count, origin->GetLotCount(lot));
while (left > 0) { while (left > 0) {
@ -361,7 +363,7 @@ void InventoryComponent::MoveItemToInventory(Item* item, const eInventoryType in
const auto delta = std::min<uint32_t>(item->GetCount(), count); const auto delta = std::min<uint32_t>(item->GetCount(), count);
AddItem(lot, delta, eLootSourceType::LOOT_SOURCE_NONE, inventory, config, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, LWOOBJID_EMPTY, origin->GetType(), 0, item->GetBound(), preferredSlot); AddItem(lot, delta, eLootSourceType::LOOT_SOURCE_NONE, inventory, config, LWOOBJID_EMPTY, showFlyingLot, isModMoveAndEquip, subkey, origin->GetType(), 0, item->GetBound(), preferredSlot);
item->SetCount(item->GetCount() - delta, false, false); item->SetCount(item->GetCount() - delta, false, false);
} }

View File

@ -4462,13 +4462,13 @@ void GameMessages::SendAddBuff(LWOOBJID& objectID, const LWOOBJID& casterID, uin
// NT // NT
void GameMessages::HandleRequestMoveItemBetweenInventoryTypes(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) { void GameMessages::HandleRequestMoveItemBetweenInventoryTypes(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
bool bAllowPartial; bool bAllowPartial{};
int32_t destSlot = -1; int32_t destSlot = -1;
int32_t iStackCount = 1; int32_t iStackCount = 1;
eInventoryType invTypeDst = ITEMS; eInventoryType invTypeDst = ITEMS;
eInventoryType invTypeSrc = ITEMS; eInventoryType invTypeSrc = ITEMS;
LWOOBJID itemID = LWOOBJID_EMPTY; LWOOBJID itemID = LWOOBJID_EMPTY;
bool showFlyingLoot; bool showFlyingLoot{};
LWOOBJID subkey = LWOOBJID_EMPTY; LWOOBJID subkey = LWOOBJID_EMPTY;
LOT itemLOT = 0; LOT itemLOT = 0;
@ -4492,12 +4492,12 @@ void GameMessages::HandleRequestMoveItemBetweenInventoryTypes(RakNet::BitStream*
if (itemID != LWOOBJID_EMPTY) { if (itemID != LWOOBJID_EMPTY) {
auto* item = inventoryComponent->FindItemById(itemID); auto* item = inventoryComponent->FindItemById(itemID);
if (item == nullptr) { if (!item) return;
return;
}
if (inventoryComponent->IsPet(item->GetSubKey()) || !item->GetConfig().empty()) { // Despawn the pet if we are moving that pet to the vault.
return; auto* petComponent = PetComponent::GetActivePet(entity->GetObjectID());
if (petComponent && petComponent->GetDatabaseId() == item->GetSubKey()) {
inventoryComponent->DespawnPet();
} }
inventoryComponent->MoveItemToInventory(item, invTypeDst, iStackCount, showFlyingLoot, false, false, destSlot); inventoryComponent->MoveItemToInventory(item, invTypeDst, iStackCount, showFlyingLoot, false, false, destSlot);