diff --git a/Dalamud/Dalamud.cs b/Dalamud/Dalamud.cs index b07bf2594..953637240 100644 --- a/Dalamud/Dalamud.cs +++ b/Dalamud/Dalamud.cs @@ -279,7 +279,7 @@ namespace Dalamud var offset = timeZone.GetUtcOffset(DateTime.UtcNow); var config = Service.Get(); - config.Fools22New = offset.Hours < 1; + config.Fools22New ??= offset.Hours < 1; config.Save(); this.fools22 = new Fools22(); diff --git a/Dalamud/Fools22.cs b/Dalamud/Fools22.cs index c25a1746f..b222c8e5b 100644 --- a/Dalamud/Fools22.cs +++ b/Dalamud/Fools22.cs @@ -17,6 +17,7 @@ using Dalamud.Interface; using Dalamud.Interface.Animation; using Dalamud.Interface.Animation.EasingFunctions; using Dalamud.Interface.Internal; +using Dalamud.Memory; using Dalamud.Utility; using ImGuiNET; using ImGuiScene; @@ -313,7 +314,10 @@ public class Fools22 : IDisposable this.time.Reset(); this.time.Start(); - this.player.Play(); + if (this.CheckIsSfxEnabled()) + { + this.player.Play(); + } } private bool CheckFoolsApplicable() @@ -329,6 +333,51 @@ public class Fools22 : IDisposable return this.assetsReady; } + private unsafe bool CheckIsSfxEnabled() + { + try + { + var framework = FFXIVClientStructs.FFXIV.Client.System.Framework.Framework.Instance(); + var configBase = framework->SystemConfig.CommonSystemConfig.ConfigBase; + + var seEnabled = false; + var masterEnabled = false; + + for (var i = 0; i < configBase.ConfigCount; i++) + { + var entry = configBase.ConfigEntry[i]; + + if (entry.Name != null) + { + var name = MemoryHelper.ReadStringNullTerminated(new IntPtr(entry.Name)); + + if (name == "IsSndSe") + { + var value = entry.Value.UInt; + Log.Information("Fools21: {Name} - {Type} - {Value}", name, entry.Type, value); + + seEnabled = value == 0; + } + + if (name == "IsSndMaster") + { + var value = entry.Value.UInt; + Log.Information("Fools21: {Name} - {Type} - {Value}", name, entry.Type, value); + + masterEnabled = value == 0; + } + } + } + + return seEnabled && masterEnabled; + } + catch (Exception ex) + { + Log.Error(ex, "Fools21: Error checking if sfx is enabled"); + return true; + } + } + public void Dispose() { this.erDeathBgTexture.Dispose();