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();
|
HighPingWarning();
|
||||||
PingAnimationRunningTime = 0.f;
|
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)
|
void ABlasterPlayerController::SetDebugMsg2(FString Key, FString Value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
#include "GameFramework/PlayerController.h"
|
#include "GameFramework/PlayerController.h"
|
||||||
#include "BlasterPlayerController.generated.h"
|
#include "BlasterPlayerController.generated.h"
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FHighPingDelegate, bool, bPingTooHigh);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -46,6 +48,8 @@ public:
|
||||||
void HandleCooldown();
|
void HandleCooldown();
|
||||||
|
|
||||||
float SingleTripTime = 0.f;
|
float SingleTripTime = 0.f;
|
||||||
|
|
||||||
|
FHighPingDelegate HighPingDelegate;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -139,6 +143,10 @@ private:
|
||||||
float PingAnimationRunningTime = 0.f;
|
float PingAnimationRunningTime = 0.f;
|
||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
float CheckPingFrequency = 20.f;
|
float CheckPingFrequency = 20.f;
|
||||||
|
|
||||||
|
UFUNCTION(Server, Reliable)
|
||||||
|
void ServerReportPingStatus(bool bHighPing);
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
float HighPingThreshold = 50.f;
|
float HighPingThreshold = 50.f;
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,6 +45,7 @@ void AWeapon::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeP
|
||||||
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||||
|
|
||||||
DOREPLIFETIME(AWeapon, WeaponState);
|
DOREPLIFETIME(AWeapon, WeaponState);
|
||||||
|
DOREPLIFETIME_CONDITION(AWeapon, bUseServerSideRewind, COND_OwnerOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AWeapon::EnableCustomDepth(bool bEnabled)
|
void AWeapon::EnableCustomDepth(bool bEnabled)
|
||||||
|
@ -190,6 +191,11 @@ void AWeapon::OnWeaponStateSet()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AWeapon::OnPingTooHigh(bool bPingTooHigh)
|
||||||
|
{
|
||||||
|
bUseServerSideRewind = !bPingTooHigh;
|
||||||
|
}
|
||||||
|
|
||||||
void AWeapon::OnRep_WeaponState()
|
void AWeapon::OnRep_WeaponState()
|
||||||
{
|
{
|
||||||
OnWeaponStateSet();
|
OnWeaponStateSet();
|
||||||
|
@ -209,6 +215,16 @@ void AWeapon::OnEquipped()
|
||||||
WeaponMesh->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);
|
WeaponMesh->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Ignore);
|
||||||
}
|
}
|
||||||
EnableCustomDepth(false);
|
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()
|
void AWeapon::OnEquippedSecondary()
|
||||||
|
@ -230,6 +246,15 @@ void AWeapon::OnEquippedSecondary()
|
||||||
WeaponMesh->SetCustomDepthStencilValue(CUSTOM_DEPTH_TAN);
|
WeaponMesh->SetCustomDepthStencilValue(CUSTOM_DEPTH_TAN);
|
||||||
WeaponMesh->MarkRenderStateDirty();
|
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()
|
void AWeapon::OnDropped()
|
||||||
|
@ -247,6 +272,16 @@ void AWeapon::OnDropped()
|
||||||
WeaponMesh->SetCustomDepthStencilValue(CUSTOM_DEPTH_BLUE);
|
WeaponMesh->SetCustomDepthStencilValue(CUSTOM_DEPTH_BLUE);
|
||||||
WeaponMesh->MarkRenderStateDirty();
|
WeaponMesh->MarkRenderStateDirty();
|
||||||
EnableCustomDepth(true);
|
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)
|
UPROPERTY(EditAnywhere)
|
||||||
float Damage = 20.f;
|
float Damage = 20.f;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(Replicated, EditAnywhere)
|
||||||
bool bUseServerSideRewind = false;
|
bool bUseServerSideRewind = false;
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
|
@ -135,6 +135,9 @@ protected:
|
||||||
|
|
||||||
UPROPERTY()
|
UPROPERTY()
|
||||||
class ABlasterPlayerController* OwnerController;
|
class ABlasterPlayerController* OwnerController;
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void OnPingTooHigh(bool bPingTooHigh);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UPROPERTY(VisibleAnywhere, Category = "Weapon Properties")
|
UPROPERTY(VisibleAnywhere, Category = "Weapon Properties")
|
||||||
|
|
Loading…
Reference in New Issue