mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-30 16:17:27 +00:00
Reduce explosion airtight cache memory usage (#40912)
* Reduce explosion airtight cache memory usage This means you can happily add explosion prototypes again New approach has the tolerance value data in a shared storage with reference counting. * Oops fix index removal * Remove debug code and fix merge conflicts * Also address my other review * Oh it's in two places lmao --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
This commit is contained in:
committed by
BarryNorfolk
co-authored by
Princess Cheeseballs
parent
538a1b1839
commit
9dd9f5cd92
@@ -1,5 +1,6 @@
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Content.Server.Explosion.Components;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Explosion.Components;
|
||||
using Robust.Shared.Map;
|
||||
@@ -40,11 +41,7 @@ public sealed partial class ExplosionSystem
|
||||
if (totalIntensity <= 0 || slope <= 0)
|
||||
return null;
|
||||
|
||||
if (!_explosionTypes.TryGetValue(typeID, out var typeIndex))
|
||||
{
|
||||
Log.Error("Attempted to spawn explosion using a prototype that was not defined during initialization. Explosion prototype hot-reload is not currently supported.");
|
||||
return null;
|
||||
}
|
||||
var typeIndex = _explosionTypes[typeID];
|
||||
|
||||
Vector2i initialTile;
|
||||
EntityUid? epicentreGrid = null;
|
||||
@@ -103,8 +100,7 @@ public sealed partial class ExplosionSystem
|
||||
// set up the initial `gridData` instance
|
||||
encounteredGrids.Add(epicentreGrid.Value);
|
||||
|
||||
if (!_airtightMap.TryGetValue(epicentreGrid.Value, out var airtightMap))
|
||||
airtightMap = new();
|
||||
var airtightMap = CompOrNull<ExplosionAirtightGridComponent>(epicentreGrid)?.Tiles ?? new();
|
||||
|
||||
var initialGridData = new ExplosionGridTileFlood(
|
||||
(epicentreGrid.Value, Comp<MapGridComponent>(epicentreGrid.Value)),
|
||||
@@ -115,7 +111,8 @@ public sealed partial class ExplosionSystem
|
||||
_gridEdges[epicentreGrid.Value],
|
||||
referenceGrid,
|
||||
spaceMatrix,
|
||||
spaceAngle);
|
||||
spaceAngle,
|
||||
this);
|
||||
|
||||
gridData[epicentreGrid.Value] = initialGridData;
|
||||
|
||||
@@ -192,8 +189,7 @@ public sealed partial class ExplosionSystem
|
||||
// is this a new grid, for which we must create a new explosion data set
|
||||
if (!gridData.TryGetValue(grid, out var data))
|
||||
{
|
||||
if (!_airtightMap.TryGetValue(grid, out var airtightMap))
|
||||
airtightMap = new();
|
||||
var airtightMap = CompOrNull<ExplosionAirtightGridComponent>(grid)?.Tiles ?? new();
|
||||
|
||||
data = new ExplosionGridTileFlood(
|
||||
(grid, Comp<MapGridComponent>(grid)),
|
||||
@@ -204,7 +200,8 @@ public sealed partial class ExplosionSystem
|
||||
_gridEdges[grid],
|
||||
referenceGrid,
|
||||
spaceMatrix,
|
||||
spaceAngle);
|
||||
spaceAngle,
|
||||
this);
|
||||
|
||||
gridData[grid] = data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user