mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 01:50:45 -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,6 +63,8 @@ namespace SPT.SinglePlayer
|
|||||||
new ScavIsPlayerEnemyPatch().Enable();
|
new ScavIsPlayerEnemyPatch().Enable();
|
||||||
new BotOwnerManualUpdatePatch().Enable();
|
new BotOwnerManualUpdatePatch().Enable();
|
||||||
new FirearmControllerShowIncompatibleNotificationClass().Enable();
|
new FirearmControllerShowIncompatibleNotificationClass().Enable();
|
||||||
|
new FixKeyAlreadyExistsErrorOnAchievementPatch().Enable();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user