Skip to content

Commit cbb4688

Browse files
committed
Fix entities not showing if game path set via command line args
1 parent 2789685 commit cbb4688

3 files changed

Lines changed: 6 additions & 12 deletions

File tree

Nitrox.Server.Subnautica/Extensions/ServiceCollectionExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,23 +106,23 @@ public IServiceCollection AddFallback<TInterface, TFallback>() where TInterface
106106

107107
public IServiceCollection AddHostedSingletonService<T>() where T : class, IHostedService => services.AddSingleton<T>().AddHostedService(provider => provider.GetRequiredService<T>());
108108

109-
public IServiceCollection AddNitroxOptions()
109+
public IServiceCollection AddNitroxOptions(ServerStartOptions startOptions)
110110
{
111111
services.AddOptionsWithValidateOnStart<ServerStartOptions, ServerStartOptions.Validator>()
112112
.BindConfiguration("")
113113
.Configure(options =>
114114
{
115115
if (string.IsNullOrWhiteSpace(options.GamePath))
116116
{
117-
options.GamePath = NitroxUser.GamePath;
117+
options.GamePath = startOptions.GamePath;
118118
}
119119
if (string.IsNullOrWhiteSpace(options.NitroxAssetsPath))
120120
{
121-
options.NitroxAssetsPath = NitroxUser.AssetsPath;
121+
options.NitroxAssetsPath = startOptions.NitroxAssetsPath;
122122
}
123123
if (string.IsNullOrWhiteSpace(options.NitroxAppDataPath))
124124
{
125-
options.NitroxAppDataPath = NitroxUser.AppDataPath;
125+
options.NitroxAppDataPath = startOptions.NitroxAppDataPath;
126126
}
127127
});
128128
services.AddOptionsWithValidateOnStart<SubnauticaServerOptions, SubnauticaServerOptions.Validator>()

Nitrox.Server.Subnautica/Models/Serialization/BatchCellsParser.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public BatchCellsParser(EntitySpawnPointFactory entitySpawnPointFactory, Subnaut
4040

4141
public List<EntitySpawnPoint> ParseBatchData(NitroxInt3 batchId)
4242
{
43-
List<EntitySpawnPoint> spawnPoints = new List<EntitySpawnPoint>();
43+
List<EntitySpawnPoint> spawnPoints = [];
4444

4545
ParseFile(batchId, "CellsCache", "baked-", "", spawnPoints);
4646

@@ -49,12 +49,6 @@ public List<EntitySpawnPoint> ParseBatchData(NitroxInt3 batchId)
4949

5050
public void ParseFile(NitroxInt3 batchId, string pathPrefix, string prefix, string suffix, List<EntitySpawnPoint> spawnPoints)
5151
{
52-
string subnauticaPath = NitroxUser.GamePath;
53-
if (string.IsNullOrEmpty(subnauticaPath))
54-
{
55-
return;
56-
}
57-
5852
string path = options.Value.GetSubnauticaBuild18Path();
5953
string fileName = Path.Combine(path, pathPrefix, $"{prefix}batch-cells-{batchId.X}-{batchId.Y}-{batchId.Z}{suffix}.bin");
6054

Nitrox.Server.Subnautica/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private static async Task StartServerAsync(string[] args)
9191
options.ServicesStartConcurrently = true;
9292
options.ServicesStopConcurrently = true;
9393
})
94-
.AddNitroxOptions()
94+
.AddNitroxOptions(startOptions)
9595
// Add initialization services - diagnoses the server environment on startup.
9696
.AddHostedSingletonService<PreventMultiServerInitService>()
9797
.AddHostedSingletonService<NetworkPortAvailabilityService>()

0 commit comments

Comments
 (0)