Various bug fixes to get entity replication working

This commit is contained in:
karlberg
2021-04-13 20:24:08 -07:00
parent 7b3b1cd73e
commit ca3df5d6c8
29 changed files with 495 additions and 137 deletions
@@ -73,7 +73,7 @@ namespace Multiplayer
template <typename BASE_TYPE, AZStd::size_t REWIND_SIZE>
inline BASE_TYPE& RewindableObject<BASE_TYPE, REWIND_SIZE>::Modify()
{
ApplicationFrameId frameTime = GetCurrentTimeForProperty();
const ApplicationFrameId frameTime = GetCurrentTimeForProperty();
if (frameTime < m_headTime)
{
AZ_Assert(false, "Trying to mutate a rewindable in the past");
@@ -82,7 +82,7 @@ namespace Multiplayer
{
SetValueForTime(GetValueForTime(frameTime), frameTime);
}
const BASE_TYPE& returnValue = GetValueForTime(GetCurrentTimeForProperty());
const BASE_TYPE& returnValue = GetValueForTime(frameTime);
return const_cast<BASE_TYPE&>(returnValue);
}
@@ -103,10 +103,11 @@ namespace Multiplayer
template <typename BASE_TYPE, AZStd::size_t REWIND_SIZE>
inline bool RewindableObject<BASE_TYPE, REWIND_SIZE>::Serialize(AzNetworking::ISerializer& serializer)
{
BASE_TYPE current = GetValueForTime(GetCurrentTimeForProperty());
if (serializer.Serialize(current, "Element") && (serializer.GetSerializerMode() == AzNetworking::SerializerMode::WriteToObject))
const ApplicationFrameId frameTime = GetCurrentTimeForProperty();
BASE_TYPE value = GetValueForTime(frameTime);
if (serializer.Serialize(value, "Element") && (serializer.GetSerializerMode() == AzNetworking::SerializerMode::WriteToObject))
{
SetValueForTime(current, GetCurrentTimeForProperty());
SetValueForTime(value, frameTime);
}
return serializer.IsValid();
}