.NET Format Style Fixes
This commit is contained in:
@@ -15,7 +15,6 @@ using SPTarkov.Server.Core.Utils.Cloners;
|
||||
using SPTarkov.Server.Core.Utils.Json;
|
||||
using LogLevel = SPTarkov.Server.Core.Models.Spt.Logging.LogLevel;
|
||||
|
||||
|
||||
namespace SPTarkov.Server.Core.Controllers;
|
||||
|
||||
[Injectable]
|
||||
@@ -81,7 +80,7 @@ public class GameController(
|
||||
fullProfile.SptData ??= new Spt
|
||||
{
|
||||
//TODO: complete
|
||||
Version = "Replace_me"
|
||||
Version = "Replace_me",
|
||||
};
|
||||
fullProfile.SptData.Migrations ??= new Dictionary<string, long>();
|
||||
fullProfile.FriendProfileIds ??= [];
|
||||
@@ -91,8 +90,14 @@ public class GameController(
|
||||
return;
|
||||
}
|
||||
|
||||
fullProfile.CharacterData!.PmcData!.WishList ??= new DictionaryOrList<string, int>(new Dictionary<string, int>(), []);
|
||||
fullProfile.CharacterData.ScavData!.WishList ??= new DictionaryOrList<string, int>(new Dictionary<string, int>(), []);
|
||||
fullProfile.CharacterData!.PmcData!.WishList ??= new DictionaryOrList<string, int>(
|
||||
new Dictionary<string, int>(),
|
||||
[]
|
||||
);
|
||||
fullProfile.CharacterData.ScavData!.WishList ??= new DictionaryOrList<string, int>(
|
||||
new Dictionary<string, int>(),
|
||||
[]
|
||||
);
|
||||
|
||||
if (fullProfile.DialogueRecords is not null)
|
||||
{
|
||||
@@ -101,7 +106,9 @@ public class GameController(
|
||||
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Started game with session {sessionId} {fullProfile.ProfileInfo?.Username}");
|
||||
_logger.Debug(
|
||||
$"Started game with session {sessionId} {fullProfile.ProfileInfo?.Username}"
|
||||
);
|
||||
}
|
||||
|
||||
var pmcProfile = fullProfile.CharacterData.PmcData;
|
||||
@@ -133,7 +140,12 @@ public class GameController(
|
||||
_hideoutHelper.UnlockHideoutWallInProfile(pmcProfile);
|
||||
|
||||
// Handle if player has been inactive for a long time, catch up on hideout update before the user goes to his hideout
|
||||
if (!_profileActivityService.ActiveWithinLastMinutes(sessionId, _hideoutConfig.UpdateProfileHideoutWhenActiveWithinMinutes))
|
||||
if (
|
||||
!_profileActivityService.ActiveWithinLastMinutes(
|
||||
sessionId,
|
||||
_hideoutConfig.UpdateProfileHideoutWhenActiveWithinMinutes
|
||||
)
|
||||
)
|
||||
{
|
||||
_hideoutHelper.UpdatePlayerHideout(sessionId);
|
||||
}
|
||||
@@ -167,10 +179,12 @@ public class GameController(
|
||||
public GameConfigResponse GetGameConfig(string sessionId)
|
||||
{
|
||||
var profile = _profileHelper.GetPmcProfile(sessionId);
|
||||
var gameTime = profile?.Stats?.Eft?.OverallCounters?.Items?
|
||||
.FirstOrDefault(c => c.Key!.Contains("LifeTime") && c.Key.Contains("Pmc"))
|
||||
?.Value ??
|
||||
0D;
|
||||
var gameTime =
|
||||
profile
|
||||
?.Stats?.Eft?.OverallCounters?.Items?.FirstOrDefault(c =>
|
||||
c.Key!.Contains("LifeTime") && c.Key.Contains("Pmc")
|
||||
)
|
||||
?.Value ?? 0D;
|
||||
|
||||
var config = new GameConfigResponse
|
||||
{
|
||||
@@ -188,18 +202,14 @@ public class GameController(
|
||||
Trading = _httpServerHelper.GetBackendUrl(),
|
||||
Messaging = _httpServerHelper.GetBackendUrl(),
|
||||
Main = _httpServerHelper.GetBackendUrl(),
|
||||
RagFair = _httpServerHelper.GetBackendUrl()
|
||||
RagFair = _httpServerHelper.GetBackendUrl(),
|
||||
},
|
||||
UseProtobuf = false,
|
||||
UtcTime = _timeUtil.GetTimeStamp(),
|
||||
TotalInGame = gameTime,
|
||||
SessionMode = "pve",
|
||||
PurchasedGames = new PurchasedGames
|
||||
{
|
||||
IsEftPurchased = true,
|
||||
IsArenaPurchased = false
|
||||
},
|
||||
IsGameSynced = true
|
||||
PurchasedGames = new PurchasedGames { IsEftPurchased = true, IsArenaPurchased = false },
|
||||
IsGameSynced = true,
|
||||
};
|
||||
|
||||
return config;
|
||||
@@ -211,14 +221,12 @@ public class GameController(
|
||||
/// <param name="sessionId">Session/Player id</param>
|
||||
/// <param name="requestData"></param>
|
||||
/// <returns></returns>
|
||||
public GameModeResponse GetGameMode(
|
||||
string sessionId,
|
||||
GameModeRequestData requestData)
|
||||
public GameModeResponse GetGameMode(string sessionId, GameModeRequestData requestData)
|
||||
{
|
||||
return new GameModeResponse
|
||||
{
|
||||
GameMode = "pve",
|
||||
BackendUrl = _httpServerHelper.GetBackendUrl()
|
||||
BackendUrl = _httpServerHelper.GetBackendUrl(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -229,14 +237,7 @@ public class GameController(
|
||||
/// <returns></returns>
|
||||
public List<ServerDetails> GetServer(string sessionId)
|
||||
{
|
||||
return
|
||||
[
|
||||
new ServerDetails
|
||||
{
|
||||
Ip = _httpConfig.BackendIp,
|
||||
Port = _httpConfig.BackendPort
|
||||
}
|
||||
];
|
||||
return [new ServerDetails { Ip = _httpConfig.BackendIp, Port = _httpConfig.BackendPort }];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -246,13 +247,9 @@ public class GameController(
|
||||
/// <returns></returns>
|
||||
public CurrentGroupResponse GetCurrentGroup(string sessionId)
|
||||
{
|
||||
return new CurrentGroupResponse
|
||||
{
|
||||
Squad = []
|
||||
};
|
||||
return new CurrentGroupResponse { Squad = [] };
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handle client/checkVersion
|
||||
/// </summary>
|
||||
@@ -263,7 +260,7 @@ public class GameController(
|
||||
return new CheckVersionResponse
|
||||
{
|
||||
IsValid = true,
|
||||
LatestVersion = _coreConfig.CompatibleTarkovVersion
|
||||
LatestVersion = _coreConfig.CompatibleTarkovVersion,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -275,11 +272,7 @@ public class GameController(
|
||||
public GameKeepAliveResponse GetKeepAlive(string sessionId)
|
||||
{
|
||||
_profileActivityService.SetActivityTimestamp(sessionId);
|
||||
return new GameKeepAliveResponse
|
||||
{
|
||||
Message = "OK",
|
||||
UtcTime = _timeUtil.GetTimeStamp()
|
||||
};
|
||||
return new GameKeepAliveResponse { Message = "OK", UtcTime = _timeUtil.GetTimeStamp() };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -311,7 +304,9 @@ public class GameController(
|
||||
var botReloadSkill = _profileHelper.GetSkillFromProfile(pmcProfile, SkillTypes.BotReload);
|
||||
if (botReloadSkill?.Progress > 0)
|
||||
{
|
||||
_logger.Warning(_localisationService.GetText("server_start_player_active_botreload_skill"));
|
||||
_logger.Warning(
|
||||
_localisationService.GetText("server_start_player_active_botreload_skill")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,23 +332,25 @@ public class GameController(
|
||||
var hpRegenPerHour = 456.6;
|
||||
|
||||
// Set new values, whatever is smallest
|
||||
energyRegenPerHour += pmcProfile.Bonuses!
|
||||
.Where(bonus => bonus.Type == BonusType.EnergyRegeneration)
|
||||
energyRegenPerHour += pmcProfile
|
||||
.Bonuses!.Where(bonus => bonus.Type == BonusType.EnergyRegeneration)
|
||||
.Aggregate(0d, (sum, bonus) => sum + bonus.Value!.Value);
|
||||
|
||||
hydrationRegenPerHour += pmcProfile.Bonuses!
|
||||
.Where(bonus => bonus.Type == BonusType.HydrationRegeneration)
|
||||
hydrationRegenPerHour += pmcProfile
|
||||
.Bonuses!.Where(bonus => bonus.Type == BonusType.HydrationRegeneration)
|
||||
.Aggregate(0d, (sum, bonus) => sum + bonus.Value!.Value);
|
||||
|
||||
hpRegenPerHour += pmcProfile.Bonuses!
|
||||
.Where(bonus => bonus.Type == BonusType.HealthRegeneration)
|
||||
hpRegenPerHour += pmcProfile
|
||||
.Bonuses!.Where(bonus => bonus.Type == BonusType.HealthRegeneration)
|
||||
.Aggregate(0d, (sum, bonus) => sum + bonus.Value!.Value);
|
||||
|
||||
// Player has energy deficit
|
||||
if (pmcProfile.Health?.Energy?.Current - pmcProfile.Health?.Energy?.Maximum <= _deviation)
|
||||
{
|
||||
// Set new value, whatever is smallest
|
||||
pmcProfile.Health!.Energy!.Current += Math.Round(energyRegenPerHour * (diffSeconds!.Value / 3600));
|
||||
pmcProfile.Health!.Energy!.Current += Math.Round(
|
||||
energyRegenPerHour * (diffSeconds!.Value / 3600)
|
||||
);
|
||||
if (pmcProfile.Health.Energy.Current > pmcProfile.Health.Energy.Maximum)
|
||||
{
|
||||
pmcProfile.Health.Energy.Current = pmcProfile.Health.Energy.Maximum;
|
||||
@@ -361,9 +358,14 @@ public class GameController(
|
||||
}
|
||||
|
||||
// Player has hydration deficit
|
||||
if (pmcProfile.Health?.Hydration?.Current - pmcProfile.Health?.Hydration?.Maximum <= _deviation)
|
||||
if (
|
||||
pmcProfile.Health?.Hydration?.Current - pmcProfile.Health?.Hydration?.Maximum
|
||||
<= _deviation
|
||||
)
|
||||
{
|
||||
pmcProfile.Health!.Hydration!.Current += Math.Round(hydrationRegenPerHour * (diffSeconds!.Value / 3600));
|
||||
pmcProfile.Health!.Hydration!.Current += Math.Round(
|
||||
hydrationRegenPerHour * (diffSeconds!.Value / 3600)
|
||||
);
|
||||
if (pmcProfile.Health.Hydration.Current > pmcProfile.Health.Hydration.Maximum)
|
||||
{
|
||||
pmcProfile.Health.Hydration.Current = pmcProfile.Health.Hydration.Maximum;
|
||||
@@ -383,10 +385,15 @@ public class GameController(
|
||||
/// <param name="pmcProfile">Player</param>
|
||||
/// <param name="hpRegenPerHour"></param>
|
||||
/// <param name="diffSeconds"></param>
|
||||
protected void DecreaseBodyPartEffectTimes(PmcData pmcProfile, double hpRegenPerHour, double diffSeconds)
|
||||
protected void DecreaseBodyPartEffectTimes(
|
||||
PmcData pmcProfile,
|
||||
double hpRegenPerHour,
|
||||
double diffSeconds
|
||||
)
|
||||
{
|
||||
foreach (var bodyPart in pmcProfile.Health!.BodyParts!
|
||||
.Select(bodyPartKvP => bodyPartKvP.Value))
|
||||
foreach (
|
||||
var bodyPart in pmcProfile.Health!.BodyParts!.Select(bodyPartKvP => bodyPartKvP.Value)
|
||||
)
|
||||
{
|
||||
// Check part hp
|
||||
if (bodyPart.Health!.Current < bodyPart.Health.Maximum)
|
||||
@@ -399,7 +406,6 @@ public class GameController(
|
||||
bodyPart.Health.Current = bodyPart.Health.Maximum;
|
||||
}
|
||||
|
||||
|
||||
if (bodyPart.Effects is null || bodyPart.Effects.Count == 0)
|
||||
{
|
||||
continue;
|
||||
@@ -423,7 +429,7 @@ public class GameController(
|
||||
// Decrement effect time value by difference between current time and time health was last updated
|
||||
effectKvP.Value.Time -= diffSeconds;
|
||||
if (effectKvP.Value.Time < 1)
|
||||
// Effect time was sub 1, set floor it can be
|
||||
// Effect time was sub 1, set floor it can be
|
||||
{
|
||||
effectKvP.Value.Time = 1;
|
||||
}
|
||||
@@ -475,7 +481,9 @@ public class GameController(
|
||||
{
|
||||
if (
|
||||
fullProfile.SptData.Mods.Any(m =>
|
||||
m.Author == mod.ModMetadata.Author && m.Version == mod.ModMetadata.Version && m.Name == mod.ModMetadata.Name
|
||||
m.Author == mod.ModMetadata.Author
|
||||
&& m.Version == mod.ModMetadata.Version
|
||||
&& m.Name == mod.ModMetadata.Name
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -490,7 +498,7 @@ public class GameController(
|
||||
Version = mod.ModMetadata.Version,
|
||||
Name = mod.ModMetadata.Name,
|
||||
Url = mod.ModMetadata.Url,
|
||||
DateAdded = _timeUtil.GetTimeStamp()
|
||||
DateAdded = _timeUtil.GetTimeStamp(),
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -552,7 +560,9 @@ public class GameController(
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Profile made with: {fullProfile.SptData?.Version}");
|
||||
_logger.Debug($"Server version: {ProgramStatics.SPT_VERSION() ?? _coreConfig.SptVersion} {ProgramStatics.COMMIT()}");
|
||||
_logger.Debug(
|
||||
$"Server version: {ProgramStatics.SPT_VERSION() ?? _coreConfig.SptVersion} {ProgramStatics.COMMIT()}"
|
||||
);
|
||||
_logger.Debug($"Debug enabled: {ProgramStatics.DEBUG()}");
|
||||
_logger.Debug($"Mods enabled: {ProgramStatics.MODS()}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user