Skip to content

Commit a70ce94

Browse files
committed
Fix #374 by logging additional info when hooks appear to have invalid data
1 parent 18b9a5b commit a70ce94

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Mods/SML/Source/SML/Private/Patching/BlueprintHookManager.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,22 @@ void UBlueprintHookManager::RegisterBlueprintHook(UGameInstance* OwnerGameInstan
602602
for (const FBlueprintHookDefinition& HookDefinition : HookBlueprintGeneratedClass->HookDescriptors) {
603603

604604
// Make sure the hook target function in question is actually valid
605-
if (HookDefinition.TargetFunction == nullptr || HookDefinition.HookFunction == nullptr || HookDefinition.TargetSpecifier == nullptr) {
606-
UE_LOG(LogBlueprintHookManager, Error, TEXT("Blueprint hook %s has invalid data, blueprint might need to be recompiled."), *HookBlueprintGeneratedClass->GetFullName());
605+
// It could be invalid due to broken data, removal of the target class/function, or being on a dedicated server (ex. widget blueprints not on servers)
606+
if (HookDefinition.TargetFunction == nullptr) {
607+
if (HookDefinition.HookFunction == nullptr) {
608+
// If the hook function is also invalid, we probably have invalid data
609+
UE_LOG(LogBlueprintHookManager, Error, TEXT("Blueprint hook asset %s has invalid data and one of its hooks can't be applied. Target structure may have changed or blueprint might need to be recompiled."), *HookBlueprintGeneratedClass->GetFullName());
610+
} else {
611+
// If the hook function is still valid, we are probably on a dedicated server where the target blueprint doesn't exist
612+
// Short form HookFunction name since the function must be defined in the hook blueprint
613+
UE_LOG(LogBlueprintHookManager, Warning, TEXT("Blueprint hook asset %s hook which would call hook implementation '%s' has invalid Target Function and can't be applied. Either the target structure has changed, or we're running on a dedicated server where the target doesn't exist (for example, widgets) in which case this isn't a problem."), *HookBlueprintGeneratedClass->GetFullName(), *HookDefinition.HookFunction->GetName());
614+
}
615+
continue;
616+
}
617+
618+
// Verify other hook required data
619+
if (HookDefinition.HookFunction == nullptr || HookDefinition.TargetSpecifier == nullptr) {
620+
UE_LOG(LogBlueprintHookManager, Error, TEXT("Blueprint hook asset %s for target function %s has invalid data and can't be applied. Blueprint might need to be recompiled."), *HookBlueprintGeneratedClass->GetFullName(), *HookDefinition.TargetFunction->GetFullName());
607621
continue;
608622
}
609623

0 commit comments

Comments
 (0)