forked from space-wizards/RobustToolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Pool a lot more stuff with PVS under the assumption once GameState / MsgState are serialized it's safe to fuck with it. I tried using Collections.Pooled although then you need IList and it becomes a lot more scrunkly with serializing it so I just kept using ObjectPool for now. Maybe someday it'd be better to swap as the pooled data could be re-used across more systems although this PVS data allocs to shit on live. - Move _deletionHistory out of PVSCollection to PvsSystem with the goal of nuking RobustTree someday.
- Loading branch information
1 parent
2459a9d
commit 412a626
Showing
9 changed files
with
208 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System.Collections.Generic; | ||
using Robust.Shared.GameObjects; | ||
using Robust.Shared.Timing; | ||
using Robust.Shared.Utility; | ||
|
||
namespace Robust.Server.GameStates; | ||
|
||
internal sealed partial class PvsSystem | ||
{ | ||
/// <summary> | ||
/// History of deletion-tuples, containing the <see cref="GameTick"/> of the deletion, as well as the <see cref="TIndex"/> of the object which was deleted. | ||
/// </summary> | ||
private readonly List<(GameTick tick, NetEntity ent)> _deletionHistory = new(); | ||
|
||
/// <inheritdoc /> | ||
public void CullDeletionHistoryUntil(GameTick tick) | ||
{ | ||
if (tick == GameTick.MaxValue) | ||
{ | ||
_deletionHistory.Clear(); | ||
return; | ||
} | ||
|
||
for (var i = _deletionHistory.Count - 1; i >= 0; i--) | ||
{ | ||
var hist = _deletionHistory[i].tick; | ||
if (hist <= tick) | ||
{ | ||
_deletionHistory.RemoveSwap(i); | ||
if (_largestCulled < hist) | ||
_largestCulled = hist; | ||
} | ||
} | ||
} | ||
|
||
private GameTick _largestCulled; | ||
|
||
public void GetDeletedEntities(GameTick fromTick, IList<NetEntity> ents) | ||
{ | ||
if (fromTick == GameTick.Zero) | ||
return; | ||
|
||
// I'm 99% sure this can never happen, but it is hard to test real laggy/lossy networks with many players. | ||
if (_largestCulled > fromTick) | ||
{ | ||
Log.Error($"Culled required deletion history! culled: {_largestCulled}. requested: > {fromTick}"); | ||
_largestCulled = GameTick.Zero; | ||
} | ||
|
||
foreach (var (tick, id) in _deletionHistory) | ||
{ | ||
if (tick > fromTick) | ||
ents.Add(id); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.