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

Commit 4310910

Browse files
committed
Fixes MOTD not showing if the GreetingMessage field is empty. Remove leftover debug logging from player block enforcement. Improvements to concealment.
1 parent f278876 commit 4310910

File tree

6 files changed

+166
-217
lines changed

6 files changed

+166
-217
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//4
1+
//5
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.7.4")]
10-
[assembly: AssemblyVersion("1.13.7.4")]
9+
[assembly: AssemblyFileVersion("1.13.7.5")]
10+
[assembly: AssemblyVersion("1.13.7.5")]

EssentialsPlugin/EntityManagers/EntityManagement.cs

Lines changed: 35 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.Collections.Generic;
55
using System.Linq;
6+
using System.Runtime.Remoting;
67
using System.Threading;
78
using EssentialsPlugin.ProcessHandlers;
89
using EssentialsPlugin.Utility;
@@ -42,8 +43,6 @@ public static void CheckAndConcealEntities( )
4243
try
4344
{
4445
List<MyPlayer> players;
45-
HashSet<MyEntity> entities;
46-
HashSet<MyEntity> entitiesFiltered = new HashSet<MyEntity>( );
4746

4847
try
4948
{
@@ -54,39 +53,18 @@ public static void CheckAndConcealEntities( )
5453
Essentials.Log.Error( ex, "Error getting players list. Check and Conceal failed: {0}");
5554
return;
5655
}
57-
58-
try
59-
{
60-
entities = MyEntities.GetEntities();
61-
}
62-
catch ( Exception ex )
63-
{
64-
Essentials.Log.Error( ex, "Error getting entity list, skipping check" );
65-
return;
66-
}
67-
68-
foreach (MyEntity entity in entities )
69-
{
70-
if ( !( entity is MyCubeGrid ) )
71-
continue;
72-
73-
if ( UnregisteredEntities.Contains( entity ) )
74-
continue;
75-
76-
entitiesFiltered.Add( entity );
77-
}
7856

79-
var groups = GridGroup.GetGroups( entitiesFiltered, GridLinkTypeEnum.Physical );
80-
81-
foreach ( GridGroup group in groups )
57+
foreach ( GridGroup group in GridGroup.GetAllGroups( GridLinkTypeEnum.Logical ) )
8258
{
59+
//we're using grid groups so that multi-part pirate ships don't lose pieces
8360
if(PluginSettings.Instance.DynamicConcealPirates)
8461
{
8562
if ( group.Parent.GetOwner() == "Space Pirates" )
8663
{
8764
if (PluginSettings.Instance.DynamicShowMessages)
8865
Essentials.Log.Info( $"Not concealing pirate owned grid {group.Parent.EntityId} -> {group.Parent.DisplayName}.");
89-
continue;}
66+
continue;
67+
}
9068
}
9169
foreach ( MyCubeGrid grid in group.Grids )
9270
{
@@ -98,21 +76,21 @@ public static void CheckAndConcealEntities( )
9876
if ( grid.IsStatic && !PluginSettings.Instance.ConcealIncludeStations )
9977
continue;
10078
if ( !PluginSettings.Instance.ConcealIncludeLargeGrids )
101-
continue;
102-
}
79+
continue;
80+
}
10381

10482
if ( players.Any( x => Vector3D.Distance( x.GetPosition(), grid.PositionComp.GetPosition() ) < PluginSettings.Instance.DynamicConcealDistance ) )
105-
continue;
83+
continue;
10684

107-
if ( ProcessDockingZone.ZoneCache.Any( x => Vector3D.Distance( x.GetPosition(), grid.PositionComp.GetPosition() ) < 100d ) )
108-
continue;
85+
if ( ProcessDockingZone.ZoneCache.Any( x => Vector3D.Distance( x.GetPosition(), grid.PositionComp.GetPosition() ) < 100 ) )
86+
continue;
10987

11088
if ( CheckConcealBlockRules( grid ) )
11189
continue;
11290

11391
ConcealEntity( grid );
11492
}
115-
}
93+
}
11694
}
11795
catch ( Exception ex )
11896
{
@@ -137,12 +115,13 @@ private static bool CheckConcealBlockRules( MyCubeGrid grid )
137115
var beacon = cubeBlock as IMyBeacon;
138116
if ( beacon != null)
139117
{
140-
beaconCount++;
118+
//beaconCount++;
141119
// Keep this return here, as 4 beacons always means true
142-
if ( beaconCount >= 4 )
143-
{
144-
return true;
145-
}
120+
//DON'T TELL ME WHAT TO DO
121+
//if ( beaconCount >= 4 )
122+
//{
123+
// return true;
124+
//}
146125

147126
if ( !beacon.Enabled )
148127
continue;
@@ -185,21 +164,18 @@ private static bool CheckConcealBlockRules( MyCubeGrid grid )
185164
return true;
186165
}
187166
}
188-
189-
//TODO
190-
/*
167+
191168
var cryo = cubeBlock as MyCryoChamber;
192169
if ( cryo?.Pilot != null )
193170
return true;
194-
*/
195171

196172
var production = cubeBlock as IMyProductionBlock;
197-
if ( production != null )
173+
if ( production != null && PluginSettings.Instance.DynamicConcealProduction )
198174
{
199175
if ( !production.Enabled )
200176
continue;
201177

202-
if ( production.IsProducing )
178+
if ( !production.IsQueueEmpty )
203179
return true;
204180
}
205181

@@ -459,7 +435,7 @@ private static bool CheckRevealBlockRules( MyCubeGrid grid, out string reason )
459435

