Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.

Commit 6cdeafb

Browse files
committed
Fixes #89, blocksubtype scan commands didn't work correctly. Should fix #91. Fixes concealed grids not showing in grid scans. Fixes concealment still causing ships to move when revealed. Changed server restart behavior to fix issues with mods not getting the shutdown signal.
1 parent 2f666f9 commit 6cdeafb

File tree

6 files changed

+34
-25
lines changed

6 files changed

+34
-25
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//96
1+
//117
22
//
33
// This code was generated by a tool. Any changes made manually will be lost
44
// the next time this code is regenerated.
55
//
66

77
using System.Reflection;
88

9-
[assembly: AssemblyFileVersion("1.13.6.96")]
10-
[assembly: AssemblyVersion("1.13.6.96")]
9+
[assembly: AssemblyFileVersion("1.13.6.117")]
10+
[assembly: AssemblyVersion("1.13.6.117")]

EssentialsPlugin/EntityManagers/EntityManagement.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,11 @@ private static void ConcealEntity( IMyEntity entity )
567567

568568
pos = 6;
569569
RemovedGrids.Add( entity.EntityId );
570-
entity.InScene = false;
571-
entity.OnRemovedFromScene( entity );
572-
BaseEntityNetworkManager.BroadcastRemoveEntity( entity, false );
570+
newEntity.InScene = false;
571+
//BaseEntityNetworkManager.BroadcastRemoveEntity( entity, false );
572+
entity.Close( );
573573
MyAPIGateway.Entities.AddEntity( newEntity, false );
574-
MyMultiplayer.ReplicateImmediatelly( MyExternalReplicable.FindByObject( newEntity ) );
574+
//MyMultiplayer.ReplicateImmediatelly( MyExternalReplicable.FindByObject( newEntity ) );
575575

576576
pos = 7;
577577
if ( PluginSettings.Instance.DynamicShowMessages )
@@ -1044,15 +1044,19 @@ public static void RevealEntity( KeyValuePair<IMyEntity, string> item )
10441044
return;
10451045
}
10461046

1047+
newEntity.Physics.Enabled = false;
1048+
10471049
RemovedGrids.Add( entity.EntityId );
1048-
entity.InScene = true;
1049-
entity.OnAddedToScene( entity );
10501050
entity.Physics.Enabled = false;
10511051
entity.Close( );
1052+
1053+
Thread.Sleep( 50 );
1054+
newEntity.Physics.Enabled = true;
1055+
newEntity.InScene = true;
10521056
MyAPIGateway.Entities.AddEntity( newEntity );
10531057
//MyMultiplayer.ReplicateImmediatelly( MyExternalReplicable.FindByObject( newEntity ) );
1054-
entity.Physics.LinearVelocity = Vector3.Zero;
1055-
entity.Physics.AngularVelocity = Vector3.Zero;
1058+
newEntity.Physics.LinearVelocity = Vector3.Zero;
1059+
newEntity.Physics.AngularVelocity = Vector3.Zero;
10561060

