Skip to content

Commit

Permalink
Error if trying to get tags of invalid class
Browse files Browse the repository at this point in the history
  • Loading branch information
budak7273 committed Aug 8, 2024
1 parent c1bd976 commit 25beaa7
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Mods/SML/Source/SML/Private/Registry/ContentTagRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ const FGameplayTagContainer UContentTagRegistry::GetGameplayTagContainerFor(UCla
// Return a copy because the container pointer returned by Find()
// is only valid until the next change to any map key.
FGameplayTagContainer toReturn;

if (!IsValid(content)) {
UE_LOG(LogContentTagRegistry, Error, TEXT("Attempt to retrieve content tags of an invalid class."));
return toReturn;
}

const auto record = GetOrInitContainerFor(content);
if (record) {
toReturn.AppendTags(*record);
Expand Down Expand Up @@ -100,6 +106,31 @@ FGameplayTagContainer UContentTagRegistry::GetTagsFromExtendedAttributeProvider(
return FGameplayTagContainer::EmptyContainer;
}

void UContentTagRegistry::RegisterTagAdditionTable(FName ModReference, UDataTable* TagTable) {
if (!IsValid(TagTable)) {
const FString Context = FString::Printf(TEXT("Attempt to register NULL TagTable. Mod Reference: %s"), *ModReference.ToString());
NOTIFY_INVALID_REGISTRATION(*Context);
return;
}

if (!IsValid(PointTable->RowStruct) || !PointTable->RowStruct->IsChildOf(FResourceSinkPointsData::StaticStruct())) {
const FString Context = FString::Printf(TEXT("Invalid AWESOME Sink item points table in mod %s (%s): Row Type should be Resource Sink Points Data"),
*ModReference.ToString(), *PointTable->GetPathName());
NOTIFY_INVALID_REGISTRATION(*Context);
return;
}

FPendingResourceSinkRegistration Registration;
Registration.Track = Track;
Registration.ModReference = ModReference;
Registration.PointTable = PointTable;

PendingItemSinkPointsRegistrations.Add(Registration);
if (AFGResourceSinkSubsystem* ResourceSinkSubsystem = AFGResourceSinkSubsystem::Get(GetWorld())) {
FlushPendingResourceSinkRegistrations(ResourceSinkSubsystem);
}
}

void UContentTagRegistry::FreezeRegistry() {
UE_LOG(LogContentTagRegistry, Verbose, TEXT("Freezing content tag registry"));
bRegistryFrozen = true;
Expand Down

0 comments on commit 25beaa7

Please sign in to comment.