460436
if ( medical.HasPlayerAccess( playerId ) )
461437
{
462-
reason = $"Grid has medbay and player is factionshare - playerid: {playerId}";
438+
reason = $"Grid has medbay and player has access - playerid: {playerId}";
463439
return true;
464440
}
465441
}
@@ -473,50 +449,26 @@ private static bool CheckRevealBlockRules( MyCubeGrid grid, out string reason )
473449
}
474450

475451
var cryo = cubeBlock as MyCryoChamber;
476-
if ( cryo != null )
477-
{
478-
if ( cryo.Pilot == null )
479-
continue;
480-
481-
if ( !cryo.IsFunctional )
482-
continue;
483-
484-
if ( PluginSettings.Instance.DynamicConcealIncludeMedBays )
485-
{
486-
lock ( Online )
487-
{
488-
foreach ( ulong connectedPlayer in Online )
489-
{
490-
long playerId = PlayerMap.Instance.GetFastPlayerIdFromSteamId( connectedPlayer );
452+
if ( cryo != null )
453+
{
454+
if ( cryo.Pilot == null )
455+
continue;
491456

492-
if (cryo.Pilot.GetPlayerIdentityId() == playerId )
493-
{
494-
reason = $"Grid has cryopod and player is inside - playerid: {playerId}";
495-
return true;
496-
}
457+
if ( !cryo.IsFunctional )
458+
continue;
497459

498-
if ( cryo.HasPlayerAccess( playerId ) )
499-
{
500-
reason = $"Grid has cryopod and player can use - playerid: {playerId}";
501-
return true;
502-
}
503-
}
504-
}
505-
}
506-
else
507-
{
508-
reason = "Grid has cryopod and conceal can not include cryopods";
509-
return true;
510-
}
511-
}
460+
reason = $"Grid has cryopod and player is inside - player: {cryo.Pilot.DisplayName}";
461+
return true;
462+
}
512463

464+
//don't check conceal settings for production blocks, we always want them to reveal
513465
var production = cubeBlock as MyProductionBlock;
514466
if ( production != null )
515467
{
516468
if ( !production.Enabled )
517469
continue;
518470

519-
if ( production.Queue.Any() )
471+
if ( !production.IsQueueEmpty )
520472
{
521473
reason = "Grid has production facility that has a queue";
522474
return true;
@@ -657,6 +609,9 @@ private static void UnregisterHierarchy( MyEntity entity )
657609
if ( entity.Hierarchy == null )
658610
return;
659611

612+
if ( UnregisteredEntities.Contains( entity ) )
613+
return;
614+
660615
foreach ( var child in entity.Hierarchy.Children )
661616
{
662617
MyEntity childEntity = (MyEntity)child.Container.Entity;

EssentialsPlugin/Essentials.cs

Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ public string[ ] DynamicConcealIgnoreSubTypeList
712712

713713
[Category( "Dynamic Entity Management" )]
714714
[DisplayName( "Include MedBays" )]
715-
[Description( "The list of subtype blocks that will make the entity manager ignore a grid. If a grid contains any of these block subtypes, it will automatically not include it when deciding whether to conceal the grid or not" )]
715+
[Description( "If any online player has access to a working medbay on a grid, it will be ignored." )]
716716
[Browsable( true )]
717717
[ReadOnly( false )]
718718
public bool DynamicConcealIncludeMedBays
@@ -721,47 +721,18 @@ public bool DynamicConcealIncludeMedBays
721721
set { PluginSettings.Instance.DynamicConcealIncludeMedBays = value; }
722722
}
723723

724-
/* Experiments not working yet */
725-
/*
726-
[Category("Dynamic Entity Management")]
727-
[Description("")]
728-
[Browsable(true)]
729-
[ReadOnly(false)]
730-
public bool DynamicConcealServerOnly
731-
{
732-
get { return PluginSettings.Instance.DynamicConcealServerOnly; }
733-
set
734-
{
735-
PluginSettings.Instance.DynamicConcealServerOnly = value;
736-
}
737-
}
738724

739-
[Category("Dynamic Entity Management")]
740-
[Description("")]
741-
[Browsable(true)]
742-
[ReadOnly(false)]
743-
public bool DynamicClientConcealEnabled
744-
{
745-
get { return PluginSettings.Instance.DynamicClientConcealEnabled; }
746-
set
747-
{
748-
PluginSettings.Instance.DynamicClientConcealEnabled = value;
749-
}
750-
}
751-
752-
[Category("Dynamic Entity Management")]
753-
[Description("")]
754-
[Browsable(true)]
755-
[ReadOnly(false)]
756-
public float DynamicClientConcealDistance
757-
{
758-
get { return PluginSettings.Instance.DynamicClientConcealDistance; }
759-
set
760-
{
761-
PluginSettings.Instance.DynamicClientConcealDistance = value;
762-
}
763-
}
764-
/**/
725+
[Category("Dynamic Entity Management")]
726+
[DisplayName("Include Active Production")]
727+
[Description("Ships with active production blocks will be concealed.")]
728+
[Browsable(true)]
729+
[ReadOnly(false)]
730+
public bool DynamicConcealProduction
731+
{
732+
get { return PluginSettings.Instance.DynamicConcealIncludeMedBays; }
733+
set { PluginSettings.Instance.DynamicConcealIncludeMedBays = value; }
734+
}
735+
765736
[Category( "Dynamic Entity Management" )]
766737
[DisplayName( "Log Actions" )]
767738
[Description( "Enable / Disable console messages that display whether an entity is concealed or revealed. Should be off if you don't care about seeing how many entities get revealed/concealed." )]

0 commit comments

Comments
 (0)