Removal and Replacement of the CryTimer (gEnv->pTimer) (#5409)

Replaced and removed the CryTimer (gEnv->pTimer). The new TimeSystem is a merger of the current time functionality found in the engine.

* Rename TimeSystemComponent.h/.cpp to TimeSystem.h/.cpp
* Adding New TimeSystem
* remove old timer cvars
* small improvements to the time system.
 - updated parts to use the time conversion functions.
 - in AdvanceTickDeltaTimes applying t_simulationTickScale is now uses doubles instead of floats.
* Replace gEnv->pTimer / ITimer usages with TimeSystem
* Updating usages of AZ::TimeMs{ 0 } and AZ::TimeUs{ 0 } to AZ::Time::ZeroTimeMs and AZ::Time::ZeroTimeUs
* red code the CryTimer
* using TimeUs instead of TimeMs is some cases + updating usages of old cvars to new

Signed-off-by: amzn-sean <75276488+amzn-sean@users.noreply.github.com>
This commit is contained in:
amzn-sean
2021-11-15 12:11:58 +00:00
committed by GitHub
parent 0ada8b335b
commit 38a03817bb
142 changed files with 1215 additions and 2090 deletions
@@ -66,11 +66,6 @@ namespace Multiplayer
}
}
inline double ConvertTimeMsToSeconds(AZ::TimeMs value)
{
return static_cast<double>(static_cast<AZ::TimeMs>(value)) / 1000.0;
}
void LocalPredictionPlayerInputComponent::LocalPredictionPlayerInputComponent::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
@@ -162,7 +157,7 @@ namespace Multiplayer
}
const AZ::TimeMs currentTimeMs = AZ::GetElapsedTimeMs();
const double clientInputRateSec = ConvertTimeMsToSeconds(cl_InputRateMs);
const double clientInputRateSec = AZ::TimeMsToSecondsDouble(cl_InputRateMs);
m_lastInputReceivedTimeMs = currentTimeMs;
// Keep track of last inputs received, also allows us to update frame ids
@@ -267,7 +262,7 @@ namespace Multiplayer
return;
}
const double clientInputRateSec = ConvertTimeMsToSeconds(cl_InputRateMs);
const double clientInputRateSec = AZ::TimeMsToSecondsDouble(cl_InputRateMs);
// Copy array so we can modify input ids
NetworkInputMigrationVector inputArrayCopy = inputArray;
@@ -342,7 +337,7 @@ namespace Multiplayer
// If this correction is for a move outside our input history window, just start replaying from the oldest move we have available
const uint32_t startReplayIndex = (inputHistorySize > historicalDelta) ? (inputHistorySize - historicalDelta) : 0;
const double clientInputRateSec = ConvertTimeMsToSeconds(cl_InputRateMs);
const double clientInputRateSec = AZ::TimeMsToSecondsDouble(cl_InputRateMs);
for (uint32_t replayIndex = startReplayIndex; replayIndex < inputHistorySize; ++replayIndex)
{
// Reprocess the input for this frame
@@ -423,9 +418,9 @@ namespace Multiplayer
void LocalPredictionPlayerInputComponentController::UpdateAutonomous(AZ::TimeMs deltaTimeMs)
{
const double deltaTime = ConvertTimeMsToSeconds(deltaTimeMs);
const double clientInputRateSec = ConvertTimeMsToSeconds(cl_InputRateMs);
const double maxRewindHistory = ConvertTimeMsToSeconds(cl_MaxRewindHistoryMs);
const double deltaTime = AZ::TimeMsToSecondsDouble(deltaTimeMs);
const double clientInputRateSec = AZ::TimeMsToSecondsDouble(cl_InputRateMs);
const double maxRewindHistory = AZ::TimeMsToSecondsDouble(cl_MaxRewindHistoryMs);
#ifndef AZ_RELEASE_BUILD
m_moveAccumulator += deltaTime * cl_DebugHackTimeMultiplier;
@@ -13,7 +13,7 @@ namespace Multiplayer
// This can be used to help mitigate client side performance when large numbers of entities are created off the network
AZ_CVAR(uint32_t, cl_ClientMaxRemoteEntitiesPendingCreationCount, AZStd::numeric_limits<uint32_t>::max(), nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Maximum number of entities that we have sent to the client, but have not had a confirmation back from the client");
AZ_CVAR(AZ::TimeMs, cl_ClientEntityReplicatorPendingRemovalTimeMs, AZ::TimeMs{ 10000 }, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "How long should wait prior to removing an entity for the client through a change in the replication window, entity deletes are still immediate");
AZ_CVAR(AZ::TimeMs, cl_DefaultNetworkEntityActivationTimeSliceMs, AZ::TimeMs{ 0 }, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Max Ms to use to activate entities coming from the network, 0 means instantiate everything");
AZ_CVAR(AZ::TimeMs, cl_DefaultNetworkEntityActivationTimeSliceMs, AZ::Time::ZeroTimeMs, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Max Ms to use to activate entities coming from the network, 0 means instantiate everything");
ClientToServerConnectionData::ClientToServerConnectionData
(
@@ -27,7 +27,7 @@ namespace Multiplayer
CollectHierarchyRoots();
AZ::EntitySystemBus::Handler::BusConnect();
m_updateDebugOverlay.Enqueue(AZ::TimeMs{ 0 }, true);
m_updateDebugOverlay.Enqueue(AZ::Time::ZeroTimeMs, true);
}
MultiplayerDebugHierarchyReporter::~MultiplayerDebugHierarchyReporter()
@@ -127,7 +127,7 @@ namespace Multiplayer
MultiplayerDebugPerEntityReporter::MultiplayerDebugPerEntityReporter()
: m_updateDebugOverlay([this]() { UpdateDebugOverlay(); }, AZ::Name("UpdateDebugPerEntityOverlay"))
{
m_updateDebugOverlay.Enqueue(AZ::TimeMs{ 0 }, true);
m_updateDebugOverlay.Enqueue(AZ::Time::ZeroTimeMs, true);
m_eventHandlers.m_entitySerializeStart = decltype(m_eventHandlers.m_entitySerializeStart)([this](AzNetworking::SerializerMode mode, AZ::EntityId entityId, const char* entityName)
{
@@ -35,7 +35,7 @@ namespace Multiplayer
{
m_networkEditorInterface = AZ::Interface<INetworking>::Get()->CreateNetworkInterface(
AZ::Name(MpEditorInterfaceName), ProtocolType::Tcp, TrustZone::ExternalClientToServer, *this);
m_networkEditorInterface->SetTimeoutMs(AZ::TimeMs{ 0 }); // Disable timeouts on this network interface
m_networkEditorInterface->SetTimeoutMs(AZ::Time::ZeroTimeMs); // Disable timeouts on this network interface
// Wait to activate the editor-server until LegacySystemInterfaceCreated so that the logging system is ready
// Automated testing listens for these logs
@@ -178,7 +178,7 @@ namespace Multiplayer
AZStd::queue<AZStd::string> m_pendingConnectionTickets;
AZStd::unordered_map<uint64_t, NetEntityId> m_playerRejoinData;
AZ::TimeMs m_lastReplicatedHostTimeMs = AZ::TimeMs{ 0 };
AZ::TimeMs m_lastReplicatedHostTimeMs = AZ::Time::ZeroTimeMs;
HostFrameId m_lastReplicatedHostFrameId = HostFrameId(0);
uint64_t m_temporaryUserIdentifier = 0; // Used in the event of a migration or rejoin
@@ -54,10 +54,10 @@ namespace Multiplayer
m_maxPayloadSize = connection.GetConnectionMtu() - UdpPacketHeaderSerializeSize - ReplicationManagerPacketOverhead;
// Schedule ClearRemovedReplicators()
m_clearRemovedReplicators.Enqueue(AZ::TimeMs{ 0 }, true);
m_clearRemovedReplicators.Enqueue(AZ::Time::ZeroTimeMs, true);
// Start window update events
m_updateWindow.Enqueue(AZ::TimeMs{ 0 }, true);
m_updateWindow.Enqueue(AZ::Time::ZeroTimeMs, true);
INetworkEntityManager* networkEntityManager = GetNetworkEntityManager();
if (networkEntityManager != nullptr)
@@ -97,7 +97,7 @@ namespace Multiplayer
notReadyEntities.push_back(entityId);
}
}
if (m_entityActivationTimeSliceMs > AZ::TimeMs{ 0 } && AZ::GetElapsedTimeMs() > endTimeMs)
if (m_entityActivationTimeSliceMs > AZ::Time::ZeroTimeMs && AZ::GetElapsedTimeMs() > endTimeMs)
{
// If we go over our timeslice, break out the loop
break;
@@ -344,7 +344,7 @@ namespace Multiplayer
void EntityReplicator::SetPendingRemoval(AZ::TimeMs pendingRemovalTimeMs)
{
AZ_Assert(m_propertyPublisher, "Only valid if we are publishing updates");
if (pendingRemovalTimeMs > AZ::TimeMs{ 0 })
if (pendingRemovalTimeMs > AZ::Time::ZeroTimeMs)
{
if (!IsPendingRemoval())
{
@@ -26,7 +26,7 @@ namespace Multiplayer
bool PropertySubscriber::IsDeleting() const
{
return m_markForRemovalTimeMs > AZ::TimeMs{ 0 };
return m_markForRemovalTimeMs > AZ::Time::ZeroTimeMs;
}
bool PropertySubscriber::IsDeleted() const
@@ -40,6 +40,6 @@ namespace Multiplayer
// The last packet to have been received about this entity
AzNetworking::PacketId m_lastReceivedPacketId = AzNetworking::InvalidPacketId;
AZ::TimeMs m_markForRemovalTimeMs = AZ::TimeMs{ 0 };
AZ::TimeMs m_markForRemovalTimeMs = AZ::Time::ZeroTimeMs;
};
}
@@ -123,7 +123,7 @@ namespace Multiplayer
AZ_Assert(entityHandle.GetNetBindComponent(), "No NetBindComponent found on networked entity");
}
m_removeList.push_back(entityHandle.GetNetEntityId());
m_removeEntitiesEvent.Enqueue(AZ::TimeMs{ 0 });
m_removeEntitiesEvent.Enqueue(AZ::Time::ZeroTimeMs);
}
}
@@ -44,7 +44,7 @@ namespace Multiplayer
HostFrameId m_hostFrameId = HostFrameId{ 0 };
HostFrameId m_unalteredFrameId = HostFrameId{ 0 };
AZ::TimeMs m_hostTimeMs = AZ::TimeMs{ 0 };
AZ::TimeMs m_hostTimeMs = AZ::Time::ZeroTimeMs;
float m_hostBlendFactor = DefaultBlendFactor;
AzNetworking::ConnectionId m_rewindingConnectionId = AzNetworking::InvalidConnectionId;
};