Skip to content

Commit

Permalink
Merge pull request #204 from InvalidArgument3/live-server-triage
Browse files Browse the repository at this point in the history
Revert "slipspace mvsp leak stop attempt #1"
  • Loading branch information
InvalidArgument3 authored Oct 27, 2024
2 parents fcd45c0 + b7d26db commit 41fc5d2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 44 deletions.
2 changes: 2 additions & 0 deletions Slipspace Engine/Data/Scripts/WarpDrive/WarpDrive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public override void Init(MyObjectBuilder_EntityBase objectBuilder)
if (WarpDriveSession.Instance != null)
initStart = WarpDriveSession.Instance.Runtime;

MyVisualScriptLogicProvider.PlayerLeftCockpit += PlayerLeftCockpit;

if (!MyAPIGateway.Utilities.IsDedicated)
Block.AppendingCustomInfo += Block_AppendingCustomInfo;

Expand Down
44 changes: 0 additions & 44 deletions Slipspace Engine/Data/Scripts/WarpDrive/WarpDriveSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -481,50 +481,6 @@ private bool HasValidSystem(WarpDrive drive)
return drive?.System != null && drive.System.Valid;
}

private void OnPlayerLeftCockpit(string entityName, long playerId, string gridName) {
// Verify that WarpDrive.Instance and other required systems are active
if (WarpDrive.Instance == null || WarpDrive.Instance.System == null)
return;

// Try parsing the entity name to get the cockpit ID
long cockpitId;
if (long.TryParse(entityName, out cockpitId)) {
var cockpit = MyAPIGateway.Entities.GetEntityById(cockpitId) as IMyShipController;
if (cockpit == null || cockpit.CubeGrid == null)
return;

// Check if the cockpit's grid has an active warp drive and is in warp state
var warpDrive = WarpDrive.Instance;
if (warpDrive.System.WarpState != WarpSystem.State.Active)
return;

// Validate that the warp drive and cockpit belong to the same grid
if (warpDrive.Block?.CubeGrid.EntityId != cockpit.CubeGrid.EntityId)
return;

// Trigger warp exit sequence
warpDrive.System.SafeTriggerON = true;

if (MyAPIGateway.Utilities.IsDedicated || MyAPIGateway.Multiplayer.IsServer) {
warpDrive.System.currentSpeedPt = -1f;
cockpit.CubeGrid?.Physics?.ClearSpeed();

warpDrive.System.Dewarp(true);
warpDrive.Block.Enabled = false;
warpDrive.BlockWasON = true;
}

warpDrive.System.SafeTriggerON = false;
}
}

public override void LoadData() {
Instance = this;

// Subscribe to PlayerLeftCockpit event
MyVisualScriptLogicProvider.PlayerLeftCockpit += OnPlayerLeftCockpit;
}

protected override void UnloadData()
{
try
Expand Down

0 comments on commit 41fc5d2

Please sign in to comment.