Atleast we go ingame

This commit is contained in:
Gray
2024-03-21 18:27:42 -04:00
parent b3d9ab9e8b
commit 79bcabbbd0
18 changed files with 77 additions and 183 deletions

View File

@@ -14,7 +14,10 @@ bool AActor::HasAuthority()
bool AActor::GetNetDormancy(const FVector& ViewPos, const FVector& ViewDir, AActor* Viewer, AActor* ViewTarget, class UActorChannel* InChannel, float Time, bool bLowBandwidth) // T(REP)
{
return false;
static int GetNetDormancyOffset = 0x390; // 1.11
bool (*originalGetNetDormancy)(AActor*, const FVector&, const FVector&, AActor* Viewer, AActor* ViewTarget, UActorChannel * InChannel, float Time, bool bLowBandwidth) =
decltype(originalGetNetDormancy)(this->VFTable[GetNetDormancyOffset / 8]);
return originalGetNetDormancy(this, ViewPos, ViewDir, Viewer, ViewTarget, InChannel, Time, bLowBandwidth);
}
bool AActor::IsTearOff()
@@ -211,7 +214,7 @@ void AActor::ForceNetUpdate()
bool AActor::IsNetStartupActor() // T(REP)
{
return IsNetStartup(); // The implementation on this function depends on the version.
return IsNetStartup(); // The implementation on this function depends on the version, this is for 4.19.
}
bool AActor::IsPendingKillPending() // T(REP)

View File

@@ -61,7 +61,15 @@ public:
if (CurveTableMode == ECurveTableMode::SimpleCurves)
{
auto& RowMap = ((UDataTable*)this)->GetRowMap<FSimpleCurve>(); // its the same offset so
auto Curve = RowMap.Find(RowName);
auto CurvePtr = RowMap.Find(RowName);
if (!CurvePtr)
{
LOG_WARN(LogDev, "Failed to get curve!");
return nullptr;
}
auto Curve = *CurvePtr;
auto& Keys = Curve->GetKeys();
return Keys.Num() > Index ? &Curve->GetKeys().at(Index) : nullptr;
}

View File

@@ -7,9 +7,7 @@ int32 UChannel::IsNetReady(bool Saturate)
if (*(int*)(__int64(this) + NumOutRecOffset) < 255)
{
static auto ConnectionOffset = GetOffset("Connection");
auto Connection = Get<UNetConnection*>(ConnectionOffset);
return Connection->IsNetReady(Saturate);
return GetConnection()->IsNetReady(Saturate);
}
return 0;

View File

@@ -14,11 +14,11 @@ class UDataTable : public UObject
{
public:
template <typename RowDataType = uint8_t>
TMap<FName, RowDataType>& GetRowMap()
TMap<FName, RowDataType*>& GetRowMap()
{
static auto RowStructOffset = FindOffsetStruct("/Script/Engine.DataTable", "RowStruct");
return *(TMap<FName, RowDataType>*)(__int64(this) + (RowStructOffset + sizeof(UObject*))); // because after rowstruct is rowmap
return *(TMap<FName, RowDataType*>*)(__int64(this) + (RowStructOffset + sizeof(UObject*))); // because after rowstruct is rowmap
}
static UClass* StaticClass()

View File

@@ -29,27 +29,18 @@ float UFortItemDefinition::GetMaxStackSize()
FCurveTableRowHandle Curve; // 0x8(0x10)(Edit, BlueprintVisible, NoDestructor, HasGetValueTypeHash, NativeAccessSpecifierPublic)
};
static auto AthenaGameData = FindObject<UDataTable>("/Game/Athena/Balance/DataTables/AthenaGameData.AthenaGameData");
static auto AthenaGameData = FindObject<UDataTable>(L"/Game/Athena/Balance/DataTables/AthenaGameData.AthenaGameData");
auto& ScalableFloat = Get<FScalableFloat>(MaxStackSizeOffset);
auto& RowMap = AthenaGameData->GetRowMap();
auto& RowMap = AthenaGameData->GetRowMap<FSimpleCurve>();
if (ScalableFloat.Curve.RowName.ComparisonIndex.Value == 0)
return ScalableFloat.Value;
FSimpleCurve* Curve = nullptr;
FSimpleCurve** CurvePtr = RowMap.Find(ScalableFloat.Curve.RowName);
for (auto& Pair : RowMap)
{
if (Pair.Key == ScalableFloat.Curve.RowName)
{
Curve = (FSimpleCurve*)Pair.Value;
break;
}
}
if (!Curve)
if (!CurvePtr)
return 1;
return Curve->GetKeys().at(0).Value;
return (*CurvePtr)->GetKeys().at(0).Value;
}

