i gotta go to school bro

prevent some cheats, fix a crash on newer versions for looting, fix a bug on S16+ where with mcp you would get no reserve.
This commit is contained in:
Milxnor
2023-05-10 07:59:48 -04:00
parent 3fb5c4671d
commit f41be934eb
5 changed files with 120 additions and 27 deletions

View File

@@ -1476,11 +1476,67 @@ void AFortPlayerController::ClientOnPawnDiedHook(AFortPlayerController* PlayerCo
return ClientOnPawnDiedOriginal(PlayerController, DeathReport);
}
bool IsBuildingOkForEditing(ABuildingSMActor* BuildingActorToEdit)
{
// we should check if these are valid ptrs but idk if it exists on every version and im too lazy to check
static auto EditModeSupportOffset = BuildingActorToEdit->GetOffset("EditModeSupport");
static auto EditModePatternDataOffset = BuildingActorToEdit->GetOffset("EditModePatternData");
bool idkSomeAttachmentCheck = false;
if (false)
{
// again idk if this is the same for every build
static auto AttachmentPlacementBlockingActorsOffset = BuildingActorToEdit->GetOffset("AttachmentPlacementBlockingActors");
auto& AttachmentPlacementBlockingActors = BuildingActorToEdit->Get<TArray<ABuildingSMActor*>>(AttachmentPlacementBlockingActorsOffset);
// bro what
/* auto AttachmentPlacementBlockingActorsIt = *AttachmentPlacementBlockingActors.Data; // hm?
auto v3 = &AttachmentPlacementBlockingActorsIt[AttachmentPlacementBlockingActors.Num()];
if (AttachmentPlacementBlockingActors.Data == v3)
{
idkSomeAttachmentCheck = false;
}
else
{
bool bdid = false;
while (!*AttachmentPlacementBlockingActors)
{
if (++AttachmentPlacementBlockingActors == v3)
{
idkSomeAttachmentCheck = false;
bdid = true;
break;
}
}
if (!bdid)
idkSomeAttachmentCheck = true;
} */
}
// some other stuff to but too much
return BuildingActorToEdit->IsPlayerBuildable() && !idkSomeAttachmentCheck;
}
void AFortPlayerController::ServerBeginEditingBuildingActorHook(AFortPlayerController* PlayerController, ABuildingSMActor* BuildingActorToEdit)
{
if (!BuildingActorToEdit || !BuildingActorToEdit->IsPlayerPlaced()) // We need more checks.
return;
if (BuildingActorToEdit->GetEditingPlayer() && BuildingActorToEdit->GetEditingPlayer() != PlayerController->GetPlayerState())
return;
if (BuildingActorToEdit->IsDestroyed() /* || !BuildingActorToEdit->GetWorld() */)
return;
if (!IsBuildingOkForEditing(BuildingActorToEdit))
return;
auto Pawn = PlayerController->GetMyFortPawn();
if (!Pawn)
@@ -1536,10 +1592,10 @@ void AFortPlayerController::ServerEditBuildingActorHook(UObject* Context, FFrame
// LOG_INFO(LogDev, "RotationIterations: {}", RotationIterations);
if (!BuildingActorToEdit || !NewBuildingClass || BuildingActorToEdit->IsDestroyed() || BuildingActorToEdit->GetEditingPlayer() != PlayerState)
if (!BuildingActorToEdit /* || !BuildingActorToEdit->GetWorld() */ || BuildingActorToEdit->GetEditingPlayer() != PlayerState || BuildingActorToEdit->IsDestroyed())
{
LOG_INFO(LogDev, "Cheater?");
LOG_INFO(LogDev, "BuildingActorToEdit->GetEditingPlayer(): {} PlayerState: {} NewBuildingClass: {} BuildingActorToEdit: {}", BuildingActorToEdit ? __int64(BuildingActorToEdit->GetEditingPlayer()) : -1, __int64(PlayerState), __int64(NewBuildingClass), __int64(BuildingActorToEdit));
// LOG_INFO(LogDev, "Cheater?");
// LOG_INFO(LogDev, "BuildingActorToEdit->GetEditingPlayer(): {} PlayerState: {} NewBuildingClass: {} BuildingActorToEdit: {}", BuildingActorToEdit ? __int64(BuildingActorToEdit->GetEditingPlayer()) : -1, __int64(PlayerState), __int64(NewBuildingClass), __int64(BuildingActorToEdit));
return ServerEditBuildingActorOriginal(Context, Stack, Ret);
}
@@ -1557,7 +1613,7 @@ void AFortPlayerController::ServerEditBuildingActorHook(UObject* Context, FFrame
BuildingActor->SetPlayerPlaced(true);
}
// we should do more things here
// we should do more things here but it might just be challenge related things
return ServerEditBuildingActorOriginal(Context, Stack, Ret);
}
@@ -1589,9 +1645,6 @@ void AFortPlayerController::ServerEndEditingBuildingActorHook(AFortPlayerControl
auto EditTool = Cast<AFortWeap_EditingTool>(Pawn->GetCurrentWeapon());
BuildingActorToStopEditing->GetEditingPlayer() = nullptr;
// BuildingActorToStopEditing->OnRep_EditingPlayer();
if (EditTool)
{
EditTool->GetEditActor() = nullptr;