From 9bff895564cb7dd9144e15d6fa8873f457af4b25 Mon Sep 17 00:00:00 2001 From: mischa Date: Thu, 14 Mar 2024 17:20:13 +0800 Subject: [PATCH] FIX: Prediction.CorrectHistory() now adjusts afterIndex after dequeing! --- Assets/Mirror/Core/Prediction/Prediction.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Assets/Mirror/Core/Prediction/Prediction.cs b/Assets/Mirror/Core/Prediction/Prediction.cs index f38d6c373..05b2d8bb7 100644 --- a/Assets/Mirror/Core/Prediction/Prediction.cs +++ b/Assets/Mirror/Core/Prediction/Prediction.cs @@ -110,7 +110,11 @@ public static T CorrectHistory( // respect the limit // TODO unit test to check if it respects max size if (history.Count >= stateHistoryLimit) + { history.Dequeue(); + // if we remove one entry, then we also need to adjust the afterIndex + afterIndex -= 1; + } // unlike with SortedList, we don't insert corrections for RingBuffer. // we only correct the values after it since insertions would be awkward for RingBuffer.