View File

@@ -22,10 +22,10 @@ int UFortLootLevel::GetItemLevel(const FDataTableCategoryHandle& LootLevelData,
for (auto& LootLevelDataPair : LootLevelData.DataTable->GetRowMap<FFortLootLevelData>())
{
if (LootLevelDataPair.Value.Category != LootLevelData.RowContents)
if (LootLevelDataPair.Value->Category != LootLevelData.RowContents)
continue;
OurLootLevelDatas.push_back(&LootLevelDataPair.Value);
OurLootLevelDatas.push_back(LootLevelDataPair.Value);
}
if (OurLootLevelDatas.size() > 0)

View File

@@ -47,8 +47,6 @@ void CollectDataTablesRows(const std::vector<UDataTable*>& DataTables, LOOTING_M
DataTablesToIterate.push_back(DataTable);
}
return; // T(1)
for (auto CurrentDataTable : DataTablesToIterate)
{
for (auto& CurrentPair : CurrentDataTable->GetRowMap())

View File

@@ -13,32 +13,15 @@ int UFortWeaponItemDefinition::GetClipSize()
if (!Table)
return 0;
auto& RowMap = Table->GetRowMap();
auto& RowMap = Table->GetRowMap<void>();
void* Row = nullptr;
void** RowPtr = RowMap.Find(WeaponStatHandle.RowName);
/*
T(1)
for (int i = 0; i < RowMap.Pairs.Elements.Data.Num(); ++i)
{
auto& Pair = RowMap.Pairs.Elements.Data.at(i).ElementData.Value;
if (Pair.Key() == WeaponStatHandle.RowName)
{
Row = Pair.Value();
break;
}
}
*/
if (!Row)
if (!RowPtr)
return 0;
static auto ClipSizeOffset = FindOffsetStruct("/Script/FortniteGame.FortBaseWeaponStats", "ClipSize");
return *(int*)(__int64(Row) + ClipSizeOffset);
return *(int*)(__int64(*RowPtr) + ClipSizeOffset);
}
UFortWorldItemDefinition* UFortWeaponItemDefinition::GetAmmoData()

View File

@@ -15,7 +15,10 @@ bool UNetConnection::ClientHasInitializedLevelFor(const AActor* TestActor) const
}
if (!ClientHasInitializedLevelForAddr)
{
LOG_WARN(LogDev, "Forcing ret true on ClientHasInitializedLevelFor!");
return true;
}
static bool (*ClientHasInitializedLevelForOriginal)(const UNetConnection * Connection, const AActor * TestActor)
= decltype(ClientHasInitializedLevelForOriginal)(ClientHasInitializedLevelForAddr);

View File

