diff --git a/NominaOcculta/AppearanceRepository.cs b/NominaOcculta/AppearanceRepository.cs index ed4cabb..3827695 100755 --- a/NominaOcculta/AppearanceRepository.cs +++ b/NominaOcculta/AppearanceRepository.cs @@ -9,7 +9,7 @@ namespace NominaOcculta; internal class AppearanceRepository { private Plugin Plugin { get; } private List Npcs { get; } - private List PersonalNpcs { get; } + private List PersonalNpcs { get; } = new(); private int Salt { get; set; } = new Random().Next(); private static readonly string[] Exclude = { @@ -54,6 +54,7 @@ internal class AppearanceRepository { .Where(row => row.ModelLegs != 0) .Where(row => !Exclude.Contains(names.GetRow(row.RowId)?.Singular.RawString)) .ToList(); + this.RefilterPersonal(); PluginLog.Log($"npcs: {this.Npcs.Count}"); } @@ -65,7 +66,7 @@ internal class AppearanceRepository { this.PersonalNpcs.Clear(); this.PersonalNpcs.AddRange(this.Npcs .Where(row => { - var sex = (Sex) (row.Gender + 1); + var sex = (Sex) (1 << (row.Gender + 1)); return this.Plugin.Config.PreferredSex.HasFlag(sex); }) .Where(row => { @@ -87,7 +88,7 @@ internal class AppearanceRepository { } internal ENpcBase GetNpc(uint objectId) { - if (objectId == this.Plugin.ClientState.LocalPlayer?.ObjectId) { + if (objectId == this.Plugin.ClientState.LocalPlayer?.ObjectId && this.PersonalNpcs.Count > 0) { return this.PersonalNpcs[this.GetNpcIndexPersonal(objectId)]; } diff --git a/NominaOcculta/Obscurer.cs b/NominaOcculta/Obscurer.cs index 483c9bc..0e0689a 100755 --- a/NominaOcculta/Obscurer.cs +++ b/NominaOcculta/Obscurer.cs @@ -79,6 +79,10 @@ internal class Obscurer : IDisposable { } private unsafe bool ShouldObscureAppearance(GameObject* gameObj) { + if (gameObj == null) { + return false; + } + if (gameObj->ObjectKind != (byte) FFXIVClientStructs.FFXIV.Client.Game.Object.ObjectKind.Pc) { return false; } @@ -99,14 +103,14 @@ internal class Obscurer : IDisposable { return false; } - if (!this.Plugin.Config.ObscureAppearancesSelf && chara.ObjectId == this.Plugin.ClientState.LocalPlayer?.ObjectId) { - return false; + if (this.Plugin.Config.ObscureAppearancesSelf && chara.ObjectId == this.Plugin.ClientState.LocalPlayer?.ObjectId) { + return true; } var party = this.Plugin.PartyList.Select(member => member.ObjectId).ToArray(); var inParty = party.Contains(chara.ObjectId); - if (!this.Plugin.Config.ObscureAppearancesParty && inParty) { - return false; + if (this.Plugin.Config.ObscureAppearancesParty && inParty) { + return true; } return this.Plugin.Config.ObscureAppearancesOthers; @@ -376,7 +380,6 @@ internal class Obscurer : IDisposable { ); } - Real: return ( chara.Customize[(byte) CustomizeIndex.Race], (byte) ((chara.Customize[(byte) CustomizeIndex.Tribe] - 1) % 2), diff --git a/NominaOcculta/PluginUi.cs b/NominaOcculta/PluginUi.cs index cf9b303..9810240 100755 --- a/NominaOcculta/PluginUi.cs +++ b/NominaOcculta/PluginUi.cs @@ -54,7 +54,7 @@ internal class PluginUi : IDisposable { anyChanged |= ImGui.Checkbox("Obscure appearance of self", ref this.Plugin.Config.ObscureAppearancesSelf); anyChanged |= ImGui.Checkbox("Obscure appearance of party members", ref this.Plugin.Config.ObscureAppearancesParty); anyChanged |= ImGui.Checkbox("Obscure appearance of others", ref this.Plugin.Config.ObscureAppearancesOthers); - anyChanged |= ImGui.Checkbox("Exclude friends", ref this.Plugin.Config.ObscureAppearancesExcludeFriends); + anyChanged |= ImGui.Checkbox("Exclude friends##appearance", ref this.Plugin.Config.ObscureAppearancesExcludeFriends); ImGui.Separator(); @@ -72,6 +72,10 @@ internal class PluginUi : IDisposable { ImGui.TextUnformatted("Race"); foreach (var race in this.Plugin.DataManager.GetExcelSheet()!) { + if (race.RowId == 0) { + continue; + } + var tribe1 = this.Plugin.DataManager.GetExcelSheet()!.GetRow(race.RowId * 2 - 1)!; var tribe2 = this.Plugin.DataManager.GetExcelSheet()!.GetRow(race.RowId * 2)!; @@ -98,6 +102,7 @@ internal class PluginUi : IDisposable { if (anyChanged) { this.Plugin.SaveConfig(); + this.Plugin.AppearanceRepository.RefilterPersonal(); } ImGui.Separator();