Skip to content

Commit

Permalink
Two additional checks to prevent FTLing stations (space-wizards#32558)
Browse files Browse the repository at this point in the history
Add two additional checks to prevent FTLing
  • Loading branch information
Plykiya authored and Ilya246 committed Oct 7, 2024
1 parent 525b65f commit cabdbbb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Content.Server/Shuttles/Systems/ShuttleConsoleSystem.FTL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ private void ConsoleFTL(Entity<ShuttleConsoleComponent> ent, EntityCoordinates t
if (!TryComp(shuttleUid, out ShuttleComponent? shuttleComp))
return;

if (shuttleComp.Enabled == false)
return;

// Check shuttle can even FTL
if (!_shuttle.CanFTL(shuttleUid.Value, out var reason))
{
Expand Down
20 changes: 15 additions & 5 deletions Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,18 +225,28 @@ public void RemoveFTLDestination(EntityUid uid)
/// </summary>
public bool CanFTL(EntityUid shuttleUid, [NotNullWhen(false)] out string? reason)
{
// Currently in FTL already
if (HasComp<FTLComponent>(shuttleUid))
{
reason = Loc.GetString("shuttle-console-in-ftl");
return false;
}

if (FTLMassLimit > 0 &&
TryComp(shuttleUid, out PhysicsComponent? shuttlePhysics) &&
shuttlePhysics.Mass > FTLMassLimit)
if (TryComp<PhysicsComponent>(shuttleUid, out var shuttlePhysics))
{
reason = Loc.GetString("shuttle-console-mass");
return false;
// Static physics type is set when station anchor is enabled
if (shuttlePhysics.BodyType == BodyType.Static)
{
reason = Loc.GetString("shuttle-console-static");
return false;
}

// Too large to FTL
if (FTLMassLimit > 0 && shuttlePhysics.Mass > FTLMassLimit)
{
reason = Loc.GetString("shuttle-console-mass");
return false;
}
}

if (HasComp<PreventPilotComponent>(shuttleUid))
Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/en-US/shuttles/console.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ shuttle-pilot-end = Stopped piloting
shuttle-console-in-ftl = Currently in FTL
shuttle-console-mass = Too large to FTL
shuttle-console-prevent = You are unable to pilot this ship
shuttle-console-static = Grid is static
# NAV

Expand Down

0 comments on commit cabdbbb

Please sign in to comment.