@@ -154,24 +154,23 @@ FNetViewer::FNetViewer(UNetConnection* InConnection, float DeltaSeconds) :
ViewLocation(ForceInit),
ViewDir(ForceInit)
{
// check(InConnection->OwningActor);
// check(!InConnection->PlayerController || (InConnection->PlayerController == InConnection->OwningActor));
if (!InConnection->GetOwningActor()) return;
if (InConnection->GetPlayerController() || (InConnection->GetPlayerController() != InConnection->GetOwningActor())) return;
APlayerController* ViewingController = InConnection->GetPlayerController();
// Get viewer coordinates.
ViewLocation = ViewTarget->GetActorLocation();
if (ViewingController)
{
FRotator ViewRotation = ViewingController->GetControlRotation();
// ViewingController->GetPlayerViewPoint(ViewLocation, ViewRotation);
ViewingController->GetActorEyesViewPoint(&ViewLocation, &ViewRotation); // T(REP)
ViewDir = ViewRotation.Vector();
}
}
static FORCEINLINE bool IsActorRelevantToConnection(const AActor* Actor, const std::vector<FNetViewer>& ConnectionViewers)
{
for (int32 viewerIdx = 0; viewerIdx < ConnectionViewers.size(); viewerIdx++)
for (int32 viewerIdx = 0; viewerIdx < ConnectionViewers.size(); ++viewerIdx)
{
if (reinterpret_cast<bool(*)(const AActor*, AActor*, AActor*, const FVector&)>(Actor->VFTable[Offsets::IsNetRelevantFor])(
Actor, ConnectionViewers[viewerIdx].InViewer, ConnectionViewers[viewerIdx].ViewTarget, ConnectionViewers[viewerIdx].ViewLocation))
@@ -271,14 +270,16 @@ int32 UNetDriver::ServerReplicateActors_PrepConnections()
for (int32 ConnIdx = 0; ConnIdx < GetClientConnections().Num(); ConnIdx++)
{
UNetConnection* Connection = GetClientConnections().at(ConnIdx);
// check(Connection);
if (!Connection) continue;
// check(Connection->State == USOCK_Pending || Connection->State == USOCK_Open || Connection->State == USOCK_Closed);
// checkSlow(Connection->GetUChildConnection() == NULL);
AActor* OwningActor = Connection->GetOwningActor();
if (OwningActor != NULL
// && Connection->State == USOCK_Open
// && (Connection->GetDriver()->Time - Connection->LastReceiveTime < 1.5f)
&& (Connection->GetDriver()->GetTime() - Connection->GetLastReceiveTime() < 1.5f)
)
{
// check(World == OwningActor->GetWorld());
@@ -294,18 +295,13 @@ int32 UNetDriver::ServerReplicateActors_PrepConnections()
// ViewTarget->GetWorld() // T(REP)
)
{
// It is safe to use the player controller's view target.
DesiredViewTarget = ViewTarget;
}
else
{
}
}
}
Connection->GetViewTarget() = DesiredViewTarget;
for (int32 ChildIdx = 0; ChildIdx < Connection->GetChildren().Num(); ChildIdx++)
for (int32 ChildIdx = 0; ChildIdx < Connection->GetChildren().Num(); ++ChildIdx)
{
UNetConnection* Child = Connection->GetChildren().at(ChildIdx);
APlayerController* ChildPlayerController = Child->GetPlayerController();
@@ -322,7 +318,7 @@ int32 UNetDriver::ServerReplicateActors_PrepConnections()
else
{
Connection->GetViewTarget() = NULL;
for (int32 ChildIdx = 0; ChildIdx < Connection->GetChildren().Num(); ChildIdx++)
for (int32 ChildIdx = 0; ChildIdx < Connection->GetChildren().Num(); ++ChildIdx)
{
Connection->GetChildren().at(ChildIdx)->GetViewTarget() = NULL;
}
@@ -441,19 +437,16 @@ int32 UNetDriver::ServerReplicateActors_PrioritizeActors(UNetConnection* Connect
GetNetTag()++;
Connection->GetTickCount()++;
// Set up to skip all sent temporary actors
for (int32 j = 0; j < Connection->GetSentTemporaries().Num(); j++)
for (int32 j = 0; j < Connection->GetSentTemporaries().Num(); ++j)
{
Connection->GetSentTemporaries().at(j)->GetNetTag() = GetNetTag();
}
// Make list of all actors to consider.
// check(World() == Connection->GetOwningActor()->GetWorld());
int32 FinalSortedCount = 0;
int32 DeletedCount = 0;
// Make weak ptr once for IsActorDormant call
TWeakObjectPtr<UNetConnection> WeakConnection; // T(REP)
WeakConnection.ObjectIndex = Connection->InternalIndex;
WeakConnection.ObjectSerialNumber = GetItemByIndex(Connection->InternalIndex)->SerialNumber;
@@ -527,7 +520,7 @@ int32 UNetDriver::ServerReplicateActors_PrioritizeActors(UNetConnection* Connect
Actor->GetNetTag() = GetNetTag();
OutPriorityList[FinalSortedCount] = FActorPriority(PriorityConnection, Channel, ActorInfo, ConnectionViewers, bLowNetBandwidth);
// OutPriorityActors[FinalSortedCount] = OutPriorityList + FinalSortedCount;
OutPriorityActors[FinalSortedCount] = OutPriorityList.data() + FinalSortedCount;
FinalSortedCount++;
}
@@ -771,7 +764,7 @@ int32 UNetDriver::ServerReplicateActors()
}
}
// Connection->GetTimeSensitive() = false;
// Connection->GetTimeSensitive() = false; // T(REP)
}
else if (Connection->GetViewTarget())
{
@@ -808,8 +801,6 @@ int32 UNetDriver::ServerReplicateActors()
std::vector<FActorPriority*> PriorityActors;
const int32 FinalSortedCount = ServerReplicateActors_PrioritizeActors(Connection, ConnectionViewers, ConsiderList, bCPUSaturated, PriorityList, PriorityActors);
// Process the sorted list of actors for this connection
const int32 LastProcessedActor = ServerReplicateActors_ProcessPrioritizedActors(Connection, ConnectionViewers, PriorityActors, FinalSortedCount, Updated);
for (int32 k = LastProcessedActor; k < FinalSortedCount; ++k)

View File

@@ -59,6 +59,8 @@ struct FNetworkObjectInfo
class FNetworkObjectList
{
public:
static inline void (*originalRemove)(FNetworkObjectList*, AActor* const);
typedef TSet<TSharedPtr<FNetworkObjectInfo>> FNetworkObjectSet;
FNetworkObjectSet AllNetworkObjects;
@@ -67,7 +69,11 @@ public:
TMap<TWeakObjectPtr<UNetConnection>, int32> NumDormantObjectsPerConnection;
void Remove(AActor* const Actor);
void Remove(AActor* const Actor)
{
originalRemove(this, Actor);
}
const FNetworkObjectSet& GetActiveObjects() const { return ActiveNetworkObjects; }
};
@@ -191,7 +197,7 @@ public:
int32& GetNetTag()
{
static auto NetTagOffset = 0x1DC + 4;
static auto NetTagOffset = 0x1DC + 4; // idk if this is right 1.11
return Get<int32>(NetTagOffset);
}

View File

@@ -1,110 +1 @@
#include "NetDriver.h"
void FNetworkObjectList::Remove(AActor* const Actor) // T(REP)
{
#if 0
if (Actor == nullptr)
{
return;
}
TSharedPtr<FNetworkObjectInfo>* NetworkObjectInfoPtr = nullptr;
for (int i = 0; i < AllNetworkObjects.Num(); i++)
{
auto& CurrentNetworkObject = AllNetworkObjects[i];
if (CurrentNetworkObject->Actor == Actor)
{
NetworkObjectInfoPtr = &CurrentNetworkObject;
break;
}
}
if (NetworkObjectInfoPtr == nullptr)
{
// Sanity check that we're not on the other lists either
// check(!ActiveNetworkObjects.Contains(Actor));
// check(!ObjectsDormantOnAllConnections.Contains(Actor));
// check((ActiveNetworkObjects.Num() + ObjectsDormantOnAllConnections.Num()) == AllNetworkObjects.Num());
return;
}
FNetworkObjectInfo* NetworkObjectInfo = NetworkObjectInfoPtr->Get();
for (int i = 0; i < NetworkObjectInfo->DormantConnections.Num(); i++)
{
auto& ConnectionIt = NetworkObjectInfo->DormantConnections[i];
UNetConnection* Connection = ConnectionIt.Get();
if (Connection == nullptr) // || Connection->State == USOCK_Closed)
{
NetworkObjectInfo->DormantConnections.Remove(i);
// ConnectionIt.RemoveCurrent();
continue;
}
int32* NumDormantObjectsPerConnectionRef = nullptr;
for (int z = 0; z < NumDormantObjectsPerConnection.Pairs.Num(); z++)
{
auto& Pair = NumDormantObjectsPerConnection.Pairs[z];
if (Pair.First.ObjectIndex == Connection->InternalIndex)
{
NumDormantObjectsPerConnectionRef = &Pair.Second;
break;
}
}
if (!NumDormantObjectsPerConnectionRef)
{
// We should add here TODO MILXNOR
}
// check(NumDormantObjectsPerConnectionRef > 0);
if (NumDormantObjectsPerConnectionRef)
(*NumDormantObjectsPerConnectionRef)--;
}
// Remove this object from all lists
for (int i = 0; i < AllNetworkObjects.Num(); i++)
{
auto& CurrentNetworkObject = AllNetworkObjects[i];
if (CurrentNetworkObject->Actor == Actor)
{
AllNetworkObjects.Remove(i);
break;
}
}
for (int i = 0; i < ActiveNetworkObjects.Num(); i++)
{
auto& CurrentActiveNetworkObject = ActiveNetworkObjects[i];
if (CurrentActiveNetworkObject->Actor == Actor)
{
ActiveNetworkObjects.Remove(i);
break;
}
}
for (int i = 0; i < ObjectsDormantOnAllConnections.Num(); i++)
{
auto& CurrentDormantObject = ObjectsDormantOnAllConnections[i];
if (CurrentDormantObject->Actor == Actor)
{
ObjectsDormantOnAllConnections.Remove(i);
break;
}
}
#endif
// check((ActiveNetworkObjects.Num() + ObjectsDormantOnAllConnections.Num()) == AllNetworkObjects.Num());
}

View File

@@ -16,9 +16,20 @@ struct FMath : public FGenericPlatformMath
return A * A;
}
static float SRand() // T(REP)
static FORCEINLINE float Fractional(float Value)
{
return rand();
return Value - TruncToFloat(Value);
}
static float SRand()
{
GSRandSeed = (GSRandSeed * 196314165) + 907633515;
union { float f; int32 i; } Result;
union { float f; int32 i; } Temp;
const float SRandTemp = 1.0f;
Temp.f = SRandTemp;
Result.i = (Temp.i & 0xff800000) | (GSRandSeed & 0x007fffff);
return Fractional(Result.f);
}
static FORCEINLINE uint32 FloorLog2(uint32 Value)

View File

@@ -322,6 +322,9 @@ void Addresses::FindAll()
LOG_INFO(LogDev, "Finding GIsClient");
Addresses::GIsClient = FindGIsClient();
LOG_INFO(LogDev, "Finding ObjectListRemove");
Addresses::ObjectListRemove = FindObjectListRemove();
// LOG_INFO(LogDev, "Finding GetSessionInterface");
// Addresses::GetSessionInterface = FindGetSessionInterface();
@@ -406,6 +409,7 @@ void Addresses::Print()
LOG_INFO(LogDev, "AddToAlivePlayers: 0x{:x}", AddToAlivePlayers - Base);
LOG_INFO(LogDev, "GetSessionInterface: 0x{:x}", GetSessionInterface - Base);
LOG_INFO(LogDev, "StartAircraftPhase: 0x{:x}", StartAircraftPhase - Base);
LOG_INFO(LogDev, "ObjectListRemove: 0x{:x}", ObjectListRemove - Base);
}
void Offsets::FindAll()
@@ -559,6 +563,7 @@ void Addresses::Init()
UActorChannel::originalSetChannelActor = decltype(UActorChannel::originalSetChannelActor)(Addresses::SetChannelActor);
UNetConnection::originalCreateChannel = decltype(UNetConnection::originalCreateChannel)(Addresses::CreateChannel);
UNetConnection::originalCreateChannelByName = decltype(UNetConnection::originalCreateChannelByName)(Addresses::CreateChannel);
FNetworkObjectList::originalRemove = decltype(FNetworkObjectList::originalRemove)(ObjectListRemove);
if (Engine_Version >= 421) ChunkedObjects = decltype(ChunkedObjects)(ObjectArray);
else UnchunkedObjects = decltype(UnchunkedObjects)(ObjectArray);

