Add exception tolerance to explosion processing (#9309)

This commit is contained in:
Leon Friedrich
2022-07-01 06:42:10 +12:00
committed by GitHub
parent 6d9da51ca7
commit 3bbc6fcb74

View File

@@ -117,12 +117,25 @@ public sealed partial class ExplosionSystem : EntitySystem
// TODO EXPLOSION check if active explosion is on a paused map. If it is... I guess support swapping out & // TODO EXPLOSION check if active explosion is on a paused map. If it is... I guess support swapping out &
// storing the "currently active" explosion? // storing the "currently active" explosion?
#if EXCEPTION_TOLERANCE
try
{
#endif
var processed = _activeExplosion.Process(tilesRemaining); var processed = _activeExplosion.Process(tilesRemaining);
tilesRemaining -= processed; tilesRemaining -= processed;
// has the explosion finished processing? // has the explosion finished processing?
if (_activeExplosion.FinishedProcessing) if (_activeExplosion.FinishedProcessing)
_activeExplosion = null; _activeExplosion = null;
#if EXCEPTION_TOLERANCE
}
catch (Exception e)
{
// Ensure the system does not get stuck in an error-loop.
_activeExplosion = null;
throw e;
}
#endif
} }
Logger.InfoS("Explosion", $"Processed {TilesPerTick - tilesRemaining} tiles in {Stopwatch.Elapsed.TotalMilliseconds}ms"); Logger.InfoS("Explosion", $"Processed {TilesPerTick - tilesRemaining} tiles in {Stopwatch.Elapsed.TotalMilliseconds}ms");