Merge branch 'develop' of https://github.com/sp-tarkov/server-csharp into develop
This commit is contained in:
@@ -2,6 +2,7 @@ using SPTarkov.Server.Core.DI;
|
||||
using SPTarkov.Server.Core.Models.External;
|
||||
using SPTarkov.Server.Core.Models.Utils;
|
||||
using SPTarkov.Common.Annotations;
|
||||
using SPTarkov.Server.Core.Utils;
|
||||
|
||||
namespace SPTarkov.Server.Core.Loaders;
|
||||
|
||||
@@ -13,13 +14,16 @@ public class PostDBModLoader(
|
||||
{
|
||||
public async Task OnLoad()
|
||||
{
|
||||
_logger.Info("Loading PostDBLoadMod...");
|
||||
foreach (var postDbLoadMod in _postDbLoadMods)
|
||||
if (ProgramStatics.MODS())
|
||||
{
|
||||
postDbLoadMod.PostDBLoad();
|
||||
}
|
||||
_logger.Info("Loading PostDBMods...");
|
||||
foreach (var postDbLoadMod in _postDbLoadMods)
|
||||
{
|
||||
postDbLoadMod.PostDBLoad();
|
||||
}
|
||||
|
||||
_logger.Info("Finished loading PostDBLoadMod...");
|
||||
_logger.Info("Finished loading PostDBMods...");
|
||||
}
|
||||
}
|
||||
|
||||
public string GetRoute()
|
||||
|
||||
@@ -16,17 +16,14 @@ public class PostSptModLoader(
|
||||
{
|
||||
if (ProgramStatics.MODS())
|
||||
{
|
||||
// await _postSptModLoader.load();
|
||||
// TODO: Huh?
|
||||
}
|
||||
_logger.Info("Loading PostSptMods...");
|
||||
foreach (var postSptLoadMod in _postSptLoadMods)
|
||||
{
|
||||
postSptLoadMod.PostSptLoad();
|
||||
}
|
||||
|
||||
_logger.Info("Loading PostSptMods...");
|
||||
foreach (var postSptLoadMod in _postSptLoadMods)
|
||||
{
|
||||
postSptLoadMod.PostSptLoad();
|
||||
_logger.Info("Finished loading PostSptMods...");
|
||||
}
|
||||
|
||||
_logger.Info("Finished loading PostSptMods...");
|
||||
}
|
||||
|
||||
public string GetRoute()
|
||||
|
||||
@@ -30,13 +30,14 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- SPT specific -->
|
||||
<!-- using publish - provide flag to disable modding -p:DisableModding=true -->
|
||||
<SptVersion Condition="'$(SptVersion)' == ''">0.0.0</SptVersion>
|
||||
<SptVersion Condition="'$(SptVersion)' == ''">4.0.0</SptVersion>
|
||||
<SptCommit Condition="'$(SptCommit)' == ''">a12b34</SptCommit>
|
||||
<SptBuildTime Condition="'$(SptBuildTime)' == ''">0000000000</SptBuildTime>
|
||||
<SptBuildType Condition="'$(SptBuildType)' == ''">LOCAL</SptBuildType>
|
||||
<!-- BuildType options - LOCAL, DEBUG, RELEASE, BLEEDING_EDGE, BLEEDING_EDGE_MODS - *must be all caps*-->
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Generates the ProgramStatics class with the build information -->
|
||||
<Target Name="GenerateProgramStatics" BeforeTargets="BeforeBuild">
|
||||
<WriteLinesToFile
|
||||
File="Utils/ProgramStatics.Generated.cs"
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace SPTarkov.Server.Core.Utils;
|
||||
|
||||
public static partial class ProgramStatics
|
||||
{
|
||||
private static string? _sptVersion = "0.0.0";
|
||||
private static string? _sptVersion = "4.0.0";
|
||||
private static string? _commit = "a12b34";
|
||||
private static double? _buildTime = 0000000000;
|
||||
private static EntryType? BuildType = EntryType.LOCAL;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Reflection;
|
||||
using HarmonyLib;
|
||||
using SPTarkov.Server.Core.Utils;
|
||||
|
||||
namespace SPTarkov.Server.Modding;
|
||||
|
||||
@@ -7,6 +8,11 @@ public class HarmonyBootstrapper
|
||||
{
|
||||
public static void LoadAllPatches(List<Assembly> assemblies)
|
||||
{
|
||||
if (!ProgramStatics.MODS())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var hamony = new Harmony("SPT");
|
||||
foreach (var assembly in assemblies)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Reflection;
|
||||
using System.Runtime.Loader;
|
||||
using System.Text.Json;
|
||||
using SPTarkov.Server.Core.Models.Spt.Mod;
|
||||
using SPTarkov.Server.Core.Utils;
|
||||
|
||||
namespace SPTarkov.Server.Modding;
|
||||
|
||||
@@ -18,6 +19,11 @@ public class ModDllLoader
|
||||
|
||||
var mods = new List<SptMod>();
|
||||
|
||||
if (!ProgramStatics.MODS())
|
||||
{
|
||||
return mods;
|
||||
}
|
||||
|
||||
// foreach directory in /user/mods/
|
||||
// treat this as the MOD
|
||||
// should contain a dll and Package.json
|
||||
|
||||
@@ -21,12 +21,14 @@ public static class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
// Initialize the program variables
|
||||
ProgramStatics.Initialize();
|
||||
|
||||
// Search for mod dlls
|
||||
var mods = ModDllLoader.LoadAllMods();
|
||||
|
||||
// Create web builder and logger
|
||||
var builder = CreateNewHostBuilder(args);
|
||||
// Initialize the program variables TODO: this needs to be implemented properly
|
||||
ProgramStatics.Initialize();
|
||||
|
||||
// validate and sort mods, this will also discard any mods that are invalid
|
||||
var sortedLoadedMods = ValidateMods(mods);
|
||||
@@ -35,8 +37,13 @@ public static class Program
|
||||
|
||||
// register SPT components
|
||||
DependencyInjectionRegistrator.RegisterSptComponents(typeof(Program).Assembly, typeof(App).Assembly, builder.Services);
|
||||
// register mod components from the filtered list
|
||||
DependencyInjectionRegistrator.RegisterModOverrideComponents(builder.Services, sortedLoadedMods.SelectMany(a => a.Assemblies).ToList());
|
||||
|
||||
if (ProgramStatics.MODS())
|
||||
{
|
||||
// register mod components from the filtered list
|
||||
DependencyInjectionRegistrator.RegisterModOverrideComponents(builder.Services, sortedLoadedMods.SelectMany(a => a.Assemblies).ToList());
|
||||
}
|
||||
|
||||
var serviceProvider = builder.Services.BuildServiceProvider();
|
||||
var logger = serviceProvider.GetService<ILoggerFactory>().CreateLogger("Server");
|
||||
try
|
||||
@@ -57,6 +64,7 @@ public static class Program
|
||||
|
||||
// Add the Loaded Mod Assemblies for later
|
||||
appContext?.AddValue(ContextVariableType.LOADED_MOD_ASSEMBLIES, mods);
|
||||
|
||||
// This is the builder that will get use by the HttpServer to start up the web application
|
||||
appContext?.AddValue(ContextVariableType.APP_BUILDER, builder);
|
||||
|
||||
@@ -89,11 +97,15 @@ public static class Program
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Logging.ClearProviders();
|
||||
#if DEBUG
|
||||
builder.Configuration.AddJsonFile("appsettings.Development.json", true, true);
|
||||
#else
|
||||
builder.Configuration.AddJsonFile("appsettings.json", true, true);
|
||||
#endif
|
||||
|
||||
if (ProgramStatics.DEBUG())
|
||||
{
|
||||
builder.Configuration.AddJsonFile("appsettings.Development.json", true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.Configuration.AddJsonFile("appsettings.json", true, true);
|
||||
}
|
||||
|
||||
builder.Host.UseSerilog((context, provider, logger) =>
|
||||
{
|
||||
@@ -111,6 +123,11 @@ public static class Program
|
||||
|
||||
private static List<SptMod> ValidateMods(List<SptMod> mods)
|
||||
{
|
||||
if (!ProgramStatics.MODS())
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
// We need the SPT dependencies for the ModValidator, but mods are loaded before the web application
|
||||
// So we create a disposable web application that we will throw away after getting the mods to load
|
||||
var builder = CreateNewHostBuilder();
|
||||
|
||||
Reference in New Issue
Block a user