Fixed MCP on 1.8, Fixed some buildings not showing up on 1.7.2 and 1.8, fixed listplayers crashing on some versions
This commit is contained in:
Milxnor
2023-04-29 20:15:24 -04:00
parent e04b3a2054
commit 891f45f469
16 changed files with 104 additions and 19 deletions

View File

@@ -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); CreateThread(0, 0, RestartThread, 0, 0, 0);
} }

View File

@@ -93,7 +93,7 @@ static bool ApplyCID(AFortPlayerPawn* Pawn, UObject* CID, bool bUseServerChooseP
return true; */ return true; */
if (Engine_Version == 416) if (Fortnite_Version == 1.72)
return false; return false;
static auto HeroDefinitionOffset = CID->GetOffset("HeroDefinition"); static auto HeroDefinitionOffset = CID->GetOffset("HeroDefinition");

View File

@@ -20,12 +20,10 @@ public:
return Get<uint8>(TeamIndexOffset); return Get<uint8>(TeamIndexOffset);
} }
FString GetPlayerName() int& GetPlace()
{ {
static auto GetPlayerNameFn = FindObject<UFunction>("/Script/Engine.PlayerState.GetPlayerName"); static auto PlaceOffset = GetOffset("Place");
FString PlayerName; return Get<int>(PlaceOffset);
this->ProcessEvent(GetPlayerNameFn, &PlayerName);
return PlayerName;
} }
void ClientReportKill(AFortPlayerStateAthena* Player) void ClientReportKill(AFortPlayerStateAthena* Player)

View File

@@ -1,8 +1,18 @@
#include "NetConnection.h" #include "NetConnection.h"
bool UNetConnection::ClientHasInitializedLevelFor(const AActor* TestActor) const { 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(); 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) if (!ClientHasInitializedLevelForAddr)
return true; return true;

View File

@@ -7,6 +7,7 @@
#include "GameplayStatics.h" #include "GameplayStatics.h"
#include "KismetMathLibrary.h" #include "KismetMathLibrary.h"
#include <random> #include <random>
#include "Package.h"S
#include "AssertionMacros.h" #include "AssertionMacros.h"
FNetworkObjectList& UNetDriver::GetNetworkObjectList() FNetworkObjectList& UNetDriver::GetNetworkObjectList()
@@ -348,15 +349,18 @@ bool UNetDriver::IsLevelInitializedForActor(const AActor* InActor, const UNetCon
return true; 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) if (!InActor || !InConnection)
return false; return false;
// check(World == InActor->GetWorld()); // check(World == InActor->GetWorld());
#endif */ #endif */
// return true; // damn bool bFirstWorldCheck = Engine_Version == 416
const bool bCorrectWorld = (InConnection->GetClientWorldPackageName() == GetWorldPackage()->NamePrivate && InConnection->ClientHasInitializedLevelFor(InActor)); ? (InConnection->GetClientWorldPackageName() == GetWorld()->GetOutermost()->GetFName())
: (InConnection->GetClientWorldPackageName() == GetWorldPackage()->NamePrivate);
const bool bCorrectWorld = (bFirstWorldCheck && InConnection->ClientHasInitializedLevelFor(InActor));
const bool bIsConnectionPC = (InActor == InConnection->GetPlayerController()); const bool bIsConnectionPC = (InActor == InConnection->GetPlayerController());
return bCorrectWorld || bIsConnectionPC; return bCorrectWorld || bIsConnectionPC;
} }

View File

