fix: use after free in mission progression after removing item from inventory

that method is cursed.

no longer has ub when deleting an item from the inventory
This commit is contained in:
David Markowitz 2024-05-12 03:46:07 -07:00 committed by GitHub
parent 4d1395e522
commit c06f96b55f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5354,14 +5354,14 @@ void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream& inStream, En
if (eInvType == eInventoryType::MODELS) {
item->DisassembleModel(iStackCount);
}
auto lot = item->GetLot();
item->SetCount(item->GetCount() - iStackCount, true);
Game::entityManager->SerializeEntity(entity);
auto* missionComponent = entity->GetComponent<MissionComponent>();
if (missionComponent != nullptr) {
missionComponent->Progress(eMissionTaskType::GATHER, item->GetLot(), LWOOBJID_EMPTY, "", -iStackCount);
missionComponent->Progress(eMissionTaskType::GATHER, lot, LWOOBJID_EMPTY, "", -iStackCount);
}
}
}