fix: consuming items not decrementing mission progress (#1827)

tested that consuming water no longer leaves a mission unable to be completed
This commit is contained in:
David Markowitz 2025-06-24 20:01:59 -07:00 committed by GitHub
parent 4ed7bd6767
commit f0f98a6108
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -21,6 +21,8 @@
#include "eUseItemResponse.h" #include "eUseItemResponse.h"
#include "dZoneManager.h" #include "dZoneManager.h"
#include "ChatPackets.h" #include "ChatPackets.h"
#include "MissionComponent.h"
#include "eMissionTaskType.h"
#include "CDBrickIDTableTable.h" #include "CDBrickIDTableTable.h"
#include "CDObjectSkillsTable.h" #include "CDObjectSkillsTable.h"
@ -268,9 +270,9 @@ bool Item::IsEquipped() const {
} }
bool Item::Consume() { bool Item::Consume() {
auto* skillsTable = CDClientManager::GetTable<CDObjectSkillsTable>(); auto* const skillsTable = CDClientManager::GetTable<CDObjectSkillsTable>();
auto skills = skillsTable->Query([this](const CDObjectSkills entry) { const auto skills = skillsTable->Query([this](const CDObjectSkills& entry) {
return entry.objectTemplate == static_cast<uint32_t>(lot); return entry.objectTemplate == static_cast<uint32_t>(lot);
}); });
@ -288,7 +290,12 @@ bool Item::Consume() {
GameMessages::SendUseItemResult(inventory->GetComponent()->GetParent(), lot, success); GameMessages::SendUseItemResult(inventory->GetComponent()->GetParent(), lot, success);
if (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); inventory->GetComponent()->RemoveItem(lot, 1);
auto* missionComponent = inventory->GetComponent()->GetParent()->GetComponent<MissionComponent>();
if (missionComponent) missionComponent->Progress(eMissionTaskType::GATHER, myLot, LWOOBJID_EMPTY, "", -1);
} }
return success; return success;