Added Getter Stage/Contest/Split + Bug Fix PursuitManager Extract Passed Started Pursuit.
This commit is contained in:
@ -70,13 +70,14 @@ void UDTFluxPursuitManager::GetPursuit(TArray<FDTFluxPursuitInfo>& OutPursuitFoc
|
|||||||
TArray<FDTFluxPursuitInfo>& OutPursuitNext, bool& BIsFocusTruncate,
|
TArray<FDTFluxPursuitInfo>& OutPursuitNext, bool& BIsFocusTruncate,
|
||||||
const int MaxSimultaneousPursuit)
|
const int MaxSimultaneousPursuit)
|
||||||
{
|
{
|
||||||
FDateTime CurrentTime = FDateTime::UtcNow();
|
FDateTime MetricsStartFunction = FDateTime::UtcNow();
|
||||||
|
FDateTime CurrentTime = FDateTime::Now();
|
||||||
|
|
||||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("=== GetPursuit CALLED ==="));
|
// UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("=== GetPursuit CALLED ==="));
|
||||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("MaxSimultaneousPursuit: %d"), MaxSimultaneousPursuit);
|
// UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("MaxSimultaneousPursuit: %d"), MaxSimultaneousPursuit);
|
||||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("Available groups: %d"), GroupedPursuit.Num());
|
// UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("Available groups: %d"), GroupedPursuit.Num());
|
||||||
|
|
||||||
// Validation
|
// BAd Parameter
|
||||||
if (MaxSimultaneousPursuit <= 0)
|
if (MaxSimultaneousPursuit <= 0)
|
||||||
{
|
{
|
||||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("Invalid MaxSimultaneousPursuit: %d"), MaxSimultaneousPursuit);
|
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("Invalid MaxSimultaneousPursuit: %d"), MaxSimultaneousPursuit);
|
||||||
@ -85,8 +86,6 @@ void UDTFluxPursuitManager::GetPursuit(TArray<FDTFluxPursuitInfo>& OutPursuitFoc
|
|||||||
BIsFocusTruncate = false;
|
BIsFocusTruncate = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (bIsSequenceDone || GroupedPursuit.IsEmpty())
|
if (bIsSequenceDone || GroupedPursuit.IsEmpty())
|
||||||
{
|
{
|
||||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("No groups available or sequence completed"));
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("No groups available or sequence completed"));
|
||||||
@ -95,12 +94,11 @@ void UDTFluxPursuitManager::GetPursuit(TArray<FDTFluxPursuitInfo>& OutPursuitFoc
|
|||||||
BIsFocusTruncate = false;
|
BIsFocusTruncate = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 RemovedGroupsCount = 0;
|
|
||||||
for (int32 i = GroupedPursuit.Num() - 1; i >= 0; i--) // Parcours inverse pour éviter les problèmes d'index
|
for (int32 i = GroupedPursuit.Num() - 1; i >= 0; i--) // Parcours inverse pour éviter les problèmes d'index
|
||||||
{
|
{
|
||||||
const FDTFluxPursuitGroup& Group = GroupedPursuit[i];
|
const FDTFluxPursuitGroup& Group = GroupedPursuit[i];
|
||||||
|
UE_LOG(logDTFluxCoreSubsystem, Log, TEXT("Group.StartTimeGlobal(%s) < CurrentTime(%s) "),
|
||||||
|
*Group.StartTimeGlobal.ToString(), *CurrentTime.ToString())
|
||||||
// Vérifier si le StartTime du groupe est déjà passé
|
// Vérifier si le StartTime du groupe est déjà passé
|
||||||
if (Group.StartTimeGlobal < CurrentTime)
|
if (Group.StartTimeGlobal < CurrentTime)
|
||||||
{
|
{
|
||||||
@ -111,13 +109,24 @@ void UDTFluxPursuitManager::GetPursuit(TArray<FDTFluxPursuitInfo>& OutPursuitFoc
|
|||||||
Group.PursuitGroup.Num());
|
Group.PursuitGroup.Num());
|
||||||
|
|
||||||
GroupedPursuit.RemoveAt(i);
|
GroupedPursuit.RemoveAt(i);
|
||||||
RemovedGroupsCount++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
OutPursuitFocusNext.Reset();
|
OutPursuitFocusNext.Reset();
|
||||||
OutPursuitNext.Reset();
|
OutPursuitNext.Reset();
|
||||||
|
|
||||||
|
// === VÉRIFICATION CRITIQUE : S'assurer qu'il reste des groupes après suppression ===
|
||||||
|
if (GroupedPursuit.IsEmpty())
|
||||||
|
{
|
||||||
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("All groups were expired and removed - no groups available"));
|
||||||
|
OutPursuitFocusNext.Reset();
|
||||||
|
OutPursuitNext.Reset();
|
||||||
|
BIsFocusTruncate = false;
|
||||||
|
bIsSequenceDone = true; // Marquer la séquence comme terminée
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
FDTFluxPursuitGroup FocusGroup = GroupedPursuit[0];
|
FDTFluxPursuitGroup FocusGroup = GroupedPursuit[0];
|
||||||
GroupedPursuit.RemoveAt(0);
|
GroupedPursuit.RemoveAt(0);
|
||||||
|
|
||||||
@ -136,7 +145,6 @@ void UDTFluxPursuitManager::GetPursuit(TArray<FDTFluxPursuitInfo>& OutPursuitFoc
|
|||||||
|
|
||||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("Target Next Count: %d"), TargetNextCount);
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("Target Next Count: %d"), TargetNextCount);
|
||||||
|
|
||||||
// ✅ PARCOURIR les groupes restants SANS les modifier
|
|
||||||
for (int32 GroupIndex = 0;
|
for (int32 GroupIndex = 0;
|
||||||
GroupIndex < GroupedPursuit.Num() && AddedNextCount < TargetNextCount;
|
GroupIndex < GroupedPursuit.Num() && AddedNextCount < TargetNextCount;
|
||||||
GroupIndex++)
|
GroupIndex++)
|
||||||
@ -158,7 +166,6 @@ void UDTFluxPursuitManager::GetPursuit(TArray<FDTFluxPursuitInfo>& OutPursuitFoc
|
|||||||
AvailableInGroup,
|
AvailableInGroup,
|
||||||
NeededFromGroup);
|
NeededFromGroup);
|
||||||
|
|
||||||
// ✅ COPIER les participants nécessaires (SANS les supprimer du groupe)
|
|
||||||
for (int32 ParticipantIndex = 0; ParticipantIndex < NeededFromGroup; ParticipantIndex++)
|
for (int32 ParticipantIndex = 0; ParticipantIndex < NeededFromGroup; ParticipantIndex++)
|
||||||
{
|
{
|
||||||
FDTFluxPursuitInfo NextParticipant = NextGroup.PursuitGroup[ParticipantIndex]; // Copie
|
FDTFluxPursuitInfo NextParticipant = NextGroup.PursuitGroup[ParticipantIndex]; // Copie
|
||||||
@ -198,7 +205,7 @@ void UDTFluxPursuitManager::GetPursuit(TArray<FDTFluxPursuitInfo>& OutPursuitFoc
|
|||||||
bIsSequenceDone = true;
|
bIsSequenceDone = true;
|
||||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("Pursuit sequence will be completed after this round"));
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("Pursuit sequence will be completed after this round"));
|
||||||
}
|
}
|
||||||
FTimespan Duration = FDateTime::UtcNow() - CurrentTime;
|
FTimespan Duration = FDateTime::UtcNow() - MetricsStartFunction;
|
||||||
|
|
||||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("Metrics Time Out: %d fraction seconds"),
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("Metrics Time Out: %d fraction seconds"),
|
||||||
Duration.GetDuration().GetFractionMicro());
|
Duration.GetDuration().GetFractionMicro());
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
#include "DTFluxCoreSubsystemModule.h"
|
||||||
|
#include "Assets/DTFluxModelAsset.h"
|
||||||
#include "Containers/Deque.h"
|
#include "Containers/Deque.h"
|
||||||
#include "Types/Struct/FDTFluxPursuitInfo.h"
|
#include "Types/Struct/FDTFluxPursuitInfo.h"
|
||||||
#include "Subsystems/EngineSubsystem.h"
|
#include "Subsystems/EngineSubsystem.h"
|
||||||
@ -98,9 +100,9 @@ public:
|
|||||||
TArray<FDTFluxContest> GetCurrentContests();
|
TArray<FDTFluxContest> GetCurrentContests();
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
TArray<int> GetContestsIdForTime(const FDateTime Time) const;
|
TArray<int> GetContestsIdForTime(const FDateTime Time) const;
|
||||||
UFUNCTION()
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
bool GetContestForId(const int Id, FDTFluxContest& OutContest);
|
bool GetContestForId(const int Id, FDTFluxContest& OutContest);
|
||||||
UFUNCTION()
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
TArray<FDTFluxContest> GetContestsForTime(const FDateTime Time);
|
TArray<FDTFluxContest> GetContestsForTime(const FDateTime Time);
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
@ -108,6 +110,79 @@ public:
|
|||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
TArray<FDTFluxContest> GetContests();
|
TArray<FDTFluxContest> GetContests();
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
|
void GetContest(const int ContestId, FDTFluxContest& OutContest)
|
||||||
|
{
|
||||||
|
OutContest = FDTFluxContest();
|
||||||
|
if (GetContestForId(ContestId, OutContest))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("ContestId %d not found in ContestDefinition"), ContestId)
|
||||||
|
}
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
|
bool GetStageDefinition(const FDTFluxStageKey StageKey, FDTFluxStage& OutStageDefinition)
|
||||||
|
{
|
||||||
|
int ContestId = StageKey.ContestId;
|
||||||
|
int StageId = StageKey.StageId;
|
||||||
|
FDTFluxContest ContestDefinition;
|
||||||
|
if (GetContestForId(ContestId, ContestDefinition))
|
||||||
|
{
|
||||||
|
if (ContestDefinition.Stages.IsValidIndex(StageId))
|
||||||
|
{
|
||||||
|
OutStageDefinition = ContestDefinition.Stages[StageId];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
OutStageDefinition = FDTFluxStage();
|
||||||
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("ContestId %d, StageId %d not found in ContestDefinition"),
|
||||||
|
ContestId, StageId)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
|
bool GetSplitDefinition(const FDTFluxSplitKey SplitKey, FDTFluxSplit& OutSplitDefinition)
|
||||||
|
{
|
||||||
|
int ContestId = SplitKey.ContestId;
|
||||||
|
int SplitId = SplitKey.SplitId;
|
||||||
|
FDTFluxContest ContestDefinition;
|
||||||
|
if (GetContestForId(ContestId, ContestDefinition))
|
||||||
|
{
|
||||||
|
if (ContestDefinition.Splits.IsValidIndex(SplitId))
|
||||||
|
{
|
||||||
|
OutSplitDefinition = ContestDefinition.Splits[SplitId];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
OutSplitDefinition = FDTFluxSplit();
|
||||||
|
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("ContestId %d, SplitId %d not found in ContestDefinition"),
|
||||||
|
ContestId, SplitId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
|
void GetStage(const int ContestId, const int StageId, FDTFluxStage& OutStageDefinition)
|
||||||
|
{
|
||||||
|
if (GetStageDefinition(FDTFluxStageKey(ContestId, StageId),
|
||||||
|
OutStageDefinition))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
OutStageDefinition = FDTFluxStage();
|
||||||
|
}
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="DTFlux|Core Subsystem")
|
||||||
|
void GetSplit(const int ContestId, const int StageId, const int SplitId, FDTFluxSplit& OutSplitDefinition)
|
||||||
|
{
|
||||||
|
if (GetSplitDefinition(FDTFluxSplitKey(ContestId, StageId, SplitId),
|
||||||
|
OutSplitDefinition))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
OutSplitDefinition = FDTFluxSplit();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// ~Subsystem Interface
|
// ~Subsystem Interface
|
||||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
#include "DTFluxDatesUtilities.h"
|
#include "DTFluxDatesUtilities.h"
|
||||||
|
|
||||||
#include "DTFluxUtilitiesModule.h"
|
#include "DTFluxUtilitiesModule.h"
|
||||||
@ -16,18 +15,20 @@ DTFluxDatesUtilities::~DTFluxDatesUtilities()
|
|||||||
|
|
||||||
bool DTFluxDatesUtilities::CompileDateAndTime(const FString& Time, const FString& Date, FDateTime& OutDateTime)
|
bool DTFluxDatesUtilities::CompileDateAndTime(const FString& Time, const FString& Date, FDateTime& OutDateTime)
|
||||||
{
|
{
|
||||||
if(Time.Len() < 8 && Date.Len() < 10)
|
if (Time.Len() < 8 && Date.Len() < 10)
|
||||||
{
|
{
|
||||||
TArray<FString> ExplodedTime;
|
TArray<FString> ExplodedTime;
|
||||||
Time.ParseIntoArray(ExplodedTime, TEXT(":"));
|
Time.ParseIntoArray(ExplodedTime, TEXT(":"));
|
||||||
if(ExplodedTime.Num() != 3 && !ExplodedTime[0].IsNumeric() && !ExplodedTime[1].IsNumeric() & !ExplodedTime[2].IsNumeric())
|
if (ExplodedTime.Num() != 3 && !ExplodedTime[0].IsNumeric() && !ExplodedTime[1].IsNumeric() & !ExplodedTime[2].
|
||||||
|
IsNumeric())
|
||||||
{
|
{
|
||||||
UE_LOG(logDTFluxUtilities, Error, TEXT("Bad Time Format [%s]. Unable to parse"), *Time);
|
UE_LOG(logDTFluxUtilities, Error, TEXT("Bad Time Format [%s]. Unable to parse"), *Time);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
TArray<FString> ExplodedDate;
|
TArray<FString> ExplodedDate;
|
||||||
Date.ParseIntoArray(ExplodedDate, TEXT("-"));
|
Date.ParseIntoArray(ExplodedDate, TEXT("-"));
|
||||||
if(ExplodedDate.Num() != 3 && !ExplodedDate[0].IsNumeric() && !ExplodedDate[1].IsNumeric() && !ExplodedDate[2].IsNumeric() )
|
if (ExplodedDate.Num() != 3 && !ExplodedDate[0].IsNumeric() && !ExplodedDate[1].IsNumeric() && !ExplodedDate[2].
|
||||||
|
IsNumeric())
|
||||||
{
|
{
|
||||||
UE_LOG(logDTFluxUtilities, Error, TEXT("Bad Date Format [%s]. Unable to parse"), *Date);
|
UE_LOG(logDTFluxUtilities, Error, TEXT("Bad Date Format [%s]. Unable to parse"), *Date);
|
||||||
return false;
|
return false;
|
||||||
@ -38,7 +39,7 @@ bool DTFluxDatesUtilities::CompileDateAndTime(const FString& Time, const FString
|
|||||||
int32 Day = FCString::Atoi(*ExplodedDate[2]);
|
int32 Day = FCString::Atoi(*ExplodedDate[2]);
|
||||||
int32 Month = FCString::Atoi(*ExplodedDate[1]);
|
int32 Month = FCString::Atoi(*ExplodedDate[1]);
|
||||||
int32 Year = FCString::Atoi(*ExplodedDate[0]);
|
int32 Year = FCString::Atoi(*ExplodedDate[0]);
|
||||||
if(FDateTime::Validate(Year, Month, Day, Hours, Minutes, Seconds, 0))
|
if (FDateTime::Validate(Year, Month, Day, Hours, Minutes, Seconds, 0))
|
||||||
{
|
{
|
||||||
OutDateTime = FDateTime(Year, Month, Day, Hours, Minutes, Seconds);
|
OutDateTime = FDateTime(Year, Month, Day, Hours, Minutes, Seconds);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
// Fill out your copyright notice in the Description page of Project Settings.
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class DTFLUXUTILITIES_API DTFluxDatesUtilities
|
class DTFLUXUTILITIES_API DTFluxDatesUtilities
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user