mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 19:10:32 +00:00
fix: Prediction.CorrectHistory now adjusts afterIndex after removals/insertions
This commit is contained in:
parent
39338b413d
commit
1d004dcd21
@ -112,11 +112,15 @@ public static T CorrectHistory<T>(
|
||||
// respect the limit
|
||||
// TODO unit test to check if it respects max size
|
||||
if (history.Count >= stateHistoryLimit)
|
||||
{
|
||||
history.RemoveAt(0);
|
||||
afterIndex -= 1; // we removed the first value so all indices are off by one now
|
||||
}
|
||||
|
||||
// insert the corrected state into the history, or overwrite if already exists
|
||||
// SortedList insertions are O(N)!
|
||||
history[corrected.timestamp] = corrected;
|
||||
afterIndex += 1; // we inserted the corrected value before the previous index
|
||||
|
||||
// the entry behind the inserted one still has the delta from (before, after).
|
||||
// we need to correct it to (corrected, after).
|
||||
|
Loading…
Reference in New Issue
Block a user