mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 23:17:28 +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);
|
auto* item = inv->FindItemById(itemConsumed);
|
||||||
|
|
||||||
if (item == nullptr) {
|
if (item) item->UseNonEquip(item);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
item->UseNonEquip();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameMessages::HandleMatchRequest(RakNet::BitStream* inStream, Entity* entity) {
|
void GameMessages::HandleMatchRequest(RakNet::BitStream* inStream, Entity* entity) {
|
||||||
|
@ -262,7 +262,7 @@ bool Item::Consume() {
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Item::UseNonEquip() {
|
void Item::UseNonEquip(Item* item) {
|
||||||
LOT thisLot = this->GetLot();
|
LOT thisLot = this->GetLot();
|
||||||
if (!GetInventory()) {
|
if (!GetInventory()) {
|
||||||
Game::logger->LogDebug("Item", "item %i has no inventory??", this->GetLot());
|
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().
|
// This precondition response is taken care of in SpawnPet().
|
||||||
} else {
|
} else {
|
||||||
|
bool success = false;
|
||||||
|
auto inventory = item->GetInventory();
|
||||||
|
if (inventory && inventory->GetType() == eInventoryType::ITEMS) {
|
||||||
auto* compRegistryTable = CDClientManager::Instance()->GetTable<CDComponentsRegistryTable>("ComponentsRegistry");
|
auto* compRegistryTable = CDClientManager::Instance()->GetTable<CDComponentsRegistryTable>("ComponentsRegistry");
|
||||||
const auto packageComponentId = compRegistryTable->GetByIDAndType(lot, COMPONENT_TYPE_PACKAGE);
|
const auto packageComponentId = compRegistryTable->GetByIDAndType(lot, COMPONENT_TYPE_PACKAGE);
|
||||||
|
|
||||||
@ -320,7 +323,7 @@ void Item::UseNonEquip() {
|
|||||||
}
|
}
|
||||||
if (playerInventoryComponent->HasSpaceForLoot(rolledLoot)) {
|
if (playerInventoryComponent->HasSpaceForLoot(rolledLoot)) {
|
||||||
LootGenerator::Instance().GiveLoot(playerInventoryComponent->GetParent(), rolledLoot, eLootSourceType::LOOT_SOURCE_CONSUMPTION);
|
LootGenerator::Instance().GiveLoot(playerInventoryComponent->GetParent(), rolledLoot, eLootSourceType::LOOT_SOURCE_CONSUMPTION);
|
||||||
playerInventoryComponent->RemoveItem(lot, 1);
|
item->SetCount(item->GetCount() - 1);
|
||||||
} else {
|
} else {
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
@ -333,6 +336,7 @@ void Item::UseNonEquip() {
|
|||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Game::logger->LogDebug("Item", "Player %llu %s used item %i", playerEntity->GetObjectID(), success ? "successfully" : "unsuccessfully", thisLot);
|
Game::logger->LogDebug("Item", "Player %llu %s used item %i", playerEntity->GetObjectID(), success ? "successfully" : "unsuccessfully", thisLot);
|
||||||
GameMessages::SendUseItemResult(playerInventoryComponent->GetParent(), thisLot, success);
|
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
|
* 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
|
* Disassembles the part LOTs of this item back into the inventory, if it has any
|
||||||
|
Loading…
Reference in New Issue
Block a user