Update GetPrevious to behave similarly to Get when rewound on owning connection
Signed-off-by: puvvadar <puvvadar@amazon.com>
This commit is contained in:
@@ -52,12 +52,6 @@ namespace Multiplayer
|
||||
//! @return the ConnectionId of the connection requesting the rewind operation
|
||||
virtual AzNetworking::ConnectionId GetRewindingConnectionId() const = 0;
|
||||
|
||||
//! Get the controlling connection that may be currently altering global game time.
|
||||
//! Note this abstraction is required at a relatively high level to allow for 'don't rewind the shooter' semantics
|
||||
//! @param rewindConnectionId if this parameter matches the current rewindConnectionId, it will return the unaltered hostFrameId
|
||||
//! @return the HostFrameId taking into account the provided rewinding connectionId
|
||||
virtual HostFrameId GetHostFrameIdForRewindingConnection(AzNetworking::ConnectionId rewindConnectionId) const = 0;
|
||||
|
||||
//! Forcibly sets the current network time to the provided frameId and game time in milliseconds.
|
||||
//! @param frameId the new HostFrameId to use
|
||||
//! @param timeMs the new HostTimeMs to use
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Multiplayer
|
||||
//! @return value in const base type form
|
||||
const BASE_TYPE& Get() const;
|
||||
|
||||
//! Const base type retriever for one host frame behind Get(). Only intended for use in SyncRewind contexts.
|
||||
//! Const base type retriever for one host frame behind Get() when contextually appropriate, otherwise identical to Get().
|
||||
//! @return value in const base type form
|
||||
const BASE_TYPE& GetPrevious() const;
|
||||
|
||||
@@ -86,9 +86,13 @@ namespace Multiplayer
|
||||
private:
|
||||
|
||||
//! Returns what the appropriate current time is for this rewindable property.
|
||||
//! @return the appropriate current time is for this rewindable property
|
||||
//! @return the appropriate current time for this rewindable property
|
||||
HostFrameId GetCurrentTimeForProperty() const;
|
||||
|
||||
//! Returns what the appropriate previous time is for this rewindable property.
|
||||
//! @return the appropriate previous time for this rewindable property
|
||||
HostFrameId GetPreviousTimeForProperty() const;
|
||||
|
||||
//! Updates the latest value for this object instance, if frameTime represents a current or future time.
|
||||
//! Any attempts to set old values on the object will fail
|
||||
//! @param value the new value to set in the object history
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Multiplayer
|
||||
template <typename BASE_TYPE, AZStd::size_t REWIND_SIZE>
|
||||
inline const BASE_TYPE& RewindableObject<BASE_TYPE, REWIND_SIZE>::GetPrevious() const
|
||||
{
|
||||
return GetValueForTime(GetCurrentTimeForProperty() - HostFrameId(1));
|
||||
return GetValueForTime(GetPreviousTimeForProperty());
|
||||
}
|
||||
|
||||
template <typename BASE_TYPE, AZStd::size_t REWIND_SIZE>
|
||||
@@ -118,7 +118,22 @@ namespace Multiplayer
|
||||
inline HostFrameId RewindableObject<BASE_TYPE, REWIND_SIZE>::GetCurrentTimeForProperty() const
|
||||
{
|
||||
INetworkTime* networkTime = Multiplayer::GetNetworkTime();
|
||||
return networkTime->GetHostFrameIdForRewindingConnection(m_owningConnectionId);
|
||||
if (networkTime->IsTimeRewound() && (m_owningConnectionId == networkTime->GetRewindingConnectionId()))
|
||||
{
|
||||
return networkTime->GetUnalteredHostFrameId();
|
||||
}
|
||||
return networkTime->GetHostFrameId();
|
||||
}
|
||||
|
||||
template <typename BASE_TYPE, AZStd::size_t REWIND_SIZE>
|
||||
inline HostFrameId RewindableObject<BASE_TYPE, REWIND_SIZE>::GetPreviousTimeForProperty() const
|
||||
{
|
||||
INetworkTime* networkTime = Multiplayer::GetNetworkTime();
|
||||
if (networkTime->IsTimeRewound() && (m_owningConnectionId == networkTime->GetRewindingConnectionId()))
|
||||
{
|
||||
return networkTime->GetUnalteredHostFrameId();
|
||||
}
|
||||
return networkTime->GetHostFrameId() - HostFrameId(1);
|
||||
}
|
||||
|
||||
template <typename BASE_TYPE, AZStd::size_t REWIND_SIZE>
|
||||
|
||||
@@ -65,11 +65,6 @@ namespace Multiplayer
|
||||
return m_rewindingConnectionId;
|
||||
}
|
||||
|
||||
HostFrameId NetworkTime::GetHostFrameIdForRewindingConnection(AzNetworking::ConnectionId rewindConnectionId) const
|
||||
{
|
||||
return (IsTimeRewound() && (rewindConnectionId == m_rewindingConnectionId)) ? m_unalteredFrameId : m_hostFrameId;
|
||||
}
|
||||
|
||||
void NetworkTime::ForceSetTime(HostFrameId frameId, AZ::TimeMs timeMs)
|
||||
{
|
||||
AZ_Assert(!IsTimeRewound(), "Forcibly setting network time is unsupported under a rewound time scope");
|
||||
|
||||
@@ -32,7 +32,6 @@ namespace Multiplayer
|
||||
AZ::TimeMs GetHostTimeMs() const override;
|
||||
float GetHostBlendFactor() const override;
|
||||
AzNetworking::ConnectionId GetRewindingConnectionId() const override;
|
||||
HostFrameId GetHostFrameIdForRewindingConnection(AzNetworking::ConnectionId rewindConnectionId) const override;
|
||||
void ForceSetTime(HostFrameId frameId, AZ::TimeMs timeMs) override;
|
||||
void AlterTime(HostFrameId frameId, AZ::TimeMs timeMs, float blendFactor, AzNetworking::ConnectionId rewindConnectionId) override;
|
||||
void SyncEntitiesToRewindState(const AZ::Aabb& rewindVolume) override;
|
||||
|
||||
Reference in New Issue
Block a user