Update Function to ensure ref is returned instead of copy for GetContest GetContestForTime
This commit is contained in:
@ -554,24 +554,30 @@ TArray<int> UDTFluxCoreSubsystem::GetCurrentContestsId()
|
||||
return GetContestsIdForTime(FDateTime::Now());
|
||||
}
|
||||
|
||||
TArray<FDTFluxContest> UDTFluxCoreSubsystem::GetCurrentContests()
|
||||
bool UDTFluxCoreSubsystem::GetCurrentContests(TArray<FDTFluxContest>& OutContests)
|
||||
{
|
||||
return GetContestsForTime(FDateTime::Now());
|
||||
return GetContestsForTime(FDateTime::Now(), OutContests);
|
||||
}
|
||||
|
||||
TArray<int> UDTFluxCoreSubsystem::GetContestsIdForTime(const FDateTime Time) const
|
||||
TArray<int> UDTFluxCoreSubsystem::GetContestsIdForTime(const FDateTime Time)
|
||||
{
|
||||
TArray<int> Contests;
|
||||
for (const auto& Pair : DataStorage->Contests)
|
||||
if (DataStorage)
|
||||
{
|
||||
FDTFluxContest Contest = Pair.Value;
|
||||
int ContestId = Contest.ContestId;
|
||||
if (Contest.Date < Time && Contest.EndTime > Time)
|
||||
TArray<FDTFluxContest> Contests;
|
||||
if (GetContestsForTime(Time, Contests))
|
||||
{
|
||||
Contests.Add(ContestId);
|
||||
TArray<int> ContestIds = TArray<int>();
|
||||
for (const auto& Contest : Contests)
|
||||
{
|
||||
ContestIds.Add(Contest.ContestId);
|
||||
}
|
||||
return ContestIds;
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("No Contest running for Time [%s]"), *Time.ToString());
|
||||
return TArray<int>();
|
||||
}
|
||||
return Contests;
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("DataStorage not available"));
|
||||
return TArray<int>();
|
||||
}
|
||||
|
||||
bool UDTFluxCoreSubsystem::GetContestForId(const int Id, FDTFluxContest& OutContest)
|
||||
@ -588,34 +594,46 @@ bool UDTFluxCoreSubsystem::GetContestForId(const int Id, FDTFluxContest& OutCont
|
||||
return false;
|
||||
}
|
||||
|
||||
TArray<FDTFluxContest> UDTFluxCoreSubsystem::GetContestsForTime(const FDateTime Time)
|
||||
{
|
||||
TArray<FDTFluxContest> Contests;
|
||||
for (const auto& Pair : DataStorage->Contests)
|
||||
{
|
||||
FDTFluxContest Contest = Pair.Value;
|
||||
int ContestId = Contest.ContestId;
|
||||
if (Contest.Date < Time && Contest.EndTime > Time)
|
||||
{
|
||||
Contests.Add(Contest);
|
||||
}
|
||||
}
|
||||
return Contests;
|
||||
}
|
||||
|
||||
void UDTFluxCoreSubsystem::RequestRankingsForStages(TArray<FDTFluxStage> RequestedStages) const
|
||||
{
|
||||
}
|
||||
|
||||
TArray<FDTFluxContest> UDTFluxCoreSubsystem::GetContests()
|
||||
bool UDTFluxCoreSubsystem::GetContestsForTime(const FDateTime Time, TArray<FDTFluxContest>& OutContests)
|
||||
{
|
||||
if (DataStorage)
|
||||
{
|
||||
TArray<FDTFluxContest> OutContests;
|
||||
DataStorage->Contests.GenerateValueArray(OutContests);
|
||||
return OutContests;
|
||||
OutContests.Empty();
|
||||
for (const auto& Pair : DataStorage->Contests)
|
||||
{
|
||||
FDTFluxContest Contest = Pair.Value;
|
||||
int ContestId = Contest.ContestId;
|
||||
|
||||
//ils ont commencé.
|
||||
if (Contest.Date < Time && Contest.EndTime > Time)
|
||||
{
|
||||
// ils sont finis
|
||||
if (!Contest.IsFinished())
|
||||
{
|
||||
OutContests.Add(Contest);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!OutContests.IsEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Warning, TEXT("No Contest running for Time [%s]"), *Time.ToString());
|
||||
}
|
||||
return TArray<FDTFluxContest>();
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("DataStorage not available"));
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UDTFluxCoreSubsystem::GetContests(TArray<FDTFluxContest>& OutContests)
|
||||
{
|
||||
OutContests.Empty();
|
||||
if (DataStorage)
|
||||
{
|
||||
DataStorage->Contests.GenerateValueArray(OutContests);
|
||||
return !OutContests.IsEmpty();
|
||||
}
|
||||
UE_LOG(logDTFluxCoreSubsystem, Error, TEXT("DataStorage not available"));
|
||||
return false;
|
||||
}
|
||||
|
||||
void UDTFluxCoreSubsystem::GetContest(const int ContestId, FDTFluxContest& OutContest)
|
||||
|
||||
Reference in New Issue
Block a user