From 2e9a30427d33ef1146d14db6ee8f44e4ff07c348 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Wed, 27 Sep 2023 01:16:22 +0200 Subject: [PATCH] Maybe fix problem with Mare syncing wrong with Restricted Gear protection enabled. --- Glamourer/State/StateApplier.cs | 21 +++++++++++++++------ Glamourer/State/StateListener.cs | 11 +++++++++-- Glamourer/State/StateManager.cs | 2 +- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Glamourer/State/StateApplier.cs b/Glamourer/State/StateApplier.cs index 311bcaf..04f1049 100644 --- a/Glamourer/State/StateApplier.cs +++ b/Glamourer/State/StateApplier.cs @@ -1,5 +1,6 @@ using System.Linq; using Glamourer.Customization; +using Glamourer.Events; using Glamourer.Interop; using Glamourer.Interop.Penumbra; using Glamourer.Interop.Structs; @@ -91,7 +92,7 @@ public class StateApplier /// This uses the current customization of the model to potentially prevent restricted gear types from appearing. /// This never requires redrawing. /// - public void ChangeArmor(ActorData data, EquipSlot slot, CharacterArmor armor, bool isHatVisible = true) + public void ChangeArmor(ActorData data, EquipSlot slot, CharacterArmor armor, bool checkRestrictions, bool isHatVisible = true) { if (slot is EquipSlot.Head && !isHatVisible) return; @@ -102,18 +103,26 @@ public class StateApplier if (!mdl.IsHuman) continue; - var customize = mdl.GetCustomize(); - var (_, resolvedItem) = _items.ResolveRestrictedGear(armor, slot, customize.Race, customize.Gender); - _updateSlot.UpdateSlot(actor.Model, slot, resolvedItem); + if (checkRestrictions) + { + var customize = mdl.GetCustomize(); + var (_, resolvedItem) = _items.ResolveRestrictedGear(armor, slot, customize.Race, customize.Gender); + _updateSlot.UpdateSlot(actor.Model, slot, resolvedItem); + } + else + { + _updateSlot.UpdateSlot(actor.Model, slot, armor); + } } } - /// + /// public ActorData ChangeArmor(ActorState state, EquipSlot slot, bool apply) { + // If the source is not IPC we do not want to apply restrictions. var data = GetData(state); if (apply) - ChangeArmor(data, slot, state.ModelData.Armor(slot), state.ModelData.IsHatVisible()); + ChangeArmor(data, slot, state.ModelData.Armor(slot), state[slot, false] is not StateChanged.Source.Ipc, state.ModelData.IsHatVisible()); return data; } diff --git a/Glamourer/State/StateListener.cs b/Glamourer/State/StateListener.cs index 9f4da2c..1d79926 100644 --- a/Glamourer/State/StateListener.cs +++ b/Glamourer/State/StateListener.cs @@ -225,12 +225,19 @@ public class StateListener : IDisposable if (_condition[ConditionFlag.CreatingCharacter] && actor.Index >= ObjectIndex.CutsceneStart) return; + // If the model comes from IPC it is probably from Mare, + // then we do not want to use our restricted gear protection + // since we assume the player has that gear modded to availability. + var locked = false; if (actor.Identifier(_actors.AwaitedService, out var identifier) && _manager.TryGetValue(identifier, out var state)) + { HandleEquipSlot(actor, state, slot, ref armor.Value); + locked = state[slot, false] is StateChanged.Source.Ipc; + } _funModule.ApplyFun(actor, ref armor.Value, slot); - if (!_config.UseRestrictedGearProtection) + if (!_config.UseRestrictedGearProtection || locked) return; var customize = model.GetCustomize(); @@ -263,7 +270,7 @@ public class StateListener : IDisposable _applier.ChangeWeapon(objects, slot, currentItem, stain); break; default: - _applier.ChangeArmor(objects, slot, current.ToArmor(), state.ModelData.IsHatVisible()); + _applier.ChangeArmor(objects, slot, current.ToArmor(), state[slot, false] is not StateChanged.Source.Ipc, state.ModelData.IsHatVisible()); break; } } diff --git a/Glamourer/State/StateManager.cs b/Glamourer/State/StateManager.cs index 084f014..8be11a5 100644 --- a/Glamourer/State/StateManager.cs +++ b/Glamourer/State/StateManager.cs @@ -408,7 +408,7 @@ public class StateManager : IReadOnlyDictionary { _applier.ChangeCustomize(actors, state.ModelData.Customize); foreach (var slot in EquipSlotExtensions.EqdpSlots) - _applier.ChangeArmor(actors, slot, state.ModelData.Armor(slot), state.ModelData.IsHatVisible()); + _applier.ChangeArmor(actors, slot, state.ModelData.Armor(slot), state[slot, false] is not StateChanged.Source.Ipc, state.ModelData.IsHatVisible()); var mainhandActors = state.ModelData.MainhandType != state.BaseData.MainhandType ? actors.OnlyGPose() : actors; _applier.ChangeMainhand(mainhandActors, state.ModelData.Item(EquipSlot.MainHand), state.ModelData.Stain(EquipSlot.MainHand)); var offhandActors = state.ModelData.OffhandType != state.BaseData.OffhandType ? actors.OnlyGPose() : actors;