From bf32795c08edaec909285ed4a168d330ae26a5c5 Mon Sep 17 00:00:00 2001 From: Aspher0 <154540490+Aspher0@users.noreply.github.com> Date: Thu, 11 Jul 2024 11:09:50 +0200 Subject: [PATCH] Fix some stains and add comments --- Glamourer/Designs/DesignBase.cs | 4 ++-- Glamourer/Designs/DesignConverter.cs | 8 ++++---- Glamourer/Designs/DesignData.cs | 2 ++ Glamourer/GameData/NpcData.cs | 6 +++--- Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs | 2 +- Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs | 4 +++- Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs | 2 +- Glamourer/Interop/ChangeCustomizeService.cs | 2 +- Glamourer/Interop/CharaFile/CmaFile.cs | 2 +- Glamourer/Interop/Material/PrepareColorSet.cs | 8 ++++---- Glamourer/Interop/MetaService.cs | 2 +- Glamourer/Services/ItemManager.cs | 2 +- Glamourer/State/FunEquipSet.cs | 4 ++-- Glamourer/State/FunModule.cs | 7 ++++--- 14 files changed, 30 insertions(+), 25 deletions(-) diff --git a/Glamourer/Designs/DesignBase.cs b/Glamourer/Designs/DesignBase.cs index 95b10f1..0971f02 100644 --- a/Glamourer/Designs/DesignBase.cs +++ b/Glamourer/Designs/DesignBase.cs @@ -278,7 +278,7 @@ public class DesignBase => new() { ["ItemId"] = id.Id, - ["Stain"] = stains.ToString(), + ["Stain"] = stains.ToString(), // Maybe change the "Stain" into "Stains" ? ["Crest"] = crest, ["Apply"] = apply, ["ApplyStain"] = applyStain, @@ -525,7 +525,7 @@ public class DesignBase static (CustomItemId, StainIds, bool, bool, bool, bool) ParseItem(EquipSlot slot, JToken? item) { var id = item?["ItemId"]?.ToObject() ?? ItemManager.NothingId(slot).Id; - var stains = (item?["Stain"]?.ToObject() ?? StainIds.None); + var stains = (item?["Stain"]?.ToObject() ?? StainIds.None); // Unsure var crest = item?["Crest"]?.ToObject() ?? false; var apply = item?["Apply"]?.ToObject() ?? false; var applyStain = item?["ApplyStain"]?.ToObject() ?? false; diff --git a/Glamourer/Designs/DesignConverter.cs b/Glamourer/Designs/DesignConverter.cs index 7d4eedb..b1b5c61 100644 --- a/Glamourer/Designs/DesignConverter.cs +++ b/Glamourer/Designs/DesignConverter.cs @@ -176,7 +176,7 @@ public class DesignConverter( return System.Convert.ToBase64String(compressed); } - public IEnumerable<(EquipSlot Slot, EquipItem Item, StainId Stain)> FromDrawData(IReadOnlyList armors, + public IEnumerable<(EquipSlot Slot, EquipItem Item, StainIds Stains)> FromDrawData(IReadOnlyList armors, CharacterWeapon mainhand, CharacterWeapon offhand, bool skipWarnings) { if (armors.Count != 10) @@ -194,7 +194,7 @@ public class DesignConverter( item = ItemManager.NothingItem(slot); } - yield return (slot, item, armor.Stains.Stain1); // To change + yield return (slot, item, armor.Stains); } var mh = _items.Identify(EquipSlot.MainHand, mainhand.Skeleton, mainhand.Weapon, mainhand.Variant); @@ -204,7 +204,7 @@ public class DesignConverter( mh = _items.DefaultSword; } - yield return (EquipSlot.MainHand, mh, mainhand.Stains.Stain1); // To change + yield return (EquipSlot.MainHand, mh, mainhand.Stains); var oh = _items.Identify(EquipSlot.OffHand, offhand.Skeleton, offhand.Weapon, offhand.Variant, mh.Type); if (!skipWarnings && !oh.Valid) @@ -215,7 +215,7 @@ public class DesignConverter( oh = ItemManager.NothingItem(FullEquipType.Shield); } - yield return (EquipSlot.OffHand, oh, offhand.Stains.Stain1); // To change + yield return (EquipSlot.OffHand, oh, offhand.Stains); } private static void ComputeMaterials(DesignMaterialManager manager, in StateMaterialManager materials, diff --git a/Glamourer/Designs/DesignData.cs b/Glamourer/Designs/DesignData.cs index f0d242b..4f4380b 100644 --- a/Glamourer/Designs/DesignData.cs +++ b/Glamourer/Designs/DesignData.cs @@ -161,6 +161,8 @@ public unsafe struct DesignData public bool SetStain(EquipSlot slot, StainIds stains) => slot.ToIndex() switch { + // Those need to be changed + 0 => SetIfDifferent(ref _equipmentBytes[3], stains), 1 => SetIfDifferent(ref _equipmentBytes[7], stains), 2 => SetIfDifferent(ref _equipmentBytes[11], stains), diff --git a/Glamourer/GameData/NpcData.cs b/Glamourer/GameData/NpcData.cs index 334ad9b..7c6da4c 100644 --- a/Glamourer/GameData/NpcData.cs +++ b/Glamourer/GameData/NpcData.cs @@ -56,7 +56,7 @@ public unsafe struct NpcData .Append('-') .Append(span[i].Variant.Id.ToString("D3")) .Append('-') - .Append(span[i].Stains.ToString()) + .Append(span[i].Stains.ToString()) // Unsure .Append(", "); } @@ -66,7 +66,7 @@ public unsafe struct NpcData .Append('-') .Append(Mainhand.Variant.Id.ToString("D3")) .Append('-') - .Append(Mainhand.Stains.ToString()) + .Append(Mainhand.Stains.ToString()) // Unsure .Append(", ") .Append(Offhand.Skeleton.Id.ToString("D4")) .Append('-') @@ -74,7 +74,7 @@ public unsafe struct NpcData .Append('-') .Append(Offhand.Variant.Id.ToString("D3")) .Append('-') - .Append(Offhand.Stains.ToString()); + .Append(Offhand.Stains.ToString()); // Unsure return sb.ToString(); } diff --git a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs index f6e9fd7..24315e3 100644 --- a/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/ModelEvaluationPanel.cs @@ -221,7 +221,7 @@ public unsafe class ModelEvaluationPanel( if (ImGui.SmallButton("Change Piece")) _updateSlotService.UpdateArmor(model, slot, - new CharacterArmor((PrimaryId)(slot == EquipSlot.Hands ? 6064 : slot == EquipSlot.Head ? 6072 : 1), 1, new())); + new CharacterArmor((PrimaryId)(slot == EquipSlot.Hands ? 6064 : slot == EquipSlot.Head ? 6072 : 1), 1, StainIds.None)); ImGui.SameLine(); if (ImGui.SmallButton("Change Stain")) _updateSlotService.UpdateStain(model, slot, StainIds.None); diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs index e0d4e1b..e289eb3 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockOverview.cs @@ -234,7 +234,9 @@ public class UnlockOverview } if (item.Flags.HasFlag(ItemFlags.IsDyable1)) - ImGui.TextUnformatted("Dyable"); + ImGui.TextUnformatted("Dyable1"); + if (item.Flags.HasFlag(ItemFlags.IsDyable2)) + ImGui.TextUnformatted("Dyable2"); if (item.Flags.HasFlag(ItemFlags.IsTradable)) ImGui.TextUnformatted("Tradable"); if (item.Flags.HasFlag(ItemFlags.IsCrestWorthy)) diff --git a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs index 57004cb..a020f5b 100644 --- a/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs +++ b/Glamourer/Gui/Tabs/UnlocksTab/UnlockTable.cs @@ -384,7 +384,7 @@ public class UnlockTable : Table, IDisposable => Tooltip = "Whether the item is dyable."; protected override bool GetValue(EquipItem item) - => item.Flags.HasFlag(ItemFlags.IsDyable1); + => item.Flags.HasFlag(ItemFlags.IsDyable1); // Unsure } private sealed class TradableColumn : YesNoColumn diff --git a/Glamourer/Interop/ChangeCustomizeService.cs b/Glamourer/Interop/ChangeCustomizeService.cs index c4317af..7156c95 100644 --- a/Glamourer/Interop/ChangeCustomizeService.cs +++ b/Glamourer/Interop/ChangeCustomizeService.cs @@ -36,7 +36,7 @@ public unsafe class ChangeCustomizeService : EventWrapperRef2)Human.MemberFunctionPointers.UpdateDrawData; + _original = (delegate* unmanaged[Stdcall])Human.MemberFunctionPointers.UpdateDrawData; // Unsure interop.InitializeFromAttributes(this); _penumbraReloaded.Subscribe(Restore, PenumbraReloaded.Priority.ChangeCustomizeService); } diff --git a/Glamourer/Interop/CharaFile/CmaFile.cs b/Glamourer/Interop/CharaFile/CmaFile.cs index 867e4d1..a232386 100644 --- a/Glamourer/Interop/CharaFile/CmaFile.cs +++ b/Glamourer/Interop/CharaFile/CmaFile.cs @@ -82,7 +82,7 @@ public sealed class CmaFile var set = mainhand["Item1"]?.ToObject() ?? items.DefaultSword.PrimaryId; var type = mainhand["Item2"]?.ToObject() ?? items.DefaultSword.SecondaryId; var variant = mainhand["Item3"]?.ToObject() ?? items.DefaultSword.Variant; - var stains = mainhand["Item4"]?.ToObject() ?? StainIds.None; + var stains = mainhand["Item4"]?.ToObject() ?? StainIds.None; // Unsure var item = items.Identify(EquipSlot.MainHand, set, type, variant); data.SetItem(EquipSlot.MainHand, item.Valid ? item : items.DefaultSword); diff --git a/Glamourer/Interop/Material/PrepareColorSet.cs b/Glamourer/Interop/Material/PrepareColorSet.cs index 96b37bc..5d312e8 100644 --- a/Glamourer/Interop/Material/PrepareColorSet.cs +++ b/Glamourer/Interop/Material/PrepareColorSet.cs @@ -91,14 +91,14 @@ public sealed unsafe class PrepareColorSet switch (index.DrawObject) { case MaterialValueIndex.DrawObjectType.Human: - return index.SlotIndex < 10 ? actor.Model.GetArmor(((uint)index.SlotIndex).ToEquipSlot()).Stains : new(); + return index.SlotIndex < 10 ? actor.Model.GetArmor(((uint)index.SlotIndex).ToEquipSlot()).Stains : StainIds.None; case MaterialValueIndex.DrawObjectType.Mainhand: var mainhand = (Model)actor.AsCharacter->DrawData.WeaponDataSpan[1].DrawObject; - return mainhand.IsWeapon ? (StainId)mainhand.AsWeapon->ModelUnknown : new(); + return mainhand.IsWeapon ? (StainId)mainhand.AsWeapon->ModelUnknown : StainIds.None; case MaterialValueIndex.DrawObjectType.Offhand: var offhand = (Model)actor.AsCharacter->DrawData.WeaponDataSpan[1].DrawObject; - return offhand.IsWeapon ? (StainId)offhand.AsWeapon->ModelUnknown : new(); - default: return new(); + return offhand.IsWeapon ? (StainId)offhand.AsWeapon->ModelUnknown : StainIds.None; + default: return StainIds.None; } } } diff --git a/Glamourer/Interop/MetaService.cs b/Glamourer/Interop/MetaService.cs index d3c3c4e..335c983 100644 --- a/Glamourer/Interop/MetaService.cs +++ b/Glamourer/Interop/MetaService.cs @@ -48,7 +48,7 @@ public unsafe class MetaService : IDisposable if (!actor.IsCharacter) return; - actor.AsCharacter->DrawData.SetVisor(value); + actor.AsCharacter->DrawData.SetVisor(value); // Unsure // The function seems to not do anything if the head is 0, but also breaks for carbuncles turned human, sometimes? /* var old = actor.AsCharacter->DrawData.Head.Id; diff --git a/Glamourer/Services/ItemManager.cs b/Glamourer/Services/ItemManager.cs index 318d9da..4be7035 100644 --- a/Glamourer/Services/ItemManager.cs +++ b/Glamourer/Services/ItemManager.cs @@ -197,7 +197,7 @@ public class ItemManager /// public string ValidateStain(StainIds stains, out StainIds ret, bool allowUnknown) { - if (allowUnknown || IsStainValid(stains[0]) && IsStainValid(stains[1])) + if (allowUnknown || IsStainValid(stains[0]) && IsStainValid(stains[1])) // Unsure { ret = stains; return string.Empty; diff --git a/Glamourer/State/FunEquipSet.cs b/Glamourer/State/FunEquipSet.cs index 8610a08..57bedf3 100644 --- a/Glamourer/State/FunEquipSet.cs +++ b/Glamourer/State/FunEquipSet.cs @@ -21,8 +21,8 @@ internal class FunEquipSet { public Group(ushort headS, byte headV, ushort bodyS, byte bodyV, ushort handsS, byte handsV, ushort legsS, byte legsV, ushort feetS, byte feetV, StainId[]? stains = null) - : this(new CharacterArmor(headS, headV, new()), new CharacterArmor(bodyS, bodyV, new()), new CharacterArmor(handsS, handsV, new()), - new CharacterArmor(legsS, legsV, new()), new CharacterArmor(feetS, feetV, new()), stains) + : this(new CharacterArmor(headS, headV, StainIds.None), new CharacterArmor(bodyS, bodyV, StainIds.None), new CharacterArmor(handsS, handsV, StainIds.None), + new CharacterArmor(legsS, legsV, StainIds.None), new CharacterArmor(feetS, feetV, StainIds.None), stains) { } public static Group FullSetWithoutHat(ushort modelSet, byte variant, StainId[]? stains = null) diff --git a/Glamourer/State/FunModule.cs b/Glamourer/State/FunModule.cs index 62efc98..144e6a0 100644 --- a/Glamourer/State/FunModule.cs +++ b/Glamourer/State/FunModule.cs @@ -106,7 +106,7 @@ public unsafe class FunModule : IDisposable && actor.OnlineStatus is OnlineStatus.PvEMentor or OnlineStatus.PvPMentor or OnlineStatus.TradeMentor && slot.IsEquipment()) { - armor = new CharacterArmor(6117, 1, new()); + armor = new CharacterArmor(6117, 1, StainIds.None); return; } @@ -237,6 +237,7 @@ public unsafe class FunModule : IDisposable private static IReadOnlyList DolphinBodies => [ + // Unsure about those new CharacterArmor(6089, 1, new(4, 4)), // Toad new CharacterArmor(6089, 1, new(4, 4)), // Toad new CharacterArmor(6089, 1, new(4, 4)), // Toad @@ -255,7 +256,7 @@ public unsafe class FunModule : IDisposable armor = slot switch { EquipSlot.Body => DolphinBodies[_rng.Next(0, DolphinBodies.Count - 1)], - EquipSlot.Head => new CharacterArmor(5040, 1, new(0, 0)), + EquipSlot.Head => new CharacterArmor(5040, 1, StainIds.None), _ => armor, }; } @@ -272,7 +273,7 @@ public unsafe class FunModule : IDisposable private static void SetCrown(Span armor) { - var clown = new CharacterArmor(6117, 1, new()); + var clown = new CharacterArmor(6117, 1, StainIds.None); armor[0] = clown; armor[1] = clown; armor[2] = clown;