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

Commit 760dfb0

Browse files
committed
Hotfix for broken concealment and crash in grid scan
1 parent d0a4943 commit 760dfb0

File tree

7 files changed

+210
-83
lines changed

7 files changed

+210
-83
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//1
1+
//18
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.1")]
10-
[assembly: AssemblyVersion("1.13.6.1")]
9+
[assembly: AssemblyFileVersion("1.13.6.18")]
10+
[assembly: AssemblyVersion("1.13.6.18")]

EssentialsPlugin/ChatHandlers/AdminConceal/HandleAdminConceal.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@ public override bool HandleCommand(ulong userId, string[] words)
145145
Communication.SendPrivateInformation(userId, string.Format("Total unconnected revealed entities: {0}", count));
146146

147147
Communication.SendPrivateInformation(userId, "==== Connected Entities ===");
148-
var groups = CubeGrids.GetGroups( GridLinkTypeEnum.Logical );
148+
var groups = GridGroup.GetAllGroups( GridLinkTypeEnum.Logical );
149149
//Console.WriteLine("Here: {0} : {1} {2}", connectedFound.Intersect(entitiesFound).Count(), entitiesFound.Count, connectedFound.Count);
150150
count = 0;
151151

152152
foreach ( var group in groups )
153153
{
154-
foreach ( MyCubeGrid grid in group )
154+
foreach ( MyCubeGrid grid in group.Grids )
155155
{
156156
MyEntity entity = (MyEntity)grid;
157157

@@ -161,7 +161,7 @@ public override bool HandleCommand(ulong userId, string[] words)
161161
if ( !entity.InScene )
162162
continue;
163163

164-
if ( group.Count < 2 )
164+
if ( group.Grids.Count < 2 )
165165
continue;
166166

167167
long ownerId = 0;
@@ -175,7 +175,7 @@ public override bool HandleCommand(ulong userId, string[] words)
175175
if ( ownerName == "" )
176176
ownerName = "No one";
177177

178-
Communication.SendPrivateInformation( userId, $"Id: {entity.EntityId} Display: {entity.DisplayName} OwnerId: {ownerId} OwnerName: {ownerName} Position: {grid.PositionComp.GetPosition( )} BlockCount: {grid.BlocksCount} Connections: {@group.Count}" );
178+
Communication.SendPrivateInformation( userId, $"Id: {entity.EntityId} Display: {entity.DisplayName} OwnerId: {ownerId} OwnerName: {ownerName} Position: {grid.PositionComp.GetPosition( )} BlockCount: {grid.BlocksCount} Connections: {@group.Grids.Count}" );
179179
//Communication.SendPrivateInformation(userId, string.Format("Id: {0} Display: {1} OwnerId: {2} OwnerName: {3} Position: {4} BlockCount: {5} Connections: {6}", entity.EntityId, entity.DisplayName, ownerId, ownerName, General.Vector3DToString(entity.GetPosition()), slimBlocks.Count));
180180
count++;
181181
}

EssentialsPlugin/ChatHandlers/Utility/HandleUtilityGridsList.cs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ public override string GetCommandText()
2525
return "/utility grids list";
2626
}
2727

28-
public override Communication.ServerDialogItem GetHelpDialog( )
29-
{
30-
Communication.ServerDialogItem DialogItem = new Communication.ServerDialogItem( );
31-
DialogItem.title = "Help";
32-
DialogItem.header = "";
33-
DialogItem.content = GetHelp( );
34-
DialogItem.buttonText = "close";
35-
return DialogItem;
36-
}
37-
3828
public override bool IsAdminCommand()
3929
{
4030
return false;
@@ -74,8 +64,8 @@ public override bool HandleCommand(ulong userId, string[] words)
7464
Wrapper.GameAction(() =>
7565
{
7666
MyAPIGateway.Entities.GetEntities(entities, x => x is IMyCubeGrid);
77-
MyAPIGateway.Players.GetPlayers(players);
7867
});
68+
MyAPIGateway.Players.GetPlayers(players);
7969

8070
IMyPlayer player = players.FirstOrDefault(x => x.SteamUserId == userId);
8171

@@ -95,8 +85,8 @@ public override bool HandleCommand(ulong userId, string[] words)
9585

9686
if(CubeGrids.IsFullOwner(grid, playerId, player) && !dialog)
9787
result += string.Format("Grid '{0}' at {2}", grid.DisplayName, grid.EntityId, ShowCoordinates(entity.GetPosition()));
98-
//else if (CubeGrids.IsFullOwner(grid, playerId, player) && dialog)
99-
//result += string.Format("{0} - {1} - {2}bl - {3}", grid.DisplayName, ShowCoordinates(entity.GetPosition()), gridBuilder.CubeBlocks.Count, gridBuilder.GridSizeEnum);
88+
else if (CubeGrids.IsFullOwner(grid, playerId, player) && dialog)
89+
result += string.Format("{0} - {1} - {2}bl - {3}", grid.DisplayName, ShowCoordinates(entity.GetPosition()), grid.CubeBlocks.Count, grid.GridSizeEnum);
10090
else
10191
result += string.Format("Grid '{0}'", grid.DisplayName, grid.EntityId);
10292

EssentialsPlugin/EntityManagers/EntityManagement.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public static void CheckAndConcealEntities( )
168168
}
169169

