Skip to content

Commit

Permalink
Moved check for build in content from package path to OwnedByModRefer…
Browse files Browse the repository at this point in the history
…ence
  • Loading branch information
Jarno458 committed Nov 11, 2024
1 parent ec30792 commit 63387f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
16 changes: 4 additions & 12 deletions Mods/SML/Source/SML/Private/Registry/ModContentRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,15 @@ EGameObjectRegistrationFlags FGameObjectRegistryState::GetAllowedNewFlags(UObjec

// Never allow Removed, since it's handled by MarkObjectAsRemoved

static FName baseGameProjectName = FApp::GetProjectName();

EGameObjectRegistrationFlags allowedFlags = EGameObjectRegistrationFlags::None;

if ( IsBuildIn( Object ) ) {
if ( !Registration || Registration->OwnedByModReference == baseGameProjectName ) {
allowedFlags |= EGameObjectRegistrationFlags::BuiltIn;
}

if (!Registration || Registration->HasAnyFlags(EGameObjectRegistrationFlags::Unregistered | EGameObjectRegistrationFlags::Implicit))
if ( !Registration || Registration->HasAnyFlags(EGameObjectRegistrationFlags::Unregistered | EGameObjectRegistrationFlags::Implicit) )
{
// Allow Implicit only on unregistered objects, or if it is already set
// so that is is kept when re-registering as Implicit
Expand All @@ -172,16 +174,6 @@ EGameObjectRegistrationFlags FGameObjectRegistryState::GetAllowedNewFlags(UObjec
return allowedFlags;
}

bool FGameObjectRegistryState::IsBuildIn(UObject* Object) {
UPackage* package = Object->GetPackage();

if ( !IsValid( package ) ) {
return false;
}

return package->FileName.ToString().StartsWith("/Game/FactoryGame/");
}

bool FGameObjectRegistryState::AttemptRegisterObject( FName InRegistrationPluginName, UObject* Object, EGameObjectRegistrationFlags ExtraFlags )
{
FString Message;
Expand Down
1 change: 0 additions & 1 deletion Mods/SML/Source/SML/Public/Registry/ModContentRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ class SML_API FGameObjectRegistryState
FGameObjectRegistration* FindOrAddObject( UObject* Object );
bool CanRegisterObject( UObject* Object, EGameObjectRegistrationFlags ExtraFlags, FString& OutMessage );
EGameObjectRegistrationFlags GetAllowedNewFlags( UObject* Object ) const;
static bool IsBuildIn(UObject* Object);
};

// Holds information about a pending registration of item points table to the resource sink subsystem
Expand Down

0 comments on commit 63387f7

Please sign in to comment.