From fe4b29f64338f118f0df697691e5a26b51a33e19 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Wed, 6 Mar 2024 17:50:21 -0800 Subject: [PATCH] fix: commendation vendor cant accept missions (#1497) * fix: incorrect serialization for commendation * Update VendorComponent.h --- .../dComponents/AchievementVendorComponent.cpp | 17 +++++++++++++---- dGame/dComponents/AchievementVendorComponent.h | 4 +++- dGame/dComponents/VendorComponent.h | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/dGame/dComponents/AchievementVendorComponent.cpp b/dGame/dComponents/AchievementVendorComponent.cpp index 10a0ca29..006a2b6f 100644 --- a/dGame/dComponents/AchievementVendorComponent.cpp +++ b/dGame/dComponents/AchievementVendorComponent.cpp @@ -9,11 +9,15 @@ #include "UserManager.h" #include "CDMissionsTable.h" +AchievementVendorComponent::AchievementVendorComponent(Entity* parent) : VendorComponent(parent) { + RefreshInventory(true); +}; + bool AchievementVendorComponent::SellsItem(Entity* buyer, const LOT lot) { auto* missionComponent = buyer->GetComponent(); if (!missionComponent) return false; - if (m_PlayerPurchasableItems[buyer->GetObjectID()].contains(lot)){ + if (m_PlayerPurchasableItems[buyer->GetObjectID()].contains(lot)) { return true; } @@ -35,7 +39,7 @@ void AchievementVendorComponent::Buy(Entity* buyer, LOT lot, uint32_t count) { int itemCompID = compRegistryTable->GetByIDAndType(lot, eReplicaComponentType::ITEM); CDItemComponent itemComp = itemComponentTable->GetItemComponentByID(itemCompID); uint32_t costLOT = itemComp.commendationLOT; - + if (costLOT == -1 || !SellsItem(buyer, lot)) { auto* user = UserManager::Instance()->GetUser(buyer->GetSystemAddress()); CheatDetection::ReportCheat(user, buyer->GetSystemAddress(), "Attempted to buy item %i from achievement vendor %i that is not purchasable", lot, m_Parent->GetLOT()); @@ -44,7 +48,7 @@ void AchievementVendorComponent::Buy(Entity* buyer, LOT lot, uint32_t count) { } auto* inventoryComponent = buyer->GetComponent(); - if (!inventoryComponent) { + if (!inventoryComponent) { GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_FAIL); return; } @@ -69,4 +73,9 @@ void AchievementVendorComponent::Buy(Entity* buyer, LOT lot, uint32_t count) { inventoryComponent->AddItem(lot, count, eLootSourceType::VENDOR); GameMessages::SendVendorTransactionResult(buyer, buyer->GetSystemAddress(), eVendorTransactionResult::PURCHASE_SUCCESS); -} \ No newline at end of file +} + +void AchievementVendorComponent::RefreshInventory(bool isCreation) { + SetHasStandardCostItems(true); + Game::entityManager->SerializeEntity(m_Parent); +} diff --git a/dGame/dComponents/AchievementVendorComponent.h b/dGame/dComponents/AchievementVendorComponent.h index bffd3983..ba6c7c2a 100644 --- a/dGame/dComponents/AchievementVendorComponent.h +++ b/dGame/dComponents/AchievementVendorComponent.h @@ -11,7 +11,9 @@ class Entity; class AchievementVendorComponent final : public VendorComponent { public: static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::ACHIEVEMENT_VENDOR; - AchievementVendorComponent(Entity* parent) : VendorComponent(parent) {}; + AchievementVendorComponent(Entity* parent); + + void RefreshInventory(bool isCreation = false) override; bool SellsItem(Entity* buyer, const LOT lot); void Buy(Entity* buyer, LOT lot, uint32_t count); diff --git a/dGame/dComponents/VendorComponent.h b/dGame/dComponents/VendorComponent.h index b5e9f5d0..432f1801 100644 --- a/dGame/dComponents/VendorComponent.h +++ b/dGame/dComponents/VendorComponent.h @@ -26,7 +26,7 @@ public: void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void OnUse(Entity* originator) override; - void RefreshInventory(bool isCreation = false); + virtual void RefreshInventory(bool isCreation = false); void SetupConstants(); bool SellsItem(const LOT item) const; float GetBuyScalar() const { return m_BuyScalar; }