10571061
if ( PluginSettings.Instance.DynamicShowMessages )
10581062
Essentials.Log.Info( "Revealed - Id: {0} -> {4} Display: {1} OwnerId: {2} OwnerName: {3} Reason: {5}",

EssentialsPlugin/ProcessHandlers/ProcessRestart.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ public override void Handle()
9494

9595
private void DoRestart()
9696
{
97+
// Tell SE to shut down
98+
Wrapper.GameAction( ()=>MySandboxGame.Static.Exit( ) );
99+
Thread.Sleep( 15000 );
97100
// If we're not a service, restart with a .bat otherwise just exit and let the service be restarted
98101
if (Environment.UserInteractive)
99102
{

EssentialsPlugin/Utility/CubeGrid.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -772,22 +772,24 @@ public static HashSet<GridGroup> ScanGrids( ulong userId, string[] words )
772772
if ( !quiet )
773773
Communication.SendPrivateInformation( userId,
774774
$"Scanning for ships with options: {GetOptionsText( options )}" );
775-
776-
HashSet<GridGroup> groupsToConfirm = new HashSet<GridGroup>( );
775+
777776
HashSet<GridGroup> groups = GridGroup.GetAllGroups( connectionType );
778777
HashSet<GridGroup> groupsFound = new HashSet<GridGroup>( );
779778
List<Task> scanTasks = new List<Task>();
780779

781780
/*
782-
* invert scan logic here
783-
* if we find a group that fails any of the checks, break
784-
* everything else implicitly goes into the found list
781+
* Invert scan logic here.
782+
* If we find a group that fails any of the checks, break.
783+
* Everything else implicitly goes into the found list.
785784
*
786-
* on large servers this can run into the tens of seconds,
787-
* so parallelize it
785+
* On large servers this can run into the tens of seconds,
786+
* so parallelize it.
788787
*/
789788
foreach ( GridGroup group in groups )
790789
{
790+
if ( group?.Parent == null )
791+
continue;
792+
791793
scanTasks.Add( Task.Run( ( ) =>
792794
{
793795
if ( power == StateEnum.RequiresYes && !DoesGroupHavePowerSupply( group ) )
@@ -836,14 +838,14 @@ public static HashSet<GridGroup> ScanGrids( ulong userId, string[] words )
836838
if ( hasBlockSubType && !blockSubTypes.Any( x => DoesGroupHaveBlockSubtype( group, x.Key, x.Value ) ) )
837839
return;
838840

839-
if ( excludesBlockType && blockSubTypes.Any( x => DoesGroupHaveBlockType( group, x.Key, x.Value + 1 ) ) )
841+
if ( excludesBlockType && blockSubTypes.Any( x => DoesGroupHaveBlockType( group, x.Key, x.Value ) ) )
840842
return;
841843

842844
if ( includesBlockType && !blockTypes.Any( x => DoesGroupHaveBlockType( group, x.Key, x.Value ) ) )
843845
return;
844846

845847
if ( hasBlockSubTypeLimits &&
846-
!blockSubTypes.Any( x => DoesGroupHaveBlockSubtype( group, x.Key, x.Value + 1 ) ) )
848+
!blockSubTypes.Any( x => DoesGroupHaveBlockSubtype( group, x.Key, x.Value ) ) )
847849
return;
848850

849851
lock ( groupsFound )
@@ -859,7 +861,7 @@ public static HashSet<GridGroup> ScanGrids( ulong userId, string[] words )
859861
foreach (GridGroup group in groupsFound)
860862
{
861863
if (!quiet)
862-
Communication.SendPrivateInformation( userId, $"Found group with parent {group.Parent.DisplayName}, owner {group.Parent.GetOwner( )}" );
864+
Communication.SendPrivateInformation( userId, $"Found group with parent {group.Parent.DisplayName}, owner: {group.Parent.GetOwner( ) ?? "none"}" );
863865

864866
gridCount += group.Grids.Count;
865867
}

EssentialsPlugin/Utility/Extensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static string GetOwner( this IMyCubeGrid grid )
3434
if (ownerIdentity != null)
3535
return ownerIdentity.DisplayName;
3636
}
37-
return "";
37+
return null;
3838
}
3939

4040
public static string GetOwner( this MyCubeGrid grid )

EssentialsPlugin/Utility/GridGroup.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ public GridGroup( MyCubeGrid grid, GridLinkTypeEnum linkType = GridLinkTypeEnum.
8585
//use the old method to filter out grids with pisons or rotors, for safety
8686
HashSet<IMyEntity> thisEntity = new HashSet<IMyEntity>();
8787
HashSet<IMyEntity> returnSet = new HashSet<IMyEntity>();
88-
thisEntity.Add( grid );
89-
CubeGrids.GetGridsUnconnected( thisEntity, returnSet );
88+
thisEntity.Add( (IMyEntity)grid );
89+
CubeGrids.GetGridsUnconnected( returnSet, thisEntity );
9090

91-
if ( returnSet.Count != 0 )
91+
if ( returnSet.Count > 0 )
9292
_grids.Add( (MyCubeGrid)returnSet.First( ) );
9393
else
9494
return;

0 commit comments

Comments
 (0)