Update GameMessages.cpp

I promise I'm not farming changes. I woke up at like 4AM and realised that I'd screwed up in an obvious way. Note to self: You are ALLOWED to change variables.

Wasn't caught in testing because, well, it turns out it's actually impossible to test the edge case this covers, due to the script for the brick console.
This commit is contained in:
NinjaOfLU 2022-04-14 10:09:40 +01:00 committed by GitHub
parent cdbb42badf
commit 3d6d5e58a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5433,6 +5433,8 @@ void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream* inStream, En
return;
}
iStackCount = std::min<uint32_t>(item->GetCount(), iStackCount);
if (bConfirmed) {
for (auto i = 0; i < iStackCount; ++i) {
if (eInvType == eInventoryType::MODELS)
@ -5441,14 +5443,14 @@ void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream* inStream, En
}
}
item->SetCount(item->GetCount() - std::min<uint32_t>(item->GetCount(), iStackCount), true);
item->SetCount(item->GetCount() - iStackCount, true);
EntityManager::Instance()->SerializeEntity(entity);
auto* missionComponent = entity->GetComponent<MissionComponent>();
if (missionComponent != nullptr)
{
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_ITEM_COLLECTION, item->GetLot(), LWOOBJID_EMPTY, "", -std::min<uint32_t>(item->GetCount(), iStackCount));
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_ITEM_COLLECTION, item->GetLot(), LWOOBJID_EMPTY, "", -iStackCount);
}
}
}