mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-22 21:43:35 +00:00
Merge remote-tracking branch 'upstream/main' into first-draft-leaderboard-re-write
This commit is contained in:
commit
59d7121978
@ -13,10 +13,8 @@ AMFBaseValue* AMFDeserialize::Read(RakNet::BitStream* inStream) {
|
||||
if (!inStream) return nullptr;
|
||||
AMFBaseValue* returnValue = nullptr;
|
||||
// Read in the value type from the bitStream
|
||||
uint8_t i;
|
||||
inStream->Read(i);
|
||||
if (i > static_cast<uint8_t>(eAmf::Dictionary)) return nullptr;
|
||||
eAmf marker = static_cast<eAmf>(i);
|
||||
eAmf marker;
|
||||
inStream->Read(marker);
|
||||
// Based on the typing, create the value associated with that and return the base value class
|
||||
switch (marker) {
|
||||
case eAmf::Undefined: {
|
||||
|
@ -134,3 +134,7 @@ void VendorComponent::SetupConstants() {
|
||||
m_RefreshTimeSeconds = vendorComps[0].refreshTimeSeconds;
|
||||
m_LootMatrixID = vendorComps[0].LootMatrixIndex;
|
||||
}
|
||||
|
||||
bool VendorComponent::SellsItem(const LOT item) const {
|
||||
return m_Inventory.find(item) != m_Inventory.end();
|
||||
}
|
||||
|
@ -67,6 +67,8 @@ public:
|
||||
* Called on startup of vendor to setup the variables for the component.
|
||||
*/
|
||||
void SetupConstants();
|
||||
|
||||
bool SellsItem(const LOT item) const;
|
||||
private:
|
||||
/**
|
||||
* The buy scalar.
|
||||
|
@ -4719,12 +4719,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>();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user