# HG changeset patch # User Alys Brooks # Date 2023-05-17 06:40:24 # Node ID 5f524df034cf6589bf71012b71d50acaf22be28a # Parent 06aeecdacbbaa6c4a6b87ca549448d5ccd1b82ba Fix issue with simulation. Previously, if there was more than one tick being advanced at once, it would overshoot how many ticks it covered. So if it was covering 5 ticks and each tick happens every 100 units, rather than recording that it had simulated through t= 500, it would increase the cumulative time for each tick, recording that it had simulated through t=2500. Add error message, too. diff --git a/isometric-park-fna/Simulation.cs b/isometric-park-fna/Simulation.cs --- a/isometric-park-fna/Simulation.cs +++ b/isometric-park-fna/Simulation.cs @@ -441,6 +441,11 @@ int advancesToSimulate = (int)((this.Elapsed - this.lastAdvance) / millisecondsPerAdvance); + if (this.lastAdvance > this.Elapsed) + { + Logging.Error(String.Format("Last Advance is ahead of Elapsed by {0} ms. This should basically never happen.", (this.lastAdvance - this.Elapsed))); + } + for (int i = 0; i < advancesToSimulate; i++) { this.advanceSimulation(); @@ -452,8 +457,8 @@ //it's t=125, we have 2.5 steps to simulate. However, we only want to simulate //whole steps for simplicity's sake, so that means we'll simulate 2. But that means we've only simulated //through t=120, so that's what we want to track in lastAdvance. + } this.lastAdvance += advancesToSimulate * millisecondsPerAdvance; - } } } }