200 - Limiting Server-Side Rewind
This commit is contained in:
parent
6acf090c07
commit
9e64e70607
Binary file not shown.
Binary file not shown.
|
@ -75,6 +75,10 @@ void ABlasterPlayerController::CheckPing(float DeltaTime)
|
|||
{
|
||||
HighPingWarning();
|
||||
PingAnimationRunningTime = 0.f;
|
||||
ServerReportPingStatus(true);
|
||||
} else
|
||||
{
|
||||
ServerReportPingStatus(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,6 +99,11 @@ void ABlasterPlayerController::CheckPing(float DeltaTime)
|
|||
}
|
||||
}
|
||||
|
||||
// Is the ping to high?
|
||||
void ABlasterPlayerController::ServerReportPingStatus_Implementation(bool bHighPing)
|
||||
{
|
||||
HighPingDelegate.Broadcast(bHighPing);
|
||||
}
|
||||
|
||||
void ABlasterPlayerController::SetDebugMsg2(FString Key, FString Value)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#include "GameFramework/PlayerController.h"
|
||||
#include "BlasterPlayerController.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FHighPingDelegate, bool, bPingTooHigh);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -46,6 +48,8 @@ public:
|
|||
void HandleCooldown();
|
||||
|
||||
float SingleTripTime = 0.f;
|
||||
|
||||
FHighPingDelegate HighPingDelegate;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -139,6 +143,10 @@ private:
|
|||
float PingAnimationRunningTime = 0.f;
|
||||
UPROPERTY(EditAnywhere)
|
||||
float CheckPingFrequency = 20.f;
|
||||
|
||||
UFUNCTION(Server, Reliable)
|
||||
void ServerReportPingStatus(bool bHighPing);
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
float HighPingThreshold = 50.f;
|
||||
};
|
||||
|
|
|
@ -45,6 +45,7 @@ void AWeapon::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeP
|
|||
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||
|
||||
DOREPLIFETIME(AWeapon, WeaponState);
|
||||
DOREPLIFETIME_CONDITION(AWeapon, bUseServerSideRewind, COND_OwnerOnly);
|
||||
}
|
||||
|
||||
void AWeapon::EnableCustomDepth(bool bEnabled)
|
||||
|
@ -190,6 +191,11 @@ void AWeapon::OnWeaponStateSet()
|
|||
}
|
||||
}
|
||||
|
||||
void AWeapon::OnPingTooHigh(bool bPingTooHigh)
|
||||
{
|
||||
bUseServerSideRewind = !bPingTooHigh;
|
||||
}
|
||||
|
||||
void AWeapon::OnRep_WeaponState()
|
||||
{
|
||||
OnWeaponStateSet();
|
||||
|
@ -209,6 +215,16 @@ void AWeapon::OnEquipped()
|
|||
WeaponMesh->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);
|
||||
}
|
||||
EnableCustomDepth(false);
|
||||
|
||||
OwnerCharacter = OwnerCharacter == nullptr ? Cast<ABlasterCharacter>(GetOwner()) : OwnerCharacter;
|
||||
if (OwnerCharacter && bUseServerSideRewind)
|
||||
{
|
||||
OwnerController = OwnerController == nullptr ? Cast<ABlasterPlayerController>(OwnerCharacter->Controller) : OwnerController;
|
||||
if (OwnerController && HasAuthority() && !OwnerController->HighPingDelegate.IsBound())
|
||||
{
|
||||
OwnerController->HighPingDelegate.AddDynamic(this, &AWeapon::OnPingTooHigh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AWeapon::OnEquippedSecondary()
|
||||
|
@ -230,6 +246,15 @@ void AWeapon::OnEquippedSecondary()
|
|||
WeaponMesh->SetCustomDepthStencilValue(CUSTOM_DEPTH_TAN);
|
||||
WeaponMesh->MarkRenderStateDirty();
|
||||
}
|
||||
OwnerCharacter = OwnerCharacter == nullptr ? Cast<ABlasterCharacter>(GetOwner()) : OwnerCharacter;
|
||||
if (OwnerCharacter && bUseServerSideRewind)
|
||||
{
|
||||
OwnerController = OwnerController == nullptr ? Cast<ABlasterPlayerController>(OwnerCharacter->Controller) : OwnerController;
|
||||
if (OwnerController && HasAuthority() && OwnerController->HighPingDelegate.IsBound())
|
||||
{
|
||||
OwnerController->HighPingDelegate.RemoveDynamic(this, &AWeapon::OnPingTooHigh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AWeapon::OnDropped()
|
||||
|
@ -247,6 +272,16 @@ void AWeapon::OnDropped()
|
|||
WeaponMesh->SetCustomDepthStencilValue(CUSTOM_DEPTH_BLUE);
|
||||
WeaponMesh->MarkRenderStateDirty();
|
||||
EnableCustomDepth(true);
|
||||
|
||||
OwnerCharacter = OwnerCharacter == nullptr ? Cast<ABlasterCharacter>(GetOwner()) : OwnerCharacter;
|
||||
if (OwnerCharacter && bUseServerSideRewind)
|
||||
{
|
||||
OwnerController = OwnerController == nullptr ? Cast<ABlasterPlayerController>(OwnerCharacter->Controller) : OwnerController;
|
||||
if (OwnerController && HasAuthority() && OwnerController->HighPingDelegate.IsBound())
|
||||
{
|
||||
OwnerController->HighPingDelegate.RemoveDynamic(this, &AWeapon::OnPingTooHigh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ protected:
|
|||
UPROPERTY(EditAnywhere)
|
||||
float Damage = 20.f;
|
||||
|
||||
UPROPERTY(EditAnywhere)
|
||||
UPROPERTY(Replicated, EditAnywhere)
|
||||
bool bUseServerSideRewind = false;
|
||||
|
||||
UPROPERTY()
|
||||
|
@ -135,6 +135,9 @@ protected:
|
|||
|
||||
UPROPERTY()
|
||||
class ABlasterPlayerController* OwnerController;
|
||||
|
||||
UFUNCTION()
|
||||
void OnPingTooHigh(bool bPingTooHigh);
|
||||
|
||||
private:
|
||||
UPROPERTY(VisibleAnywhere, Category = "Weapon Properties")
|
||||
|
|
Loading…
Reference in New Issue