Improved network accuracy
This commit is contained in:
@@ -386,25 +386,10 @@ namespace Marro.PacManUdon
|
||||
// Get our target time
|
||||
UpdateInternalTime();
|
||||
|
||||
if (Ready)
|
||||
{
|
||||
if (IsOwner)
|
||||
{
|
||||
ProcessEventsToSend(); // Prepare events from last cycle
|
||||
ProgressPingTime(); // See if we need to send a ping
|
||||
}
|
||||
else
|
||||
{
|
||||
ApplyReceivedEvents(); // See if there's events that need to be replayed
|
||||
}
|
||||
}
|
||||
|
||||
// Forwards simulated time by updateDelta until we're caught up
|
||||
while (nextUpdateTime <= internalTime)
|
||||
{
|
||||
ProgressSyncedTime(nextUpdateTime);
|
||||
PerformFixedSyncedUpdate();
|
||||
nextUpdateTime = SyncedTime + updateDelta;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,6 +417,26 @@ namespace Marro.PacManUdon
|
||||
}
|
||||
|
||||
private void PerformFixedSyncedUpdate()
|
||||
{
|
||||
if (Ready)
|
||||
{
|
||||
if (IsOwner)
|
||||
{
|
||||
ProcessEventsToSend(); // Prepare events from last cycle
|
||||
ProgressPingTime(); // See if we need to send a ping
|
||||
}
|
||||
else
|
||||
{
|
||||
ApplyReceivedEvents(); // See if there's events after last update that need to be replayed
|
||||
}
|
||||
}
|
||||
|
||||
ProgressSyncedTime(nextUpdateTime);
|
||||
CallSyncedUpdate();
|
||||
nextUpdateTime = SyncedTime + updateDelta;
|
||||
}
|
||||
|
||||
private void CallSyncedUpdate()
|
||||
{
|
||||
IsEventUpdate = false;
|
||||
|
||||
@@ -817,7 +822,7 @@ namespace Marro.PacManUdon
|
||||
{
|
||||
IsEventUpdate = true;
|
||||
|
||||
while (eventsQueueIndex > 0 && nextEventTime <= internalTime)
|
||||
while (eventsQueueIndex > 0 && nextEventTime <= SyncedTime)
|
||||
{
|
||||
var success = ApplyEvent(eventsQueue[0]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user