From 69536766b1d791b716b2c2af48a4c944b3438881 Mon Sep 17 00:00:00 2001 From: Ange-Marie MAURIN Date: Tue, 15 Jul 2025 05:13:31 +0200 Subject: [PATCH] Fixing GetFullName --- .../DTFluxUtilities/Private/FTDFluxUtils.cpp | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/Source/DTFluxUtilities/Private/FTDFluxUtils.cpp b/Source/DTFluxUtilities/Private/FTDFluxUtils.cpp index 321fabb..bcaf18e 100644 --- a/Source/DTFluxUtilities/Private/FTDFluxUtils.cpp +++ b/Source/DTFluxUtilities/Private/FTDFluxUtils.cpp @@ -31,28 +31,27 @@ void UFTDFluxUtils::GetFullName(const int Bib, FText& OutFullName) { OutFullName = FText(); UDTFluxCoreSubsystem* CoreSubsystem = GEngine->GetEngineSubsystem(); - FDTFluxParticipant Participant; - CoreSubsystem->GetParticipant(Bib, Participant); + if(CoreSubsystem != nullptr) { - FDTFluxParticipant OutParticipant; - if(CoreSubsystem->GetParticipant(Bib, OutParticipant)) - { - FString FormattedName = ""; - if (OutParticipant.IsTeam()) + FDTFluxParticipant Participant; + if(CoreSubsystem->GetParticipant(Bib, Participant)) { - OutFullName = FText::FromString(Participant.Team); + FString FormattedName = ""; + if (Participant.IsTeam()) + { + OutFullName = FText::FromString(Participant.Team); + return; + } + if (Participant.GetTeammate().IsEmpty()) + { + UE_LOG(logDTFluxUtilities, Warning, TEXT("Non teammate found with Bib %i"), Bib) + return; + } + OutFullName = FText::FromString(FString::Printf(TEXT("%s %s"), *Participant.GetTeammate()[0].FirstName, + *Participant.GetTeammate()[0].LastName)); return; } - if (Participant.GetTeammate().IsEmpty()) - { - UE_LOG(logDTFluxUtilities, Warning, TEXT("Non teammate found with Bib %i"), Bib) - return; - } - OutFullName = FText::FromString(FString::Printf(TEXT("%s %s"), *Participant.GetTeammate()[0].FirstName, - *Participant.GetTeammate()[0].LastName)); - return; - } - UE_LOG(logDTFluxUtilities, Warning, TEXT("Participant not found with Bib %i"), Bib); + UE_LOG(logDTFluxUtilities, Warning, TEXT("Participant not found with Bib %i"), Bib); } UE_LOG(logDTFluxUtilities, Error, TEXT("DTFluxCoreSubsystem not available")); }