@@ -5,6 +5,7 @@
#include "Class.h" #include "Class.h"
#include "KismetSystemLibrary.h" #include "KismetSystemLibrary.h"
#include "UObjectArray.h" #include "UObjectArray.h"
#include "Package.h"
FName* getFNameOfProp(void* Property) FName* getFNameOfProp(void* Property)
{ {
@@ -140,6 +141,20 @@ std::string UObject::GetFullName()
return ClassPrivate ? ClassPrivate->GetName() + " " + UKismetSystemLibrary::GetPathName(this).ToString() : "NoClassPrivate"; 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<UPackage>(Top);
}
Top = CurrentOuter;
}
}
bool UObject::IsA(UClass* otherClass) bool UObject::IsA(UClass* otherClass)
{ {
UClass* super = ClassPrivate; UClass* super = ClassPrivate;

View File

@@ -53,7 +53,10 @@ public:
std::string GetName() { return NamePrivate.ToString(); } std::string GetName() { return NamePrivate.ToString(); }
std::string GetPathName(); std::string GetPathName();
std::string GetFullName(); std::string GetFullName();
UObject* GetOuter() const { return OuterPrivate; }
FName GetFName() const { return NamePrivate; }
class UPackage* GetOutermost() const;
bool IsA(UClass* Other); bool IsA(UClass* Other);
class UFunction* FindFunction(const std::string& ShortFunctionName); class UFunction* FindFunction(const std::string& ShortFunctionName);

View File

@@ -0,0 +1,9 @@
#pragma once
#include "Object.h"
class UPackage : public UObject
{
public:
static UClass* StaticClass();
};

View File

@@ -2,6 +2,21 @@
#include "reboot.h" #include "reboot.h"
FString APlayerState::GetPlayerName()
{
static auto GetPlayerNameFn = FindObject<UFunction>("/Script/Engine.PlayerState.GetPlayerName");
if (GetPlayerNameFn)
{
FString PlayerName;
this->ProcessEvent(GetPlayerNameFn, &PlayerName);
return PlayerName;
}
static auto PlayerNameOffset = GetOffset("PlayerName");
return Get<FString>(PlayerNameOffset);
}
int& APlayerState::GetPlayerID() int& APlayerState::GetPlayerID()
{ {
static auto PlayerIDOffset = FindOffsetStruct("/Script/Engine.PlayerState", "PlayerID", false); static auto PlayerIDOffset = FindOffsetStruct("/Script/Engine.PlayerState", "PlayerID", false);

View File

@@ -2,8 +2,11 @@
#include "Actor.h" #include "Actor.h"
#include "UnrealString.h"
class APlayerState : public AActor class APlayerState : public AActor
{ {
public: public:
FString GetPlayerName();
int& GetPlayerID(); // for future me to deal with (this is a short on some versions). int& GetPlayerID(); // for future me to deal with (this is a short on some versions).
}; };

View File

@@ -245,6 +245,7 @@
<ClCompile Include="Object.cpp" /> <ClCompile Include="Object.cpp" />
<ClCompile Include="PlayerController.cpp" /> <ClCompile Include="PlayerController.cpp" />
<ClCompile Include="PlayerState.cpp" /> <ClCompile Include="PlayerState.cpp" />
<ClCompile Include="SavePackage.cpp" />
<ClCompile Include="UnrealMath.cpp" /> <ClCompile Include="UnrealMath.cpp" />
<ClCompile Include="UnrealNames.cpp" /> <ClCompile Include="UnrealNames.cpp" />
<ClCompile Include="UObjectGlobals.cpp" /> <ClCompile Include="UObjectGlobals.cpp" />
@@ -398,6 +399,7 @@
<ClInclude Include="ObjectMacros.h" /> <ClInclude Include="ObjectMacros.h" />
<ClInclude Include="OnlineReplStructs.h" /> <ClInclude Include="OnlineReplStructs.h" />
<ClInclude Include="OutputDevice.h" /> <ClInclude Include="OutputDevice.h" />
<ClInclude Include="Package.h" />
<ClInclude Include="Pawn.h" /> <ClInclude Include="Pawn.h" />
<ClInclude Include="PersistentObjectPtr.h" /> <ClInclude Include="PersistentObjectPtr.h" />
<ClInclude Include="Player.h" /> <ClInclude Include="Player.h" />

View File

@@ -256,6 +256,9 @@
<ClCompile Include="dllmain.cpp"> <ClCompile Include="dllmain.cpp">
<Filter>Reboot\Public</Filter> <Filter>Reboot\Public</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="SavePackage.cpp">
<Filter>Engine\Source\Runtime\CoreUObject\Private</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="log.h" /> <ClInclude Include="log.h" />
@@ -324,9 +327,6 @@
<ClInclude Include="Transform.h"> <ClInclude Include="Transform.h">
<Filter>Engine\Source\Runtime\Core\Public\Math</Filter> <Filter>Engine\Source\Runtime\Core\Public\Math</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Vector.h">
<Filter>Engine\Source\Runtime\Core\Public\Math</Filter>
</ClInclude>
<ClInclude Include="Quat.h"> <ClInclude Include="Quat.h">
<Filter>Engine\Source\Runtime\Core\Public\Math</Filter> <Filter>Engine\Source\Runtime\Core\Public\Math</Filter>
</ClInclude> </ClInclude>
@@ -820,6 +820,12 @@
<ClInclude Include="FortAthenaMapInfo.h"> <ClInclude Include="FortAthenaMapInfo.h">
<Filter>FortniteGame\Source\FortniteGame\Public</Filter> <Filter>FortniteGame\Source\FortniteGame\Public</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Package.h">
<Filter>Engine\Source\Runtime\CoreUObject\Public\UObject</Filter>
</ClInclude>
<ClInclude Include="Vector.h">
<Filter>Engine\Source\Runtime\Core\Public\Misc</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Filter Include="Engine"> <Filter Include="Engine">

View File

@@ -0,0 +1,9 @@
#include "Package.h"
#include "reboot.h"
UClass* UPackage::StaticClass()
{
static auto Class = FindObject<UClass>("/Script/CoreUObject.Package");
return Class;
}

View File

@@ -34,7 +34,6 @@ namespace Builder
if (!Class) if (!Class)
{ {
std::cout << "Invalid Class!\n";
continue; continue;
} }

View File

@@ -208,6 +208,12 @@ void ServerCheatHook(AFortPlayerControllerAthena* PlayerController, FString Msg)
return; 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(); auto WorldInventory = ReceivingController->GetWorldInventory();
if (!WorldInventory) if (!WorldInventory)
@@ -357,7 +363,7 @@ void ServerCheatHook(AFortPlayerControllerAthena* PlayerController, FString Msg)
auto CurrentPlayerState = Cast<AFortPlayerStateAthena>(CurrentPlayerController->GetPlayerState()); auto CurrentPlayerState = Cast<AFortPlayerStateAthena>(CurrentPlayerController->GetPlayerState());
if (!CurrentPlayerState) if (!CurrentPlayerState->IsValidLowLevel())
continue; continue;
PlayerNames += "\"" + CurrentPlayerState->GetPlayerName().ToString() + "\" "; PlayerNames += "\"" + CurrentPlayerState->GetPlayerName().ToString() + "\" ";

View File

@@ -261,7 +261,10 @@ static int playerTabTab = MAIN_PLAYERTAB;
static inline void StaticUI() static inline void StaticUI()
{ {
ImGui::Checkbox("Auto Restart", &Globals::bAutoRestart); if (IsRestartingSupported())
{
// ImGui::Checkbox("Auto Restart", &Globals::bAutoRestart);
}
#ifndef PROD #ifndef PROD
ImGui::Checkbox("Log ProcessEvent", &Globals::bLogProcessEvent); ImGui::Checkbox("Log ProcessEvent", &Globals::bLogProcessEvent);