From 891f45f469f730c35a87dc6c59ee9deff5128408 Mon Sep 17 00:00:00 2001 From: Milxnor Date: Sat, 29 Apr 2023 20:15:24 -0400 Subject: [PATCH] a bit Fixed MCP on 1.8, Fixed some buildings not showing up on 1.7.2 and 1.8, fixed listplayers crashing on some versions --- Project Reboot 3.0/FortPlayerController.cpp | 5 ++++- Project Reboot 3.0/FortPlayerControllerAthena.h | 2 +- Project Reboot 3.0/FortPlayerStateAthena.h | 8 +++----- Project Reboot 3.0/NetConnection.cpp | 16 +++++++++++++--- Project Reboot 3.0/NetDriver.cpp | 10 +++++++--- Project Reboot 3.0/Object.cpp | 15 +++++++++++++++ Project Reboot 3.0/Object.h | 3 +++ Project Reboot 3.0/Package.h | 9 +++++++++ Project Reboot 3.0/PlayerState.cpp | 15 +++++++++++++++ Project Reboot 3.0/PlayerState.h | 3 +++ Project Reboot 3.0/Project Reboot 3.0.vcxproj | 2 ++ .../Project Reboot 3.0.vcxproj.filters | 12 +++++++++--- Project Reboot 3.0/SavePackage.cpp | 9 +++++++++ Project Reboot 3.0/builder.h | 1 - Project Reboot 3.0/commands.h | 8 +++++++- Project Reboot 3.0/gui.h | 5 ++++- 16 files changed, 104 insertions(+), 19 deletions(-) create mode 100644 Project Reboot 3.0/Package.h create mode 100644 Project Reboot 3.0/SavePackage.cpp diff --git a/Project Reboot 3.0/FortPlayerController.cpp b/Project Reboot 3.0/FortPlayerController.cpp index e900a5f..1bf4412 100644 --- a/Project Reboot 3.0/FortPlayerController.cpp +++ b/Project Reboot 3.0/FortPlayerController.cpp @@ -1321,7 +1321,10 @@ void AFortPlayerController::ClientOnPawnDiedHook(AFortPlayerController* PlayerCo } } - if (GameState->GetGamePhase() == EAthenaGamePhase::EndGame) + LOG_INFO(LogDev, "KillerPlayerState->Place: {}", KillerPlayerState ? KillerPlayerState->GetPlace() : -1); + + // if (GameState->GetGamePhase() == EAthenaGamePhase::EndGame) + if (false) { CreateThread(0, 0, RestartThread, 0, 0, 0); } diff --git a/Project Reboot 3.0/FortPlayerControllerAthena.h b/Project Reboot 3.0/FortPlayerControllerAthena.h index f719d3a..237d0bf 100644 --- a/Project Reboot 3.0/FortPlayerControllerAthena.h +++ b/Project Reboot 3.0/FortPlayerControllerAthena.h @@ -93,7 +93,7 @@ static bool ApplyCID(AFortPlayerPawn* Pawn, UObject* CID, bool bUseServerChooseP return true; */ - if (Engine_Version == 416) + if (Fortnite_Version == 1.72) return false; static auto HeroDefinitionOffset = CID->GetOffset("HeroDefinition"); diff --git a/Project Reboot 3.0/FortPlayerStateAthena.h b/Project Reboot 3.0/FortPlayerStateAthena.h index fb0217d..2b9964b 100644 --- a/Project Reboot 3.0/FortPlayerStateAthena.h +++ b/Project Reboot 3.0/FortPlayerStateAthena.h @@ -20,12 +20,10 @@ public: return Get(TeamIndexOffset); } - FString GetPlayerName() + int& GetPlace() { - static auto GetPlayerNameFn = FindObject("/Script/Engine.PlayerState.GetPlayerName"); - FString PlayerName; - this->ProcessEvent(GetPlayerNameFn, &PlayerName); - return PlayerName; + static auto PlaceOffset = GetOffset("Place"); + return Get(PlaceOffset); } void ClientReportKill(AFortPlayerStateAthena* Player) diff --git a/Project Reboot 3.0/NetConnection.cpp b/Project Reboot 3.0/NetConnection.cpp index a633b5d..5e75be6 100644 --- a/Project Reboot 3.0/NetConnection.cpp +++ b/Project Reboot 3.0/NetConnection.cpp @@ -1,9 +1,19 @@ #include "NetConnection.h" -bool UNetConnection::ClientHasInitializedLevelFor(const AActor* TestActor) const { - // return true; - static auto ClientHasInitializedLevelForAddr = Memcury::Scanner::FindPattern("48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 20 48 8B 5A 20 48 8B F1 4C 8B C3").Get(); +bool UNetConnection::ClientHasInitializedLevelFor(const AActor* TestActor) const +{ + static auto ClientHasInitializedLevelForAddr = Memcury::Scanner::FindPattern("48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 20 48 8B 5A 20 48 8B F1 4C 8B C3", false).Get(); + if (!ClientHasInitializedLevelForAddr) + { + ClientHasInitializedLevelForAddr = Memcury::Scanner::FindPattern("48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 20 48 8B 5A 20 48 8B F1 4C 8B C3 48 8D", false).Get(); // 1.8 + + if (!ClientHasInitializedLevelForAddr) + { + ClientHasInitializedLevelForAddr = Memcury::Scanner::FindPattern("48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC 20 48 8B F9 48 85 D2 74 35 48").Get(); // 1.7.2 + } + } + if (!ClientHasInitializedLevelForAddr) return true; diff --git a/Project Reboot 3.0/NetDriver.cpp b/Project Reboot 3.0/NetDriver.cpp index 92e7336..2096652 100644 --- a/Project Reboot 3.0/NetDriver.cpp +++ b/Project Reboot 3.0/NetDriver.cpp @@ -7,6 +7,7 @@ #include "GameplayStatics.h" #include "KismetMathLibrary.h" #include +#include "Package.h"S #include "AssertionMacros.h" FNetworkObjectList& UNetDriver::GetNetworkObjectList() @@ -348,15 +349,18 @@ bool UNetDriver::IsLevelInitializedForActor(const AActor* InActor, const UNetCon return true; } -/* #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) +/* #if !(UE_BUILD_SHIPPING || UE_BUILD_TEST) // (Milxnor) This is on some ue versions and others not. if (!InActor || !InConnection) return false; // check(World == InActor->GetWorld()); #endif */ - // return true; // damn - const bool bCorrectWorld = (InConnection->GetClientWorldPackageName() == GetWorldPackage()->NamePrivate && InConnection->ClientHasInitializedLevelFor(InActor)); + bool bFirstWorldCheck = Engine_Version == 416 + ? (InConnection->GetClientWorldPackageName() == GetWorld()->GetOutermost()->GetFName()) + : (InConnection->GetClientWorldPackageName() == GetWorldPackage()->NamePrivate); + + const bool bCorrectWorld = (bFirstWorldCheck && InConnection->ClientHasInitializedLevelFor(InActor)); const bool bIsConnectionPC = (InActor == InConnection->GetPlayerController()); return bCorrectWorld || bIsConnectionPC; } diff --git a/Project Reboot 3.0/Object.cpp b/Project Reboot 3.0/Object.cpp index 1c7fbec..a4642fb 100644 --- a/Project Reboot 3.0/Object.cpp +++ b/Project Reboot 3.0/Object.cpp @@ -5,6 +5,7 @@ #include "Class.h" #include "KismetSystemLibrary.h" #include "UObjectArray.h" +#include "Package.h" FName* getFNameOfProp(void* Property) { @@ -140,6 +141,20 @@ std::string UObject::GetFullName() return ClassPrivate ? ClassPrivate->GetName() + " " + UKismetSystemLibrary::GetPathName(this).ToString() : "NoClassPrivate"; } +UPackage* UObject::GetOutermost() const +{ + UObject* Top = (UObject*)this; + for (;;) + { + UObject* CurrentOuter = Top->GetOuter(); + if (!CurrentOuter) + { + return Cast(Top); + } + Top = CurrentOuter; + } +} + bool UObject::IsA(UClass* otherClass) { UClass* super = ClassPrivate; diff --git a/Project Reboot 3.0/Object.h b/Project Reboot 3.0/Object.h index fd45bc5..1f09759 100644 --- a/Project Reboot 3.0/Object.h +++ b/Project Reboot 3.0/Object.h @@ -53,7 +53,10 @@ public: std::string GetName() { return NamePrivate.ToString(); } std::string GetPathName(); std::string GetFullName(); + UObject* GetOuter() const { return OuterPrivate; } + FName GetFName() const { return NamePrivate; } + class UPackage* GetOutermost() const; bool IsA(UClass* Other); class UFunction* FindFunction(const std::string& ShortFunctionName); diff --git a/Project Reboot 3.0/Package.h b/Project Reboot 3.0/Package.h new file mode 100644 index 0000000..ea150bb --- /dev/null +++ b/Project Reboot 3.0/Package.h @@ -0,0 +1,9 @@ +#pragma once + +#include "Object.h" + +class UPackage : public UObject +{ +public: + static UClass* StaticClass(); +}; \ No newline at end of file diff --git a/Project Reboot 3.0/PlayerState.cpp b/Project Reboot 3.0/PlayerState.cpp index caad178..ab66644 100644 --- a/Project Reboot 3.0/PlayerState.cpp +++ b/Project Reboot 3.0/PlayerState.cpp @@ -2,6 +2,21 @@ #include "reboot.h" +FString APlayerState::GetPlayerName() +{ + static auto GetPlayerNameFn = FindObject("/Script/Engine.PlayerState.GetPlayerName"); + + if (GetPlayerNameFn) + { + FString PlayerName; + this->ProcessEvent(GetPlayerNameFn, &PlayerName); + return PlayerName; + } + + static auto PlayerNameOffset = GetOffset("PlayerName"); + return Get(PlayerNameOffset); +} + int& APlayerState::GetPlayerID() { static auto PlayerIDOffset = FindOffsetStruct("/Script/Engine.PlayerState", "PlayerID", false); diff --git a/Project Reboot 3.0/PlayerState.h b/Project Reboot 3.0/PlayerState.h index 349d5b6..1b1f3d7 100644 --- a/Project Reboot 3.0/PlayerState.h +++ b/Project Reboot 3.0/PlayerState.h @@ -2,8 +2,11 @@ #include "Actor.h" +#include "UnrealString.h" + class APlayerState : public AActor { public: + FString GetPlayerName(); int& GetPlayerID(); // for future me to deal with (this is a short on some versions). }; \ No newline at end of file diff --git a/Project Reboot 3.0/Project Reboot 3.0.vcxproj b/Project Reboot 3.0/Project Reboot 3.0.vcxproj index 34e1860..2e6fbac 100644 --- a/Project Reboot 3.0/Project Reboot 3.0.vcxproj +++ b/Project Reboot 3.0/Project Reboot 3.0.vcxproj @@ -245,6 +245,7 @@ + @@ -398,6 +399,7 @@ + diff --git a/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters b/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters index afdb856..d7ad13d 100644 --- a/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters +++ b/Project Reboot 3.0/Project Reboot 3.0.vcxproj.filters @@ -256,6 +256,9 @@ Reboot\Public + + Engine\Source\Runtime\CoreUObject\Private + @@ -324,9 +327,6 @@ Engine\Source\Runtime\Core\Public\Math - - Engine\Source\Runtime\Core\Public\Math - Engine\Source\Runtime\Core\Public\Math @@ -820,6 +820,12 @@ FortniteGame\Source\FortniteGame\Public + + Engine\Source\Runtime\CoreUObject\Public\UObject + + + Engine\Source\Runtime\Core\Public\Misc + diff --git a/Project Reboot 3.0/SavePackage.cpp b/Project Reboot 3.0/SavePackage.cpp new file mode 100644 index 0000000..968f5ff --- /dev/null +++ b/Project Reboot 3.0/SavePackage.cpp @@ -0,0 +1,9 @@ +#include "Package.h" + +#include "reboot.h" + +UClass* UPackage::StaticClass() +{ + static auto Class = FindObject("/Script/CoreUObject.Package"); + return Class; +} \ No newline at end of file diff --git a/Project Reboot 3.0/builder.h b/Project Reboot 3.0/builder.h index d6cdd2d..1b7e212 100644 --- a/Project Reboot 3.0/builder.h +++ b/Project Reboot 3.0/builder.h @@ -34,7 +34,6 @@ namespace Builder if (!Class) { - std::cout << "Invalid Class!\n"; continue; } diff --git a/Project Reboot 3.0/commands.h b/Project Reboot 3.0/commands.h index 2439fc2..e4ff69c 100644 --- a/Project Reboot 3.0/commands.h +++ b/Project Reboot 3.0/commands.h @@ -208,6 +208,12 @@ void ServerCheatHook(AFortPlayerControllerAthena* PlayerController, FString Msg) return; } + if (Fortnite_Version < 3) // Idk why but emptyslot kicks the player because of the validate. + { + SendMessageToConsole(PlayerController, L"Not supported on this version!"); + return; + } + auto WorldInventory = ReceivingController->GetWorldInventory(); if (!WorldInventory) @@ -357,7 +363,7 @@ void ServerCheatHook(AFortPlayerControllerAthena* PlayerController, FString Msg) auto CurrentPlayerState = Cast(CurrentPlayerController->GetPlayerState()); - if (!CurrentPlayerState) + if (!CurrentPlayerState->IsValidLowLevel()) continue; PlayerNames += "\"" + CurrentPlayerState->GetPlayerName().ToString() + "\" "; diff --git a/Project Reboot 3.0/gui.h b/Project Reboot 3.0/gui.h index e7fa4e8..407989f 100644 --- a/Project Reboot 3.0/gui.h +++ b/Project Reboot 3.0/gui.h @@ -261,7 +261,10 @@ static int playerTabTab = MAIN_PLAYERTAB; static inline void StaticUI() { - ImGui::Checkbox("Auto Restart", &Globals::bAutoRestart); + if (IsRestartingSupported()) + { + // ImGui::Checkbox("Auto Restart", &Globals::bAutoRestart); + } #ifndef PROD ImGui::Checkbox("Log ProcessEvent", &Globals::bLogProcessEvent);