From: Partmedia Date: Wed, 4 Dec 2024 02:42:16 +0000 (-0800) Subject: Fix sinks and toilets not draining (#33691) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=cf202e805dd998f5e1f0865000f02bdf029812f7;p=space-station-14.git Fix sinks and toilets not draining (#33691) * Fix AutoDrain Per the system comments, AutoDrain is designed to automatically move puddles into the drain (like a floor drain). Drains without AutoDrain are still supposed to gradually empty the buffer, but not remove puddles (like sinks and toilets). However, a logic error in the original implementation causes drains with AutoDrain set to false to simply not work. Hence sinks never emptied. * Update documentation --- diff --git a/Content.Server/Fluids/EntitySystems/DrainSystem.cs b/Content.Server/Fluids/EntitySystems/DrainSystem.cs index 69d15b8d00..215c58804e 100644 --- a/Content.Server/Fluids/EntitySystems/DrainSystem.cs +++ b/Content.Server/Fluids/EntitySystems/DrainSystem.cs @@ -134,13 +134,6 @@ public sealed class DrainSystem : SharedDrainSystem } drain.Accumulator -= drain.DrainFrequency; - // Disable ambient sound from emptying manually - if (!drain.AutoDrain) - { - _ambientSoundSystem.SetAmbience(uid, false); - continue; - } - if (!managerQuery.TryGetComponent(uid, out var manager)) continue; @@ -160,41 +153,44 @@ public sealed class DrainSystem : SharedDrainSystem // This will ensure that UnitsPerSecond is per second... var amount = drain.UnitsPerSecond * drain.DrainFrequency; - _puddles.Clear(); - _lookup.GetEntitiesInRange(Transform(uid).Coordinates, drain.Range, _puddles); - - if (_puddles.Count == 0) + if (drain.AutoDrain) { - _ambientSoundSystem.SetAmbience(uid, false); - continue; - } + _puddles.Clear(); + _lookup.GetEntitiesInRange(Transform(uid).Coordinates, drain.Range, _puddles); - _ambientSoundSystem.SetAmbience(uid, true); - - amount /= _puddles.Count; - - foreach (var puddle in _puddles) - { - // Queue the solution deletion if it's empty. EvaporationSystem might also do this - // but queuedelete should be pretty safe. - if (!_solutionContainerSystem.ResolveSolution(puddle.Owner, puddle.Comp.SolutionName, ref puddle.Comp.Solution, out var puddleSolution)) + if (_puddles.Count == 0) { - EntityManager.QueueDeleteEntity(puddle); + _ambientSoundSystem.SetAmbience(uid, false); continue; } - // Removes the lowest of: - // the drain component's units per second adjusted for # of puddles - // the puddle's remaining volume (making it cleanly zero) - // the drain's remaining volume in its buffer. - var transferSolution = _solutionContainerSystem.SplitSolution(puddle.Comp.Solution.Value, - FixedPoint2.Min(FixedPoint2.New(amount), puddleSolution.Volume, drainSolution.AvailableVolume)); + _ambientSoundSystem.SetAmbience(uid, true); - drainSolution.AddSolution(transferSolution, _prototypeManager); + amount /= _puddles.Count; - if (puddleSolution.Volume <= 0) + foreach (var puddle in _puddles) { - QueueDel(puddle); + // Queue the solution deletion if it's empty. EvaporationSystem might also do this + // but queuedelete should be pretty safe. + if (!_solutionContainerSystem.ResolveSolution(puddle.Owner, puddle.Comp.SolutionName, ref puddle.Comp.Solution, out var puddleSolution)) + { + EntityManager.QueueDeleteEntity(puddle); + continue; + } + + // Removes the lowest of: + // the drain component's units per second adjusted for # of puddles + // the puddle's remaining volume (making it cleanly zero) + // the drain's remaining volume in its buffer. + var transferSolution = _solutionContainerSystem.SplitSolution(puddle.Comp.Solution.Value, + FixedPoint2.Min(FixedPoint2.New(amount), puddleSolution.Volume, drainSolution.AvailableVolume)); + + drainSolution.AddSolution(transferSolution, _prototypeManager); + + if (puddleSolution.Volume <= 0) + { + QueueDel(puddle); + } } } diff --git a/Content.Shared/Fluids/Components/DrainComponent.cs b/Content.Shared/Fluids/Components/DrainComponent.cs index 3064721bf3..ef0277d214 100644 --- a/Content.Shared/Fluids/Components/DrainComponent.cs +++ b/Content.Shared/Fluids/Components/DrainComponent.cs @@ -27,8 +27,8 @@ public sealed partial class DrainComponent : Component public float Accumulator = 0f; /// - /// Does this drain automatically absorb surrouding puddles? Or is it a drain designed to empty - /// solutions in it manually? + /// If true, automatically transfers solutions from nearby puddles and drains them. True for floor drains; + /// false for things like toilets and sinks. /// [DataField] public bool AutoDrain = true;