Zone: wait for last tick's belt tasks before clearing the orbit cache
Update cleared `_updatedOrbits` and only then waited on the previous tick's
asteroid-belt tasks, which read the cache through GetOrbitPosition. A task
still running could see the set mid-clear ("concurrent update ... corrupted its
state") or recompute an orbit into last tick's position. The wait now comes
first.
Test (Soul's orbit counter, committed): 3000 back-to-back 0.02 s ticks of a
quiet arena, and no orbit stands still against its parent. Clearing first gave
500+ stalls or the corruption exception. Measured against the parent because a
moon can genuinely pause in zone space: one such reading (tick 1321, a moon
whose motion cancels its planet's) is real motion, not the race.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b3e7995ceb
commit
5c3cd599ac
2 changed files with 26 additions and 1 deletions
|
|
@ -172,10 +172,11 @@ public class Zone
|
|||
public void Update(float deltaTime)
|
||||
{
|
||||
_time += deltaTime;
|
||||
_updatedOrbits.Clear();
|
||||
// Last tick's belt tasks read the orbit cache; they finish before it is cleared.
|
||||
foreach (var t in BeltUpdates)
|
||||
t.Wait();
|
||||
BeltUpdates.Clear();
|
||||
_updatedOrbits.Clear();
|
||||
foreach (var orbit in Orbits)
|
||||
{
|
||||
orbit.Value.PreviousPosition = orbit.Value.Position;
|
||||
|
|
|
|||
Loading…
Reference in a new issue