Skip to content

Commit 0ce5aba

Browse files
committed
Add release config without physics control because Keen's MT physics is causing crashes.
1 parent ca69f35 commit 0ce5aba

5 files changed

Lines changed: 63 additions & 35 deletions

File tree

Concealment/ConcealGroup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private void Grid_OnClosing(VRage.Game.Entity.MyEntity obj)
5757
grid.OnClosing -= Grid_OnClosing;
5858
}
5959

60-
private void UpdateAABB()
60+
public void UpdateAABB()
6161
{
6262
var startPos = Grids.First().PositionComp.GetPosition();
6363
var box = new BoundingBoxD(startPos, startPos);

Concealment/Concealment.csproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@
4747
<ErrorReport>prompt</ErrorReport>
4848
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
4949
</PropertyGroup>
50+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_NoPhys|AnyCPU'">
51+
<OutputPath>bin\Release_NoPhys\</OutputPath>
52+
<DefineConstants>TRACE</DefineConstants>
53+
<Optimize>true</Optimize>
54+
<DebugType>pdbonly</DebugType>
55+
<PlatformTarget>AnyCPU</PlatformTarget>
56+
<ErrorReport>prompt</ErrorReport>
57+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
58+
</PropertyGroup>
59+
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_NoPhys|x64'">
60+
<OutputPath>bin\x64\Release_NoPhys\</OutputPath>
61+
<DefineConstants>TRACE;NOPHYS</DefineConstants>
62+
<Optimize>true</Optimize>
63+
<DebugType>pdbonly</DebugType>
64+
<PlatformTarget>x64</PlatformTarget>
65+
<ErrorReport>prompt</ErrorReport>
66+
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
67+
</PropertyGroup>
5068
<ItemGroup>
5169
<Reference Include="HavokWrapper">
5270
<HintPath>..\..\..\..\..\..\..\steamcmd\steamapps\common\SpaceEngineersDedicatedServer\DedicatedServer64\HavokWrapper.dll</HintPath>

Concealment/Concealment.sln

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26403.3
4+
VisualStudioVersion = 15.0.26430.13
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Concealment", "Concealment.csproj", "{E5C0184B-7DC4-43D8-872E-2F71162748AA}"
77
EndProject
88
Global
99
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1010
Debug|Any CPU = Debug|Any CPU
1111
Debug|x64 = Debug|x64
12+
Release_NoPhys|Any CPU = Release_NoPhys|Any CPU
13+
Release_NoPhys|x64 = Release_NoPhys|x64
1214
Release|Any CPU = Release|Any CPU
1315
Release|x64 = Release|x64
1416
EndGlobalSection
@@ -17,6 +19,10 @@ Global
1719
{E5C0184B-7DC4-43D8-872E-2F71162748AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
1820
{E5C0184B-7DC4-43D8-872E-2F71162748AA}.Debug|x64.ActiveCfg = Release|x64
1921
{E5C0184B-7DC4-43D8-872E-2F71162748AA}.Debug|x64.Build.0 = Release|x64
22+
{E5C0184B-7DC4-43D8-872E-2F71162748AA}.Release_NoPhys|Any CPU.ActiveCfg = Release_NoPhys|Any CPU
23+
{E5C0184B-7DC4-43D8-872E-2F71162748AA}.Release_NoPhys|Any CPU.Build.0 = Release_NoPhys|Any CPU
24+
{E5C0184B-7DC4-43D8-872E-2F71162748AA}.Release_NoPhys|x64.ActiveCfg = Release_NoPhys|x64
25+
{E5C0184B-7DC4-43D8-872E-2F71162748AA}.Release_NoPhys|x64.Build.0 = Release_NoPhys|x64
2026
{E5C0184B-7DC4-43D8-872E-2F71162748AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
2127
{E5C0184B-7DC4-43D8-872E-2F71162748AA}.Release|Any CPU.Build.0 = Release|Any CPU
2228
{E5C0184B-7DC4-43D8-872E-2F71162748AA}.Release|x64.ActiveCfg = Release|x64

Concealment/ConcealmentPlugin.cs

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
using System.Threading;
77
using System.Threading.Tasks;
88
using System.Windows.Controls;
9+
using Havok;
910
using NLog;
1011
using Sandbox.Engine.Multiplayer;
1112
using Sandbox.Game.Entities;
13+
using Sandbox.Game.EntityComponents;
1214
using Sandbox.Game.Multiplayer;
1315
using Sandbox.Game.World;
1416
using Sandbox.ModAPI;
@@ -17,6 +19,7 @@
1719
using Torch.API.Plugins;
1820
using Torch.Managers;
1921
using VRage.Game;
22+
using VRage.Game.Components;
2023
using VRage.Game.Entity;
2124
using VRage.Game.ModAPI;
2225
using VRage.ModAPI;
@@ -42,7 +45,6 @@ public ConcealmentPlugin()
4245
{
4346
_intersectGroups = new List<ConcealGroup>();
4447
Settings = Persistent<Settings>.Load("Concealment.cfg");
45-
Settings.Data.RevealNeeded += () => RevealNearbyGrids(Settings.Data.RevealDistance);
4648
}
4749

4850
public UserControl GetControl()
@@ -135,14 +137,12 @@ private void ConcealEntity(IMyEntity entity)
135137
if (entity != entity.GetTopMostParent())
136138
return;
137139

138-
if (Settings.Data.ManagePhysics)
139-
{
140-
MyGamePruningStructure.Remove((MyEntity)entity);
141-
entity.Physics?.Deactivate();
142-
}
143-
144-
if (Settings.Data.ManageGamelogic)
145-
UnregisterRecursive(entity);
140+
entity.GetStorage().SetValue(Id, "True");
141+
#if !NOPHYS
142+
MyGamePruningStructure.Remove((MyEntity)entity);
143+
entity.Physics?.Deactivate();
144+
#endif
145+
UnregisterRecursive(entity);
146146

147147
void UnregisterRecursive(IMyEntity e)
148148
{
@@ -160,14 +160,12 @@ private void RevealEntity(IMyEntity entity)
160160
if (entity != entity.GetTopMostParent())
161161
return;
162162

163-
if (Settings.Data.ManagePhysics)
164-
{
165-
MyGamePruningStructure.Add((MyEntity)entity);
166-
entity.Physics?.Activate();
167-
}
168-
169-
if (Settings.Data.ManageGamelogic)
170-
RegisterRecursive(entity);
163+
entity.GetStorage().SetValue(Id, "False");
164+
#if !NOPHYS
165+
MyGamePruningStructure.Add((MyEntity)entity);
166+
entity.Physics?.Activate();
167+
#endif
168+
RegisterRecursive(entity);
171169

172170
void RegisterRecursive(IMyEntity e)
173171
{
@@ -185,10 +183,12 @@ private int ConcealGroup(ConcealGroup group)
185183
if (_concealGroups.Any(g => g.Id == group.Id))
186184
return 0;
187185

188-
Log.Info($"Concealing grids: {group.GridNames}");
186+
Log.Debug($"Concealing grids: {group.GridNames}");
189187
group.Grids.ForEach(ConcealEntity);
188+
#if !NOPHYS
190189
var aabb = group.WorldAABB;
191190
group.ProxyId = _concealedAabbTree.AddProxy(ref aabb, group, 0);
191+
#endif
192192
group.Closing += Group_Closing;
193193
Task.Run(() =>
194194
{
@@ -215,15 +215,26 @@ public int RevealGroup(ConcealGroup group)
215215
}
216216
Log.Debug($"Revealing grids: {group.GridNames}");
217217
group.Grids.ForEach(RevealEntity);
218+
#if !NOPHYS
218219
_concealGroups.Remove(group);
219220
_concealedAabbTree.RemoveProxy(group.ProxyId);
221+
#endif
220222
return group.Grids.Count;
221223
}
222224

223225
public int RevealGridsInSphere(BoundingSphereD sphere)
224226
{
225227
var revealed = 0;
228+
#if !NOPHYS
226229
_concealedAabbTree.OverlapAllBoundingSphere(ref sphere, _intersectGroups);
230+
#else
231+
foreach (var group in ConcealGroups)
232+
{
233+
group.UpdateAABB();
234+
if (sphere.Contains(group.WorldAABB) != ContainmentType.Disjoint)
235+
_intersectGroups.Add(group);
236+
}
237+
#endif
227238
foreach (var group in _intersectGroups)
228239
revealed += RevealGroup(group);
229240

@@ -305,4 +316,12 @@ private List<BoundingSphereD> GetPlayerBoundingSpheres(double distance)
305316
return ((MyPlayerCollection)MyAPIGateway.Multiplayer.Players).GetOnlinePlayers().Where(p => p.Controller?.ControlledEntity != null).Select(p => new BoundingSphereD(p.Controller.ControlledEntity.Entity.PositionComp.GetPosition(), distance)).ToList();
306317
}
307318
}
319+
320+
public static class Extensions
321+
{
322+
public static MyModStorageComponentBase GetStorage(this IMyEntity entity)
323+
{
324+
return entity.Storage = entity.Storage ?? new MyModStorageComponent();
325+
}
326+
}
308327
}

Concealment/Settings.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ public class Settings : ViewModel
1313
private ulong _concealInterval = 3600;
1414
private double _revealDistance = 50000;
1515
private ulong _revealInterval = 60;
16-
private bool _managePhysics = true;
17-
private bool _manageGamelogic = true;
1816

1917
public MTObservableCollection<string> ExcludedSubtypes { get; } = new MTObservableCollection<string>();
20-
public event Action RevealNeeded;
2118

2219
public bool Enabled
2320
{
@@ -49,18 +46,6 @@ public double RevealDistance
4946
set { _revealDistance = value; OnPropertyChanged(); }
5047
}
5148

52-
public bool ManagePhysics
53-
{
54-
get => _managePhysics;
55-
set { RevealNeeded?.Invoke(); _managePhysics = value; OnPropertyChanged(); }
56-
}
57-
58-
public bool ManageGamelogic
59-
{
60-
get => _manageGamelogic;
61-
set { RevealNeeded?.Invoke(); _manageGamelogic = value; OnPropertyChanged(); }
62-
}
63-
6449
public void Save(string path)
6550
{
6651
var xmlSerializer = new XmlSerializer(typeof(Settings));

0 commit comments

Comments
 (0)