Skip to content

Commit

Permalink
Merge pull request #154 from InvalidArgument3/initialversion
Browse files Browse the repository at this point in the history
hnng
  • Loading branch information
InvalidArgument3 authored Oct 19, 2024
2 parents dd40264 + 2e265c8 commit 9e240d0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Slipspace Engine/Data/Scripts/WarpDrive/WarpSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,6 @@ private List<IMyFunctionalBlock> GetActiveWarpDrives()

public void Dewarp(bool Collision = false)
{

// Check if we've been in warp for more than 1 minute (assuming 60 updates per second)
if (WarpState == State.Active &&
grid?.MainGrid != null &&
Expand All @@ -1343,8 +1342,8 @@ public void Dewarp(bool Collision = false)
? MyColorPickerConstants.HSVOffsetToHSV(faction.CustomColor).HSVtoColor()
: Color.Black; // Default color if no faction

// Ensure this is only run on the server (dedicated or host) to avoid multiple executions
if (!(MyAPIGateway.Multiplayer.IsServer || MyAPIGateway.Utilities.IsDedicated))
// Server-only block for adding GPS
if (MyAPIGateway.Multiplayer.IsServer || MyAPIGateway.Utilities.IsDedicated)
{
// Only the server or dedicated server adds the GPS marker once, visible to all players
MyVisualScriptLogicProvider.AddGPSForAll(
Expand All @@ -1353,10 +1352,10 @@ public void Dewarp(bool Collision = false)
exitPosition,
gpsColor,
30);
};
}
}


// The rest of Dewarp() executes on both client and server to maintain synchronization

if (PlayersInWarpList.Count > 0)
{
Expand All @@ -1378,6 +1377,7 @@ public void Dewarp(bool Collision = false)
var MainGrid = grid.MainGrid;
var WarpDriveOnGrid = GetActiveWarpDrive(MainGrid);

// Sending network message to other players for warp state changes
if (WarpDriveOnGrid != null && WarpState == State.Active && (MyAPIGateway.Multiplayer.IsServer || MyAPIGateway.Utilities.IsDedicated))
{
if (WarpDriveOnGrid != null)
Expand Down

0 comments on commit 9e240d0

Please sign in to comment.