Fix edit bug fr

This commit is contained in:
Gray
2025-06-10 10:23:19 -04:00
parent 3aab2efb9f
commit bfd8288eee
2 changed files with 50 additions and 35 deletions

View File

@@ -1681,7 +1681,7 @@ void AFortPlayerController::ClientOnPawnDiedHook(AFortPlayerController* PlayerCo
void AFortPlayerController::ServerBeginEditingBuildingActorHook(AFortPlayerController* PlayerController, ABuildingSMActor* BuildingActorToEdit) void AFortPlayerController::ServerBeginEditingBuildingActorHook(AFortPlayerController* PlayerController, ABuildingSMActor* BuildingActorToEdit)
{ {
// LOG_INFO(LogDev, "ServerBeginEditingBuildingActorHook!"); DEBUG_LOG_INFO(LogDev, "\n[Begin START]!");
if (!BuildingActorToEdit || !BuildingActorToEdit->IsPlayerPlaced()) // We need more checks. if (!BuildingActorToEdit || !BuildingActorToEdit->IsPlayerPlaced()) // We need more checks.
return; return;
@@ -1711,7 +1711,7 @@ void AFortPlayerController::ServerBeginEditingBuildingActorHook(AFortPlayerContr
Pawn->EquipWeaponDefinition(EditToolDef, EditToolInstance->GetItemEntry()->GetItemGuid()); Pawn->EquipWeaponDefinition(EditToolDef, EditToolInstance->GetItemEntry()->GetItemGuid());
auto EditTool = Cast<AFortWeap_EditingTool>(Pawn->GetCurrentWeapon()); auto EditTool = Cast<AFortWeap_EditingTool>(Pawn->GetCurrentWeapon());
// LOG_INFO(LogDev, "[Begin {}] EditTool: {}!", BuildingActorToEdit->GetFullName(), __int64(EditTool)); DEBUG_LOG_INFO(LogDev, "[Begin {}] EditTool: {}!", BuildingActorToEdit->GetFullName(), __int64(EditTool));
if (!EditTool) if (!EditTool)
return; return;
@@ -1721,12 +1721,12 @@ void AFortPlayerController::ServerBeginEditingBuildingActorHook(AFortPlayerContr
BuildingActorToEdit->SetEditingPlayer(PlayerState); BuildingActorToEdit->SetEditingPlayer(PlayerState);
// LOG_INFO(LogDev, "[Begin] Updating Editing player to: {}!", __int64(PlayerState)); DEBUG_LOG_INFO(LogDev, "[Begin] Updating Editing player to: {}!", __int64(PlayerState));
} }
void AFortPlayerController::ServerEditBuildingActorHook(UObject* Context, FFrame& Stack, void* Ret) void AFortPlayerController::ServerEditBuildingActorHook(UObject* Context, FFrame& Stack, void* Ret)
{ {
// LOG_INFO(LogDev, "ServerEditBuildingActorHook!"); DEBUG_LOG_INFO(LogDev, "\n[Edit START]!");
auto PlayerController = (AFortPlayerController*)Context; auto PlayerController = (AFortPlayerController*)Context;
@@ -1756,6 +1756,7 @@ void AFortPlayerController::ServerEditBuildingActorHook(UObject* Context, FFrame
// if (!PlayerState || PlayerState->GetTeamIndex() != BuildingActorToEdit->GetTeamIndex()) // if (!PlayerState || PlayerState->GetTeamIndex() != BuildingActorToEdit->GetTeamIndex())
//return ServerEditBuildingActorOriginal(Context, Frame, Ret); //return ServerEditBuildingActorOriginal(Context, Frame, Ret);
// if (Fortnite_Version < 16)
// BuildingActorToEdit->SetEditingPlayer(nullptr); // BuildingActorToEdit->SetEditingPlayer(nullptr);
static ABuildingSMActor* (*BuildingSMActorReplaceBuildingActor)(ABuildingSMActor*, __int64, UClass*, int, int, uint8_t, AFortPlayerController*) = static ABuildingSMActor* (*BuildingSMActorReplaceBuildingActor)(ABuildingSMActor*, __int64, UClass*, int, int, uint8_t, AFortPlayerController*) =
@@ -1767,9 +1768,8 @@ void AFortPlayerController::ServerEditBuildingActorHook(UObject* Context, FFrame
BuildingActor->SetPlayerPlaced(true); BuildingActor->SetPlayerPlaced(true);
} }
// we should do more things here if (Fortnite_Version >= 12)
{
// we need to set editactor and stuff because on newer builds ServerEndEditingBuildingActor doesnt get callered
BuildingActorToEdit->SetEditingPlayer(nullptr); BuildingActorToEdit->SetEditingPlayer(nullptr);
auto Pawn = PlayerController->GetMyFortPawn(); auto Pawn = PlayerController->GetMyFortPawn();
@@ -1791,19 +1791,20 @@ void AFortPlayerController::ServerEditBuildingActorHook(UObject* Context, FFrame
Pawn->EquipWeaponDefinition(EditToolDef, EditToolInstance->GetItemEntry()->GetItemGuid()); Pawn->EquipWeaponDefinition(EditToolDef, EditToolInstance->GetItemEntry()->GetItemGuid());
auto EditTool = Cast<AFortWeap_EditingTool>(Pawn->GetCurrentWeapon()); auto EditTool = Cast<AFortWeap_EditingTool>(Pawn->GetCurrentWeapon());
// LOG_INFO(LogDev, "EditTool: {}", __int64(EditTool)); DEBUG_LOG_INFO(LogDev, "[Edit] New Equipped EditTool: {}", __int64(EditTool));
if (EditTool) if (EditTool)
{ {
EditTool->GetEditActor() = nullptr; EditTool->GetEditActor() = nullptr;
} }
}
return ServerEditBuildingActorOriginal(Context, Stack, Ret); return ServerEditBuildingActorOriginal(Context, Stack, Ret);
} }
void AFortPlayerController::ServerEndEditingBuildingActorHook(AFortPlayerController* PlayerController, ABuildingSMActor* BuildingActorToStopEditing) void AFortPlayerController::ServerEndEditingBuildingActorHook(AFortPlayerController* PlayerController, ABuildingSMActor* BuildingActorToStopEditing)
{ {
// LOG_INFO(LogDev, "[{}] ServerEndEditingBuildingActorHook EditiNgplAyer: {}!", BuildingActorToStopEditing ? BuildingActorToStopEditing->GetFullName() : "NULL", BuildingActorToStopEditing ? __int64(BuildingActorToStopEditing->GetEditingPlayer()) : -1); DEBUG_LOG_INFO(LogDev, "\n[End START] [{}] ServerEndEditingBuildingActorHook EditiNgplAyer: {}!", BuildingActorToStopEditing ? BuildingActorToStopEditing->GetName() : "NULL", BuildingActorToStopEditing ? __int64(BuildingActorToStopEditing->GetEditingPlayer()) : -1);
auto Pawn = PlayerController->GetMyFortPawn(); auto Pawn = PlayerController->GetMyFortPawn();
if (!BuildingActorToStopEditing || !Pawn if (!BuildingActorToStopEditing || !Pawn
@@ -1825,10 +1826,16 @@ void AFortPlayerController::ServerEndEditingBuildingActorHook(AFortPlayerControl
if (!EditToolInstance) if (!EditToolInstance)
return; return;
// LOG_INFO(LogDev, "EditTool BEFORE: {}", __int64(Cast<AFortWeap_EditingTool>(Pawn->GetCurrentWeapon()))); auto OldWep = Pawn->GetCurrentWeapon();
DEBUG_LOG_INFO(LogDev, "[End] EditTool Equipped BEFORE: {} (name: {})", __int64(Cast<AFortWeap_EditingTool>(OldWep)), OldWep ? OldWep->GetFullName() : "NULL");
if (Fortnite_Version >= 12)
{
Pawn->EquipWeaponDefinition(EditToolDef, EditToolInstance->GetItemEntry()->GetItemGuid()); Pawn->EquipWeaponDefinition(EditToolDef, EditToolInstance->GetItemEntry()->GetItemGuid());
}
auto EditTool = Cast<AFortWeap_EditingTool>(Pawn->GetCurrentWeapon()); auto EditTool = Cast<AFortWeap_EditingTool>(Pawn->GetCurrentWeapon());
DEBUG_LOG_INFO(LogDev, "[End] EditTool Equipped AFTER: {}", __int64(EditTool));
if (EditTool) if (EditTool)
{ {

View File

@@ -120,3 +120,11 @@ inline void InitLogger()
#define LOG_ERROR(loggerName, ...) #define LOG_ERROR(loggerName, ...)
#define LOG_FATAL(loggerName, ...) #define LOG_FATAL(loggerName, ...)
#endif #endif
#if 0
#define DEBUG_LOG_INFO(loggerName, ...) \
if (spdlog::get(#loggerName)) \
spdlog::get(#loggerName)->info(std::format(__VA_ARGS__));
#else
#define DEBUG_LOG_INFO(loggerName, ...)
#endif