0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-12 15:10:44 -05:00

Fixed a client error when it tries to add the same achievement to a profile twice

This commit is contained in:
Dev 2024-11-03 21:44:37 +00:00
parent 7853f55bff
commit 58600633fe
2 changed files with 29 additions and 1 deletions

View File

@ -0,0 +1,26 @@
using System.Reflection;
using HarmonyLib;
using SPT.Reflection.Patching;
namespace SPT.SinglePlayer.Patches.RaidFix
{
public class FixKeyAlreadyExistsErrorOnAchievementPatch: ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(AbstractAchievementControllerClass), nameof(AbstractAchievementControllerClass.OnConditionalStatusChangedEvent));
}
[PatchPrefix]
public static bool Prefix(GClass1368 achievement, bool notify, AbstractAchievementControllerClass __instance)
{
if (achievement.IsDone() && __instance.Profile.AchievementsData.ContainsKey(achievement.Id))
{
// Tries to add same achievement key a second time, throwing a "An item with the same key has already been added" error
return false; // Skip original
}
return true; // Do original
}
}
}

View File

@ -63,7 +63,9 @@ namespace SPT.SinglePlayer
new ScavIsPlayerEnemyPatch().Enable();
new BotOwnerManualUpdatePatch().Enable();
new FirearmControllerShowIncompatibleNotificationClass().Enable();
}
new FixKeyAlreadyExistsErrorOnAchievementPatch().Enable();
}
catch (Exception ex)
{
Logger.LogError($"A PATCH IN {GetType().Name} FAILED. SUBSEQUENT PATCHES HAVE NOT LOADED");