Merge pull request #517 from CJ-SPT/skill-fix

Fix sending invalid skill information to client
This commit is contained in:
Chomp
2025-07-26 09:32:56 +00:00
committed by GitHub
3 changed files with 20 additions and 2 deletions
+1
View File
@@ -3,6 +3,7 @@ using Benchmarks.Mock;
using SPTarkov.Server.Core.Models.Spt.Templates;
using SPTarkov.Server.Core.Utils;
using SPTarkov.Server.Core.Utils.Cloners;
using SPTarkov.Server.Core.Utils.Json;
using SPTarkov.Server.Core.Utils.Json.Converters;
namespace Benchmarks;
@@ -20,6 +20,7 @@ public class ProfileController(
ISptLogger<ProfileController> logger,
SaveServer saveServer,
CreateProfileService createProfileService,
ProfileFixerService profileFixerService,
PlayerScavGenerator playerScavGenerator,
ProfileHelper profileHelper
)
@@ -98,7 +99,23 @@ public class ProfileController(
/// <returns>Return a full profile, scav and pmc profiles + meta data</returns>
public virtual List<PmcData> GetCompleteProfile(MongoId sessionId)
{
return profileHelper.GetCompleteProfile(sessionId);
var profile = profileHelper.GetCompleteProfile(sessionId);
// Some users like to crank massive skill multipliers and send the client invalid information,
// causing a json exception during parsing
if (profile[0].Skills != null)
{
// Pmc profile is index 0
profileFixerService.CheckForSkillsOverMaxLevel(profile[0]);
}
if (profile[1].Skills != null)
{
// We also do the scav profile here because it is also affected by the skill multipliers
profileFixerService.CheckForSkillsOverMaxLevel(profile[1]);
}
return profile;
}
/// <summary>
@@ -624,7 +624,7 @@ public class ProfileFixerService(
/// Check for and cap profile skills at 5100.
/// </summary>
/// <param name="pmcProfile"> Profile to check and fix </param>
protected void CheckForSkillsOverMaxLevel(PmcData pmcProfile)
public void CheckForSkillsOverMaxLevel(PmcData pmcProfile)
{
var skills = pmcProfile.Skills.Common;