Fixed various crashes and infinite loops when encountering unhandled or null combo input assets.

This commit is contained in:
Jamie Greunbaum 2023-09-22 14:24:15 -04:00
parent a4913db597
commit aa81438bc7
2 changed files with 21 additions and 9 deletions

View File

@ -77,12 +77,10 @@ void UComboManagerComponent::ActivateComboAction(const UComboInputAsset *Input)
this->BroadcastDelegates(*ComboAction, EComboActionTriggerEvent::Activated); this->BroadcastDelegates(*ComboAction, EComboActionTriggerEvent::Activated);
UE_LOG(LogComboManagerComponent, Verbose, TEXT("Fallback action %s activated"), *(*ComboAction)->ActionName.ToString()); UE_LOG(LogComboManagerComponent, Verbose, TEXT("Fallback action %s activated"), *(*ComboAction)->ActionName.ToString());
} }
// If we haven't found an action to perform, reset the combo and activate using the default start node. // If we haven't found an action to perform, end here.
else else
{ {
this->ActiveNode = nullptr; UE_LOG(LogComboManagerComponent, Verbose, TEXT("No action found for %s"), *Input->ComboInputName.ToString());
this->ActivateComboAction(Input);
return;
} }
} }
void UComboManagerComponent::DEBUG__UnlockAction(TObjectPtr<const UComboInputAsset> Unlock) void UComboManagerComponent::DEBUG__UnlockAction(TObjectPtr<const UComboInputAsset> Unlock)

View File

@ -28,9 +28,16 @@ void UInputBufferComponent::BeginPlay()
TSet<const UInputAction *> InputActionsToBind; TSet<const UInputAction *> InputActionsToBind;
for (TSoftObjectPtr<const UComboInputAsset> ComboInput : Settings->ComboActions) for (TSoftObjectPtr<const UComboInputAsset> ComboInput : Settings->ComboActions)
{ {
for (const UInputAction *InputAction : ComboInput->ActionGroup) if (ComboInput.IsValid())
{ {
InputActionsToBind.Add(InputAction); for (const UInputAction *InputAction : ComboInput->ActionGroup)
{
InputActionsToBind.Add(InputAction);
}
}
else
{
UE_LOG(LogInputBufferComponent, Verbose, TEXT("Invalid combo action found in Combo Actions list in %s"), *Settings->GetClass()->GetName());
} }
} }
for (const UInputAction *InputAction : InputActionsToBind) for (const UInputAction *InputAction : InputActionsToBind)
@ -52,11 +59,18 @@ void UInputBufferComponent::AddActionToBuffer(const FInputActionValue &Value, co
const UInputBufferSubsystemGlobalSettings *Settings = GetDefault<UInputBufferSubsystemGlobalSettings>(); const UInputBufferSubsystemGlobalSettings *Settings = GetDefault<UInputBufferSubsystemGlobalSettings>();
for (TSoftObjectPtr<const UComboInputAsset> ComboInput : Settings->ComboActions) for (TSoftObjectPtr<const UComboInputAsset> ComboInput : Settings->ComboActions)
{ {
if (ComboInput->MatchesInputActions(this->MostRecentActions)) if (ComboInput.IsValid())
{ {
this->ActivateComboInput(ComboInput.Get()); if (ComboInput->MatchesInputActions(this->MostRecentActions))
{
this->ActivateComboInput(ComboInput.Get());
break; break;
}
}
else
{
UE_LOG(LogInputBufferComponent, Verbose, TEXT("Invalid combo action found in Combo Actions list in %s"), *Settings->GetClass()->GetName());
} }
} }