170170
DateTime getGridsStart = DateTime.Now;
171-
//CubeGrids.GetGridsUnconnected( entitiesFound, entitiesFiltered );
171+
CubeGrids.GetGridsUnconnected( entitiesFound, entitiesFiltered );
172172
getGrids += ( DateTime.Now - getGridsStart ).TotalMilliseconds;
173173

174174
HashSet<IMyEntity> entitiesToConceal = new HashSet<IMyEntity>( );
@@ -485,7 +485,10 @@ private static void ConcealEntity( IMyEntity entity )
485485
int pos = 0;
486486
//RemovedGrids.Clear( );
487487
try
488-
{
488+
{
489+
if ( entity?.Physics == null )
490+
return;
491+
489492
if ( !entity.InScene )
490493
return;
491494

@@ -496,7 +499,8 @@ private static void ConcealEntity( IMyEntity entity )
496499
pos = 1;
497500
long ownerId = grid.BigOwners.FirstOrDefault( );
498501
string ownerName = string.Empty;
499-
502+
if ( ownerId > 0 )
503+
{
500504
ownerName = PlayerMap.Instance.GetPlayerItemFromPlayerId( ownerId ).Name;
501505

502506
if ( !PluginSettings.Instance.DynamicConcealPirates )
@@ -508,7 +512,7 @@ private static void ConcealEntity( IMyEntity entity )
508512
return;
509513
}
510514
}
511-
515+
}
512516
Essentials.Log.Info( grid.EntityId.ToString() + " " + ownerId.ToString() + " " + ownerName );
513517

514518
pos = 2;
@@ -584,7 +588,7 @@ private static void ConcealEntity( IMyEntity entity )
584588
}
585589
catch ( Exception ex )
586590
{
587-
Essentials.Log.Error( "Failure while concealing entity {0}.", pos, ex );
591+
Essentials.Log.Error( ex, $"Failure while concealing entity {pos}." );
588592
}
589593
}
590594

@@ -1158,7 +1162,7 @@ public static bool ToggleMedbayGrids( ulong steamId )
11581162
return false;
11591163
}
11601164

1161-
//.GetGridsUnconnected( entitiesFound, entities );
1165+
CubeGrids.GetGridsUnconnected( entitiesFound, entities );
11621166

11631167
HashSet<IMyEntity> entitiesToConceal = new HashSet<IMyEntity>( );
11641168
FilterEntitiesForMedbayCheck( steamId, entitiesFound, entitiesToConceal );

EssentialsPlugin/ProcessHandlers/ProcessConceal.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ public override int GetUpdateResolution()
3030
{
3131
int updateSpeed = PluginSettings.Instance.DynamicConcealUpdateSpeed;
3232

33-
if ( updateSpeed < 1000 )
33+
if ( updateSpeed < 100 )
3434
return updateSpeed;
3535
else
36-
return 1000;
36+
return 100;
3737
}
3838

3939
public override void Handle()
@@ -43,7 +43,7 @@ public override void Handle()
4343
//force reveal bypasses the plugin setting. useful to recover grids after you turn it off
4444
if ( ForceReveal && DateTime.Now - m_lastConcealProcess > TimeSpan.FromMilliseconds( updateSpeed ) )
4545
{
46-
//Essentials.Log.Info( "Process force reveal" );
46+
Essentials.Log.Info( "Process force reveal" );
4747
EntityManagement.ProcessConcealment( true );
4848
m_lastConcealProcess = DateTime.Now;
4949
}
@@ -53,21 +53,21 @@ public override void Handle()
5353

5454
if (DateTime.Now - m_lastConcealCheck > TimeSpan.FromSeconds(30))
5555
{
56-
//Essentials.Log.Info("CheckAndConcealEntities");
56+
Essentials.Log.Info("CheckAndConcealEntities");
5757
EntityManagement.CheckAndConcealEntities();
5858
m_lastConcealCheck = DateTime.Now;
5959
}
6060

6161
if (DateTime.Now - m_lastRevealCheck > TimeSpan.FromSeconds(5))
6262
{
63-
//Essentials.Log.Info("CheckAndRevealEntities");
63+
Essentials.Log.Info("CheckAndRevealEntities");
6464
EntityManagement.CheckAndRevealEntities();
6565
m_lastRevealCheck = DateTime.Now;
6666
}
6767

6868
if ( DateTime.Now - m_lastConcealProcess > TimeSpan.FromMilliseconds( updateSpeed ) )
6969
{
70-
//Essentials.Log.Info( "Process concealment" );
70+
Essentials.Log.Info( "Process concealment" );
7171
EntityManagement.ProcessConcealment( );
7272
m_lastConcealProcess = DateTime.Now;
7373
}

0 commit comments

Comments
 (0)