fix zone on 16.50, fix infinite item bug, fix grappler crashing on some versions

This commit is contained in:
Milxnor
2023-04-02 12:23:42 -04:00
parent 20e9fb87df
commit f41b18f875
3 changed files with 30 additions and 9 deletions

View File

@@ -197,11 +197,35 @@ bool AFortInventory::RemoveItem(const FGuid& ItemGuid, bool* bShouldUpdate, int
auto NewCount = ReplicatedEntry->GetCount() - Count;
if (NewCount > 0 || (ItemDefinition->ShouldPersistWhenFinalStackEmpty() && !bForceRemoval))
{
if (ItemDefinition->ShouldPersistWhenFinalStackEmpty())
NewCount = NewCount < 0 ? 0 : NewCount; // min(NewCount, 0) or something i forgot
auto& ItemInstances = GetItemList().GetItemInstances();
auto& ReplicatedEntries = GetItemList().GetReplicatedEntries();
bool bOverrideChangeStackSize = false;
if (ItemDefinition->ShouldPersistWhenFinalStackEmpty() && !bForceRemoval)
{
bool bIsFinalStack = true;
for (int i = 0; i < ItemInstances.Num(); i++)
{
auto ItemInstance = ItemInstances.at(i);
if (ItemInstance->GetItemEntry()->GetItemDefinition() == ItemDefinition && ItemInstance->GetItemEntry()->GetItemGuid() != ItemGuid)
{
bIsFinalStack = false;
break;
}
}
if (bIsFinalStack)
{
NewCount = NewCount < 0 ? 0 : NewCount; // min(NewCount, 0) or something i forgot
bOverrideChangeStackSize = true;
}
}
if (NewCount > 0 || bOverrideChangeStackSize)
{
ItemInstance->GetItemEntry()->GetCount() = NewCount;
ReplicatedEntry->GetCount() = NewCount;
@@ -214,9 +238,6 @@ bool AFortInventory::RemoveItem(const FGuid& ItemGuid, bool* bShouldUpdate, int
static auto FortItemEntryStruct = FindObject<UStruct>(L"/Script/FortniteGame.FortItemEntry");
static auto FortItemEntrySize = FortItemEntryStruct->GetPropertiesSize();
auto& ItemInstances = GetItemList().GetItemInstances();
auto& ReplicatedEntries = GetItemList().GetReplicatedEntries();
for (int i = 0; i < ItemInstances.Num(); i++)
{
if (ItemInstances.at(i)->GetItemEntry()->GetItemGuid() == ItemGuid)