From f41b18f87520adea90fa4e7222e90420cd48999f Mon Sep 17 00:00:00 2001 From: Milxnor Date: Sun, 2 Apr 2023 12:23:42 -0400 Subject: [PATCH] fix zone on 16.50, fix infinite item bug, fix grappler crashing on some versions --- Project Reboot 3.0/FortInventory.cpp | 35 ++++++++++++++++++++++------ Project Reboot 3.0/dllmain.cpp | 2 +- Project Reboot 3.0/finder.h | 2 +- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Project Reboot 3.0/FortInventory.cpp b/Project Reboot 3.0/FortInventory.cpp index 492b885..71d8123 100644 --- a/Project Reboot 3.0/FortInventory.cpp +++ b/Project Reboot 3.0/FortInventory.cpp @@ -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(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) diff --git a/Project Reboot 3.0/dllmain.cpp b/Project Reboot 3.0/dllmain.cpp index 16cdf6d..6a9dcaf 100644 --- a/Project Reboot 3.0/dllmain.cpp +++ b/Project Reboot 3.0/dllmain.cpp @@ -283,7 +283,7 @@ DWORD WINAPI Main(LPVOID) break; } - if (*(uint8_t*)(uint8_t*)(OnPlayImpactFXPtrRef - i) == 0x4C && *(uint8_t*)(uint8_t*)(OnPlayImpactFXPtrRef - i + 1) == 0x8B) + if (*(uint8_t*)(uint8_t*)(OnPlayImpactFXPtrRef - i) == 0x4C && *(uint8_t*)(uint8_t*)(OnPlayImpactFXPtrRef - i + 1) == 0x8B && *(uint8_t*)(uint8_t*)(OnPlayImpactFXPtrRef - i + 2) == 0xDC) { OnPlayImpactFXAddr = OnPlayImpactFXPtrRef - i; break; diff --git a/Project Reboot 3.0/finder.h b/Project Reboot 3.0/finder.h index bff49b6..e66aa7f 100644 --- a/Project Reboot 3.0/finder.h +++ b/Project Reboot 3.0/finder.h @@ -601,7 +601,7 @@ static inline uint64 FindSetZoneToIndex() // actually StartNewSafeZonePhase // return Memcury::Scanner::FindPattern("48 8B C4 48 89 58 10 48 89 70 18 48 89 78 20 55 41 54 41 55 41 56 41 57 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? 0F 29 70 C8 0F 29 78 B8 44 0F 29 40 ? 44 0F 29 48 ? 44 0F 29 50 ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 85 ? ? ? ? 4C 8B B1 ? ? ? ? 45 33 ED 89 54 24 70 44 8B FA 48 89 4C 24").Get(); // 18.40 // return Memcury::Scanner::FindPattern("40 55 53 56 41 55 48 8D 6C 24 ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 45 18 48 8B").Get(); // 14.60 - auto Addr = Memcury::Scanner::FindStringRef(L"FortGameModeAthena: No MegaStorm on SafeZone[%d]. GridCellThickness is less than 1.0.", true, 0, Fortnite_Version >= 17).Get(); + auto Addr = Memcury::Scanner::FindStringRef(L"FortGameModeAthena: No MegaStorm on SafeZone[%d]. GridCellThickness is less than 1.0.", true, 0, Fortnite_Version >= 16.50).Get(); // return FindBytes(Addr, { 0x40, 0x55 }, 30000, 0, true); if (!Addr)