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);
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
{
this->ActiveNode = nullptr;
this->ActivateComboAction(Input);
return;
UE_LOG(LogComboManagerComponent, Verbose, TEXT("No action found for %s"), *Input->ComboInputName.ToString());
}
}
void UComboManagerComponent::DEBUG__UnlockAction(TObjectPtr<const UComboInputAsset> Unlock)

View File

@ -27,12 +27,19 @@ void UInputBufferComponent::BeginPlay()
const UInputBufferSubsystemGlobalSettings *Settings = GetDefault<UInputBufferSubsystemGlobalSettings>();
TSet<const UInputAction *> InputActionsToBind;
for (TSoftObjectPtr<const UComboInputAsset> ComboInput : Settings->ComboActions)
{
if (ComboInput.IsValid())
{
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)
{
this->BindAction(InputAction, ETriggerEvent::Started, this, &UInputBufferComponent::AddActionToBuffer, InputAction);
@ -51,6 +58,8 @@ void UInputBufferComponent::AddActionToBuffer(const FInputActionValue &Value, co
// Find any combo input that matches this action, plus buffered actions.
const UInputBufferSubsystemGlobalSettings *Settings = GetDefault<UInputBufferSubsystemGlobalSettings>();
for (TSoftObjectPtr<const UComboInputAsset> ComboInput : Settings->ComboActions)
{
if (ComboInput.IsValid())
{
if (ComboInput->MatchesInputActions(this->MostRecentActions))
{
@ -59,6 +68,11 @@ void UInputBufferComponent::AddActionToBuffer(const FInputActionValue &Value, co
break;
}
}
else
{
UE_LOG(LogInputBufferComponent, Verbose, TEXT("Invalid combo action found in Combo Actions list in %s"), *Settings->GetClass()->GetName());
}
}
this->GetWorld()->GetTimerManager().SetTimer(this->MultiPressTimerHandle, this, &UInputBufferComponent::ClearMultiPresses, Settings->MultiPressTimerLength);
}