Fix: remove ability to buy items from a vendor if they don't sell said item (#1105)

This commit is contained in:
David Markowitz
2023-06-03 00:40:46 -07:00
committed by GitHub
parent 9fabff16e4
commit 8ae1e1bc6b
3 changed files with 13 additions and 2 deletions

View File

@@ -4733,12 +4733,17 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti
const auto isCommendationVendor = entity->GetLOT() == 13806;
VendorComponent* vend = static_cast<VendorComponent*>(entity->GetComponent(eReplicaComponentType::VENDOR));
auto* vend = entity->GetComponent<VendorComponent>();
if (!vend && !isCommendationVendor) return;
InventoryComponent* inv = static_cast<InventoryComponent*>(player->GetComponent(eReplicaComponentType::INVENTORY));
auto* inv = player->GetComponent<InventoryComponent>();
if (!inv) return;
if (!isCommendationVendor && !vend->SellsItem(item)) {
Game::logger->Log("GameMessages", "User %llu %s tried to buy an item %i from a vendor when they do not sell said item", player->GetObjectID(), user->GetUsername().c_str(), item);
return;
}
CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
CDItemComponentTable* itemComponentTable = CDClientManager::Instance().GetTable<CDItemComponentTable>();