Skip to content

Commit

Permalink
Fix sources, let invalid model state weapons reset to base if necessa…
Browse files Browse the repository at this point in the history
…ry, check design application against base type.
  • Loading branch information
Ottermandias committed Mar 7, 2024
1 parent ee426eb commit c99aa51
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 1 addition & 3 deletions Glamourer/Designs/Links/MergedDesign.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Glamourer.Events;
using Glamourer.GameData;
using Glamourer.Interop.Penumbra;
using Glamourer.Interop.Penumbra;
using Glamourer.State;
using Penumbra.GameData.Enums;
using Penumbra.GameData.Structs;
Expand Down
6 changes: 3 additions & 3 deletions Glamourer/State/StateEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ public void ApplyDesign(object data, MergedDesign mergedDesign, ApplySettings se
if (settings.RespectManual && state.Sources[weaponSlot, false].IsManual())
continue;

var currentType = state.ModelData.Item(weaponSlot).Type;
if (!settings.FromJobChange)
{
if (gPose.InGPose)
Expand All @@ -291,10 +290,11 @@ public void ApplyDesign(object data, MergedDesign mergedDesign, ApplySettings se
});
}

var currentType = state.BaseData.Item(weaponSlot).Type;
if (mergedDesign.Weapons.TryGetValue(currentType, out var weapon))
{
var source = settings.UseSingleSource ? settings.Source :
weapon.Item2 is StateSource.Game ? StateSource.Game : weapon.Item2;
weapon.Item2 is StateSource.Game ? StateSource.Game : settings.Source;
Editor.ChangeItem(state, weaponSlot, weapon.Item1, source, out _,
settings.Key);
}
Expand All @@ -304,7 +304,7 @@ public void ApplyDesign(object data, MergedDesign mergedDesign, ApplySettings se
if (settings.FromJobChange)
jobChange.Set(state, mergedDesign.Weapons.Values.Select(m =>
(m.Item1, settings.UseSingleSource ? settings.Source :
m.Item2 is StateSource.Game ? StateSource.Game : m.Item2)));
m.Item2 is StateSource.Game ? StateSource.Game : settings.Source)));

foreach (var meta in MetaExtensions.AllRelevant.Where(mergedDesign.Design.DoApplyMeta))
{
Expand Down
3 changes: 2 additions & 1 deletion Glamourer/State/StateListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ private void OnWeaponLoading(Actor actor, EquipSlot slot, ref CharacterWeapon we
{
if (weapon.Skeleton.Id != 0)
weapon = weapon.With(newWeapon.Stain);
_manager.ChangeItem(state, slot, state.BaseData.Item(slot), ApplySettings.Game);
// Force unlock if necessary.
_manager.ChangeItem(state, slot, state.BaseData.Item(slot), ApplySettings.Game with { Key = state.Combination });
}
}

Expand Down

0 comments on commit c99aa51

Please sign in to comment.