Improved network accuracy

This commit is contained in:
2026-06-11 12:25:12 +02:00
parent f0859d92ac
commit bce6b329c2
3 changed files with 30 additions and 16 deletions

View File

@@ -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]);