Skip to content

Commit

Permalink
Update PirateRadioSpawnRule.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
VMSolidus committed Nov 8, 2024
1 parent 9e85b73 commit 5d66afc
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Content.Server/StationEvents/Events/PirateRadioSpawnRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using System.Linq;
using Content.Server.GameTicking.Components;
using Content.Shared.CCVar;
using Robust.Shared.Serialization.Manager;
using Content.Shared.Parallax.Biomes;

namespace Content.Server.StationEvents.Events;

Expand All @@ -21,13 +23,26 @@ public sealed class PirateRadioSpawnRule : StationEventSystem<PirateRadioSpawnRu
[Dependency] private readonly IConfigurationManager _confMan = default!;
[Dependency] private readonly GameTicker _gameTicker = default!;
[Dependency] private readonly TransformSystem _xform = default!;
[Dependency] private readonly ISerializationManager _serializationManager = default!;

protected override void Started(EntityUid uid, PirateRadioSpawnRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
base.Started(uid, component, gameRule, args);

var stations = _gameTicker.GetSpawnableStations();
if (stations is null || stations.Count <= 0)
if (stations is null)
return;

// Remove any station from the list that is on a Planet's surface.
// We have to do this because if we spawn the listening post 1.5 kilometers from the station on a planet
// The server will then attempt to generate 7 billion entities, immediately exceeding the 32bit signed integer limit for EntityUids.
var stationsCopy = _serializationManager.CreateCopy(stations, notNullableOverride: true);
foreach (var station in stationsCopy)
if (HasComp<BiomeComponent>(Transform(station).MapUid))
stations.Remove(station);

// _random forces Test Fails if given an empty list. which is guaranteed to happen during Tests.
if (stations.Count <= 0)
return;

var targetStation = _random.Pick(stations);
Expand Down

0 comments on commit 5d66afc

Please sign in to comment.