d2e2f04c93
* Fix exception sometimes thrown on save
- Switch back from File.Rename to File.Move, as Rename is throwing exceptions on some users systems
* Change BTR skin to tarcola during Christmas event
* Added comment
* Remove unused using
* Add wipe Response model
* formatting and add Wipe Endpoint to V2
* Format Style Fixes
* Merge pull request #669 from sp-tarkov/Assembly-ref-validation
Validate core assembly reference when loading mods
* removed zombies from customs and interchange + increased infection across other maps that have zombie kill quests
* Don't apply hostility changes to maps without zombies during halloween
`ReplaceBotHostiltiy` has optional map whitelist param
* Updated hostility values for maps with infection:
bosses = hostile to player not to pmc bots
followers = hostile to player not to pmc bots
pmcs = hostile to player + always hostile to scavs
scavs = hostile to player and pmc bots
raiders = hostile to player and pmc bots
Adjusted infection rates to just maps with zombie kill quests
* Format Style Fixes
* Added missing values for event bosses
* Format Style Fixes
* Added missing values for `ravangezryachiyevent`
Fixed preset typo `bossTagillaAgro`
* Format Style Fixes
* Flagged `Night of The Cult` as halloween quest
* Fixed incorrect logic
* Enabled `Night of The Cult` bosses to spawn
* Format Style Fixes
* Addd a new ReleaseCheckService to notify users of updates (#670)
* Addd a new ReleaseCheckService to notify users of updates
- Pulls the latest release from GitHub API to compare the tag against the users current SPT version
- Runs at the very end of the startup process to avoid being pushed off screen by mod logging
- Only notifies of patch version increments, not major or minor increments
- Links the release notes so users can Ctrl+Click to open directly to the upgrade page
- Is run on its own thread, and discards all errors, so as to not impact users without an internet connection or ability to access GitHub
* Formatting
* Use record for the ReleaseInformation class
---------
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
* ProfileDataService changes:
Added `ClearProfileData()`
Replaced filepath access with `Path.Combine`
Reduced various sources of duplication
* Adjusted `Goons` spawn chance to 20% across `Customs/Lighthouse/Woods/Shoreline`
* Account for compound items in DialogHelper.GetMessageItemContents
* Generate weapon/armor price based on the child item price total
* Added halloween event bosses to april event
* Flagged infected spawns as `ForceSpawn` and ``
* Add migration for invalid pockets
* Default assign IEnumerable
* Post raid effect fixes:
When exiting raid with severe muscle pain, prevent client instructing server to add mild muscle pain
When exiting a raid with effect that has a timer, decrease timer value by amount of time spent in raid
* Updated nuget packages
* Fixed player scav not having correct HP values on limbs #642
* Remove unused record
* Revert "Updated nuget packages"
This reverts commit f6d9d461a6.
* Added `IMP mine detector` to reward and flea blacklist
* Fixed weapon builds not overwriting existing #654
Cleaned up `SaveWeaponBuild` and `SaveEquipmentBuild`
---------
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Co-authored-by: Chomp <27521899+chompDev@users.noreply.github.com>
Co-authored-by: Chomp <dev@dev.sp-tarkov.com>
Co-authored-by: CWX <CWXDEV@outlook.com>
Co-authored-by: sp-tarkov-bot <singleplayertarkov@gmail.com>
Co-authored-by: Cj <161484149+CJ-SPT@users.noreply.github.com>
Co-authored-by: Tyfon <29051038+tyfon7@users.noreply.github.com>
Co-authored-by: Archangel <jesse@archangel.wtf>
200 lines
5.3 KiB
C#
200 lines
5.3 KiB
C#
using SPTarkov.DI.Annotations;
|
|
using SPTarkov.Server.Core.Models.Common;
|
|
using SPTarkov.Server.Core.Models.Eft.Launcher;
|
|
using SPTarkov.Server.Core.Models.Eft.Profile;
|
|
using SPTarkov.Server.Core.Models.Spt.Config;
|
|
using SPTarkov.Server.Core.Models.Spt.Mod;
|
|
using SPTarkov.Server.Core.Servers;
|
|
using SPTarkov.Server.Core.Services;
|
|
using SPTarkov.Server.Core.Utils;
|
|
using Info = SPTarkov.Server.Core.Models.Eft.Profile.Info;
|
|
|
|
namespace SPTarkov.Server.Core.Controllers;
|
|
|
|
[Injectable]
|
|
public class LauncherV2Controller(
|
|
IReadOnlyList<SptMod> loadedMods,
|
|
HashUtil hashUtil,
|
|
SaveServer saveServer,
|
|
DatabaseService databaseService,
|
|
ServerLocalisationService serverLocalisationService,
|
|
ConfigServer configServer,
|
|
Watermark watermark,
|
|
ProfileController profileController
|
|
)
|
|
{
|
|
protected readonly CoreConfig CoreConfig = configServer.GetConfig<CoreConfig>();
|
|
|
|
/// <summary>
|
|
/// Returns a simple string of Pong!
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string Ping()
|
|
{
|
|
return "Pong!";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns all available profile types and descriptions for creation.
|
|
/// - This is also localised.
|
|
/// </summary>
|
|
/// <returns>dict of profile names + description</returns>
|
|
public Dictionary<string, string> Types()
|
|
{
|
|
var result = new Dictionary<string, string>();
|
|
var dbProfiles = databaseService.GetProfileTemplates();
|
|
|
|
foreach (var (templateName, template) in dbProfiles)
|
|
{
|
|
result.TryAdd(templateName, serverLocalisationService.GetText(template.DescriptionLocaleKey));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Checks if login details were correct.
|
|
/// </summary>
|
|
/// <param name="info"></param>
|
|
/// <returns></returns>
|
|
public bool Login(LoginRequestData info)
|
|
{
|
|
var sessionId = GetSessionId(info);
|
|
|
|
return !sessionId.IsEmpty;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Register a new profile.
|
|
/// </summary>
|
|
/// <param name="info"></param>
|
|
/// <returns></returns>
|
|
public async Task<bool> Register(RegisterData info)
|
|
{
|
|
foreach (var (_, profile) in saveServer.GetProfiles())
|
|
{
|
|
if (info.Username == profile.ProfileInfo!.Username)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
await CreateAccount(info);
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Remove profile from server.
|
|
/// </summary>
|
|
/// <param name="info"></param>
|
|
/// <returns></returns>
|
|
public bool Remove(LoginRequestData info)
|
|
{
|
|
var sessionId = GetSessionId(info);
|
|
|
|
return !sessionId.IsEmpty && saveServer.RemoveProfile(sessionId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the Servers SPT Version.
|
|
/// - "4.0.0"
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string SptVersion()
|
|
{
|
|
return watermark.GetVersionTag();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the compatible EFT Version.
|
|
/// - "0.14.9.31124"
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string EftVersion()
|
|
{
|
|
return CoreConfig.CompatibleTarkovVersion;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the Servers loaded mods.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public Dictionary<string, AbstractModMetadata> LoadedMods()
|
|
{
|
|
return loadedMods.ToDictionary(sptMod => sptMod.ModMetadata.Name, sptMod => sptMod.ModMetadata);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates the account from provided details.
|
|
/// </summary>
|
|
/// <param name="info"></param>
|
|
/// <returns></returns>
|
|
protected async Task<MongoId> CreateAccount(RegisterData info)
|
|
{
|
|
var profileId = new MongoId();
|
|
var scavId = new MongoId();
|
|
var newProfileDetails = new Info
|
|
{
|
|
ProfileId = profileId,
|
|
ScavengerId = scavId,
|
|
Aid = hashUtil.GenerateAccountId(),
|
|
Username = info.Username,
|
|
IsWiped = true,
|
|
Edition = info.Edition,
|
|
};
|
|
|
|
saveServer.CreateProfile(newProfileDetails);
|
|
|
|
await saveServer.LoadProfileAsync(profileId);
|
|
await saveServer.SaveProfileAsync(profileId);
|
|
|
|
return profileId;
|
|
}
|
|
|
|
protected MongoId GetSessionId(LoginRequestData info)
|
|
{
|
|
foreach (var (sessionId, profile) in saveServer.GetProfiles())
|
|
{
|
|
if (info.Username == profile.ProfileInfo!.Username)
|
|
{
|
|
return sessionId;
|
|
}
|
|
}
|
|
|
|
return MongoId.Empty();
|
|
}
|
|
|
|
public SptProfile GetProfile(MongoId sessionId)
|
|
{
|
|
return saveServer.GetProfile(sessionId);
|
|
}
|
|
|
|
public MiniProfile? GetMiniProfileFromUsername(LoginRequestData info)
|
|
{
|
|
return profileController.GetMiniProfile(GetSessionId(info));
|
|
}
|
|
|
|
public bool Wipe(RegisterData info)
|
|
{
|
|
if (!CoreConfig.AllowProfileWipe)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
var sessionId = Login(info);
|
|
|
|
if (!sessionId)
|
|
{
|
|
var profileInfo = saveServer
|
|
.GetProfiles()
|
|
.FirstOrDefault(x => x.Value.ProfileInfo?.Username == info.Username)
|
|
.Value.ProfileInfo;
|
|
|
|
profileInfo!.Edition = info.Edition;
|
|
profileInfo.IsWiped = true;
|
|
}
|
|
|
|
return sessionId;
|
|
}
|
|
}
|