View File

@@ -77,6 +77,7 @@ namespace Addresses
extern inline uint64 GameSessionPatch = 0;
extern inline uint64 GetSessionInterface = 0; // Matchmaking
extern inline uint64 StartAircraftPhase = 0;
extern inline uint64 ObjectListRemove = 0;
void SetupVersion(); // Finds Engine Version
void FindAll();

View File

@@ -619,6 +619,11 @@ static inline uint64 FindOnDamageServer()
return Addr;
}
static inline uint64 FindObjectListRemove()
{
return Memcury::Scanner::FindPattern("48 85 D2 0F 84 ? ? ? ? 55 56 41 56 48 8D 6C 24 ? 48 81 EC ? ? ? ? 4C 8B F2 4C 8B C2 48 8D 55").Get(); // 1.11
}
static inline uint64 FindStaticLoadObject()
{
auto Addrr = Memcury::Scanner::FindStringRef(L"STAT_LoadObject", false).Get();

View File

@@ -29,6 +29,7 @@ typedef unsigned __int64 uint64;
extern inline int Engine_Version = 0; // For example, 420, 421, etc. // Prevent using this when possible.
extern inline double Fortnite_Version = 0; // For example, 4.1, 6.21, etc. // Prevent using this when possible.
extern inline int Fortnite_CL = 0;
extern inline int32 GSRandSeed = 0;
// #define PROD // this doesnt do anything besides remove processeventhook and some assert stuff
// DEPRACTERD ^^^ (see Globals::bDeveloperMode)

View File

@@ -144,7 +144,6 @@ static __forceinline T* Cast(UObject* Object)
extern inline int AmountOfRestarts = 0; // DO NOT CHANGE
extern inline FRandomStream ReplicationRandStream = (0);
extern inline int32 GSRandSeed = 0;
extern inline std::set<std::string> ReplicatedActors = {};
inline uint8_t GetFieldMask(void* Property, int additional = 0)