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

Commit

Permalink
Hotfix for broken concealment and crash in grid scan
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxar-tc committed Apr 15, 2016
1 parent d0a4943 commit 760dfb0
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 83 deletions.
6 changes: 3 additions & 3 deletions EssentialsPlugin/AssemblyFileVersion.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//1
//18
//
// This code was generated by a tool. Any changes made manually will be lost
// the next time this code is regenerated.
//

using System.Reflection;

[assembly: AssemblyFileVersion("1.13.6.1")]
[assembly: AssemblyVersion("1.13.6.1")]
[assembly: AssemblyFileVersion("1.13.6.18")]
[assembly: AssemblyVersion("1.13.6.18")]
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ public override bool HandleCommand(ulong userId, string[] words)
Communication.SendPrivateInformation(userId, string.Format("Total unconnected revealed entities: {0}", count));

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

foreach ( var group in groups )
{
foreach ( MyCubeGrid grid in group )
foreach ( MyCubeGrid grid in group.Grids )
{
MyEntity entity = (MyEntity)grid;

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

if ( group.Count < 2 )
if ( group.Grids.Count < 2 )
continue;

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

Communication.SendPrivateInformation( userId, $"Id: {entity.EntityId} Display: {entity.DisplayName} OwnerId: {ownerId} OwnerName: {ownerName} Position: {grid.PositionComp.GetPosition( )} BlockCount: {grid.BlocksCount} Connections: {@group.Count}" );
Communication.SendPrivateInformation( userId, $"Id: {entity.EntityId} Display: {entity.DisplayName} OwnerId: {ownerId} OwnerName: {ownerName} Position: {grid.PositionComp.GetPosition( )} BlockCount: {grid.BlocksCount} Connections: {@group.Grids.Count}" );
//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));
count++;
}
Expand Down
16 changes: 3 additions & 13 deletions EssentialsPlugin/ChatHandlers/Utility/HandleUtilityGridsList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ public override string GetCommandText()
return "/utility grids list";
}

public override Communication.ServerDialogItem GetHelpDialog( )
{
Communication.ServerDialogItem DialogItem = new Communication.ServerDialogItem( );
DialogItem.title = "Help";
DialogItem.header = "";
DialogItem.content = GetHelp( );
DialogItem.buttonText = "close";
return DialogItem;
}

public override bool IsAdminCommand()
{
return false;
Expand Down Expand Up @@ -74,8 +64,8 @@ public override bool HandleCommand(ulong userId, string[] words)
Wrapper.GameAction(() =>
{
MyAPIGateway.Entities.GetEntities(entities, x => x is IMyCubeGrid);
MyAPIGateway.Players.GetPlayers(players);
});
MyAPIGateway.Players.GetPlayers(players);

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

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

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

Expand Down
16 changes: 10 additions & 6 deletions EssentialsPlugin/EntityManagers/EntityManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public static void CheckAndConcealEntities( )
}

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

HashSet<IMyEntity> entitiesToConceal = new HashSet<IMyEntity>( );
Expand Down Expand Up @@ -485,7 +485,10 @@ private static void ConcealEntity( IMyEntity entity )
int pos = 0;
//RemovedGrids.Clear( );
try
{
{
if ( entity?.Physics == null )
return;

if ( !entity.InScene )
return;

Expand All @@ -496,7 +499,8 @@ private static void ConcealEntity( IMyEntity entity )
pos = 1;
long ownerId = grid.BigOwners.FirstOrDefault( );
string ownerName = string.Empty;

if ( ownerId > 0 )
{
ownerName = PlayerMap.Instance.GetPlayerItemFromPlayerId( ownerId ).Name;

if ( !PluginSettings.Instance.DynamicConcealPirates )
Expand All @@ -508,7 +512,7 @@ private static void ConcealEntity( IMyEntity entity )
return;
}
}

}
Essentials.Log.Info( grid.EntityId.ToString() + " " + ownerId.ToString() + " " + ownerName );

pos = 2;
Expand Down Expand Up @@ -584,7 +588,7 @@ private static void ConcealEntity( IMyEntity entity )
}
catch ( Exception ex )
{
Essentials.Log.Error( "Failure while concealing entity {0}.", pos, ex );
Essentials.Log.Error( ex, $"Failure while concealing entity {pos}." );
}
}

Expand Down Expand Up @@ -1158,7 +1162,7 @@ public static bool ToggleMedbayGrids( ulong steamId )
return false;
}

//.GetGridsUnconnected( entitiesFound, entities );
CubeGrids.GetGridsUnconnected( entitiesFound, entities );

HashSet<IMyEntity> entitiesToConceal = new HashSet<IMyEntity>( );
FilterEntitiesForMedbayCheck( steamId, entitiesFound, entitiesToConceal );
Expand Down
12 changes: 6 additions & 6 deletions EssentialsPlugin/ProcessHandlers/ProcessConceal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public override int GetUpdateResolution()
{
int updateSpeed = PluginSettings.Instance.DynamicConcealUpdateSpeed;

if ( updateSpeed < 1000 )
if ( updateSpeed < 100 )
return updateSpeed;
else
return 1000;
return 100;
}

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

if (DateTime.Now - m_lastConcealCheck > TimeSpan.FromSeconds(30))
{
//Essentials.Log.Info("CheckAndConcealEntities");
Essentials.Log.Info("CheckAndConcealEntities");
EntityManagement.CheckAndConcealEntities();
m_lastConcealCheck = DateTime.Now;
}

if (DateTime.Now - m_lastRevealCheck > TimeSpan.FromSeconds(5))
{
//Essentials.Log.Info("CheckAndRevealEntities");
Essentials.Log.Info("CheckAndRevealEntities");
EntityManagement.CheckAndRevealEntities();
m_lastRevealCheck = DateTime.Now;
}

if ( DateTime.Now - m_lastConcealProcess > TimeSpan.FromMilliseconds( updateSpeed ) )
{
//Essentials.Log.Info( "Process concealment" );
Essentials.Log.Info( "Process concealment" );
EntityManagement.ProcessConcealment( );
m_lastConcealProcess = DateTime.Now;
}
Expand Down
Loading

0 comments on commit 760dfb0

Please sign in to comment.