Error C4717 : ‘UVelocityCharacterMovementComponent::FSavedMove_Velocity::GetCompressedFlags’: recursive on all control paths, function will cause runtime stack overflow
include “VelocityCharacterMovementComponent.h”
include “GameFramework/Character.h”
bool UVelocityCharacterMovementComponent::FSavedMove_Velocity::CanCombineWith(const FSavedMovePtr& NewMove,
ACharacter* InCharacter, float MaxDelta) const
{
FSavedMove_Velocity* NewVelocityMove = static_cast<FSavedMove_Velocity*>(NewMove.Get());
if (Saved_bWantsToSprint != NewVelocityMove->Saved_bWantsToSprint)
{
return false;
}
return FSavedMove_Character::CanCombineWith(NewMove, InCharacter, MaxDelta);
}
void UVelocityCharacterMovementComponent::FSavedMove_Velocity::Clear()
{
FSavedMove_Character::Clear();
Saved_bWantsToSprint = 0;
}
uint8 UVelocityCharacterMovementComponent::FSavedMove_Velocity::GetCompressedFlags() const
{
uint8 Result = Super::GetCompressedFlags();
if (Saved_bWantsToSprint) Result |= FLAG_Custom_0;
return Result;
}
void UVelocityCharacterMovementComponent::FSavedMove_Velocity::SetMoveFor(ACharacter* C, float InDeltaTime, FVector const& NewAccel, class FNetworkPredictionData_Client_Character& ClientData)
{
FSavedMove_Character::SetMoveFor(C, InDeltaTime, NewAccel, ClientData);
UVelocityCharacterMovementComponent* CharacterMovement = Cast<UVelocityCharacterMovementComponent>(C->GetCharacterMovement());
Saved_bWantsToSprint = CharacterMovement->Safe_bWantsToSprint;
}
void UVelocityCharacterMovementComponent::FSavedMove_Velocity::PrepMoveFor(ACharacter* C)
{
FSavedMove_Character::PrepMoveFor(C);
UVelocityCharacterMovementComponent* CharacterMovement = Cast<UVelocityCharacterMovementComponent>(C->GetCharacterMovement());
CharacterMovement->Safe_bWantsToSprint = Saved_bWantsToSprint;
}
UVelocityCharacterMovementComponent::FNetworkPredictionData_Client_Velocity::FNetworkPredictionData_Client_Velocity(const UCharacterMovementComponent& ClientMovement)
: Super(ClientMovement)
{
}
FSavedMovePtr UVelocityCharacterMovementComponent::FNetworkPredictionData_Client_Velocity::AllocateNewMove()
{
return FSavedMovePtr(new FSavedMove_Velocity());
}
FNetworkPredictionData_Client* UVelocityCharacterMovementComponent::GetPredictionData_Client() const
{
check(PawnOwner != nullptr)
if (ClientPredictionData == nullptr)
{
UVelocityCharacterMovementComponent* MutableThis = const_cast<UVelocityCharacterMovementComponent*>(this);
MutableThis->ClientPredictionData = new FNetworkPredictionData_Client_Velocity(*this);
MutableThis->ClientPredictionData->MaxSmoothNetUpdateDist = 92.f;
MutableThis->ClientPredictionData->NoSmoothNetUpdateDist = 140.f;
}
return ClientPredictionData;
}
void UVelocityCharacterMovementComponent::UpdateFromCompressedFlags(uint8 Flags)
{
Super::UpdateFromCompressedFlags(Flags);
Safe_bWantsToSprint = (Flags & FSavedMove_Character::FLAG_Custom_0) != 0;
}
void UVelocityCharacterMovementComponent::OnMovementUpdated(float DeltaSeconds, const FVector& OldLocation,const FVector& OldVelocity)
{
Super::OnMovementUpdated(DeltaSeconds, OldLocation, OldVelocity);
if (MovementMode == MOVE_Walking)
{
if (Safe_bWantsToSprint)
{
MaxWalkSpeed = Sprint_MaxWalkSpeed;
}
else
{
MaxWalkSpeed = Walk_MaxWalkSpeed;
}
}
}
void UVelocityCharacterMovementComponent::SprintPressed()
{
Safe_bWantsToSprint = true;
}
void UVelocityCharacterMovementComponent::SprintReleased()
{
Safe_bWantsToSprint = false;
}
UVelocityCharacterMovementComponent::UVelocityCharacterMovementComponent()
{
}