mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 05:27:19 +00:00
sanity check on opening packages (#923)
This commit is contained in:
parent
1470af99c3
commit
5cc7d47074
@ -5763,11 +5763,7 @@ void GameMessages::HandleUseNonEquipmentItem(RakNet::BitStream* inStream, Entity
|
||||
|
||||
auto* item = inv->FindItemById(itemConsumed);
|
||||
|
||||
if (item == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
item->UseNonEquip();
|
||||
if (item) item->UseNonEquip(item);
|
||||
}
|
||||
|
||||
void GameMessages::HandleMatchRequest(RakNet::BitStream* inStream, Entity* entity) {
|
||||
|
@ -262,7 +262,7 @@ bool Item::Consume() {
|
||||
return success;
|
||||
}
|
||||
|
||||
void Item::UseNonEquip() {
|
||||
void Item::UseNonEquip(Item* item) {
|
||||
LOT thisLot = this->GetLot();
|
||||
if (!GetInventory()) {
|
||||
Game::logger->LogDebug("Item", "item %i has no inventory??", this->GetLot());
|
||||
@ -292,6 +292,9 @@ void Item::UseNonEquip() {
|
||||
}
|
||||
// This precondition response is taken care of in SpawnPet().
|
||||
} else {
|
||||
bool success = false;
|
||||
auto inventory = item->GetInventory();
|
||||
if (inventory && inventory->GetType() == eInventoryType::ITEMS) {
|
||||
auto* compRegistryTable = CDClientManager::Instance()->GetTable<CDComponentsRegistryTable>("ComponentsRegistry");
|
||||
const auto packageComponentId = compRegistryTable->GetByIDAndType(lot, COMPONENT_TYPE_PACKAGE);
|
||||
|
||||
@ -320,7 +323,7 @@ void Item::UseNonEquip() {
|
||||
}
|
||||
if (playerInventoryComponent->HasSpaceForLoot(rolledLoot)) {
|
||||
LootGenerator::Instance().GiveLoot(playerInventoryComponent->GetParent(), rolledLoot, eLootSourceType::LOOT_SOURCE_CONSUMPTION);
|
||||
playerInventoryComponent->RemoveItem(lot, 1);
|
||||
item->SetCount(item->GetCount() - 1);
|
||||
} else {
|
||||
success = false;
|
||||
}
|
||||
@ -333,6 +336,7 @@ void Item::UseNonEquip() {
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Game::logger->LogDebug("Item", "Player %llu %s used item %i", playerEntity->GetObjectID(), success ? "successfully" : "unsuccessfully", thisLot);
|
||||
GameMessages::SendUseItemResult(playerInventoryComponent->GetParent(), thisLot, success);
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public:
|
||||
/**
|
||||
* Uses this item if its non equip, essentially an interface for the linked GM
|
||||
*/
|
||||
void UseNonEquip();
|
||||
void UseNonEquip(Item* item);
|
||||
|
||||
/**
|
||||
* Disassembles the part LOTs of this item back into the inventory, if it has any
|
||||
|
Loading…
Reference in New Issue
Block a user