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:
parent
7853f55bff
commit
58600633fe
@ -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
|
||||
}
|
||||
}
|
||||
}
|
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user