From f0f98a610866a28d3f4ae1d849809fc608271ab1 Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Tue, 24 Jun 2025 20:01:59 -0700 Subject: [PATCH] fix: consuming items not decrementing mission progress (#1827) tested that consuming water no longer leaves a mission unable to be completed --- dGame/dInventory/Item.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dGame/dInventory/Item.cpp b/dGame/dInventory/Item.cpp index 32603761..a552eddf 100644 --- a/dGame/dInventory/Item.cpp +++ b/dGame/dInventory/Item.cpp @@ -21,6 +21,8 @@ #include "eUseItemResponse.h" #include "dZoneManager.h" #include "ChatPackets.h" +#include "MissionComponent.h" +#include "eMissionTaskType.h" #include "CDBrickIDTableTable.h" #include "CDObjectSkillsTable.h" @@ -268,9 +270,9 @@ bool Item::IsEquipped() const { } bool Item::Consume() { - auto* skillsTable = CDClientManager::GetTable(); + auto* const skillsTable = CDClientManager::GetTable(); - auto skills = skillsTable->Query([this](const CDObjectSkills entry) { + const auto skills = skillsTable->Query([this](const CDObjectSkills& entry) { return entry.objectTemplate == static_cast(lot); }); @@ -288,7 +290,12 @@ bool Item::Consume() { GameMessages::SendUseItemResult(inventory->GetComponent()->GetParent(), lot, success); if (success) { + // Save this because if this is the last item in the inventory + // we may delete ourself (lol) + const auto myLot = this->lot; inventory->GetComponent()->RemoveItem(lot, 1); + auto* missionComponent = inventory->GetComponent()->GetParent()->GetComponent(); + if (missionComponent) missionComponent->Progress(eMissionTaskType::GATHER, myLot, LWOOBJID_EMPTY, "", -1); } return success;