mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-27 19:09:18 +01:00
Merge remote-tracking branch 'origin/master' into fools23
This commit is contained in:
commit
88a665cb58
10 changed files with 72 additions and 19 deletions
|
|
@ -355,17 +355,17 @@ internal sealed class DalamudConfiguration : IServiceType
|
|||
/// Gets or sets hitch threshold for game network up in milliseconds.
|
||||
/// </summary>
|
||||
public double GameNetworkUpHitch { get; set; } = 30;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets hitch threshold for game network down in milliseconds.
|
||||
/// </summary>
|
||||
public double GameNetworkDownHitch { get; set; } = 30;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets hitch threshold for framework update in milliseconds.
|
||||
/// </summary>
|
||||
public double FrameworkUpdateHitch { get; set; } = 50;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets hitch threshold for ui builder in milliseconds.
|
||||
/// </summary>
|
||||
|
|
@ -428,7 +428,7 @@ internal sealed class DalamudConfiguration : IServiceType
|
|||
{
|
||||
ThreadSafety.AssertMainThread();
|
||||
|
||||
File.WriteAllText(this.configPath, JsonConvert.SerializeObject(this, SerializerSettings));
|
||||
Util.WriteAllTextSafe(this.configPath, JsonConvert.SerializeObject(this, SerializerSettings));
|
||||
this.DalamudConfigurationSaved?.Invoke(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System.IO;
|
||||
|
||||
using Dalamud.Utility;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dalamud.Configuration;
|
||||
|
|
@ -32,7 +33,7 @@ public sealed class PluginConfigurations
|
|||
/// <param name="pluginName">Plugin name.</param>
|
||||
public void Save(IPluginConfiguration config, string pluginName)
|
||||
{
|
||||
File.WriteAllText(this.GetConfigFile(pluginName).FullName, SerializeConfig(config));
|
||||
Util.WriteAllTextSafe(this.GetConfigFile(pluginName).FullName, SerializeConfig(config));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -125,6 +125,17 @@
|
|||
<TempVerFile>$(OutputPath)TEMP_gitver.txt</TempVerFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="GetGitCommitCount" BeforeTargets="WriteGitHash" Condition="'$(CommitCount)'==''">
|
||||
<Exec Command="git -C "$(ProjectDir.Replace('\','\\'))" rev-list --count HEAD" ConsoleToMSBuild="true">
|
||||
<Output TaskParameter="ConsoleOutput" PropertyName="DalamudGitCommitCount" />
|
||||
</Exec>
|
||||
|
||||
<!-- Set the BuildHash property to contain the GitVersion, if it wasn't already set.-->
|
||||
<PropertyGroup>
|
||||
<CommitCount>$([System.Text.RegularExpressions.Regex]::Replace($(DalamudGitCommitCount), @"\t|\n|\r", ""))</CommitCount>
|
||||
</PropertyGroup>
|
||||
</Target>
|
||||
|
||||
<Target Name="GetGitHash" BeforeTargets="WriteGitHash" Condition="'$(BuildHash)'=='' And '$(Configuration)'=='Release'">
|
||||
<!-- write the hash to the temp file.-->
|
||||
<Exec Command="git -C "$(ProjectDir.Replace('\','\\'))" describe --long --always --dirty" ConsoleToMSBuild="true">
|
||||
|
|
@ -171,6 +182,10 @@
|
|||
<_Parameter1>GitHash</_Parameter1>
|
||||
<_Parameter2>$(BuildHash)</_Parameter2>
|
||||
</AssemblyAttributes>
|
||||
<AssemblyAttributes Include="AssemblyMetadata">
|
||||
<_Parameter1>GitCommitCount</_Parameter1>
|
||||
<_Parameter2>$(CommitCount)</_Parameter2>
|
||||
</AssemblyAttributes>
|
||||
<AssemblyAttributes Include="AssemblyMetadata">
|
||||
<_Parameter1>GitHashClientStructs</_Parameter1>
|
||||
<_Parameter2>$(BuildHashClientStructs)</_Parameter2>
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public sealed class GameConfig : IServiceType
|
|||
public GameConfigSection UiConfig { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of config options that are control mode specific. (Mouse & Keyboard / Gamepad).
|
||||
/// Gets the collection of config options that are control mode specific. (Mouse and Keyboard / Gamepad).
|
||||
/// </summary>
|
||||
public GameConfigSection UiControl { get; private set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,14 @@ internal class FunctionPointerVariableHook<T> : Hook<T>
|
|||
|
||||
unsafe
|
||||
{
|
||||
var pfnThunkBytes = (byte*)NativeFunctions.HeapAlloc(HookManager.NoFreeExecutableHeap, 0, 12);
|
||||
// Note: WINE seemingly tries to clean up all heap allocations on process exit.
|
||||
// We want our allocation to be kept there forever, until no running thread remains.
|
||||
// Therefore we're using VirtualAlloc instead of HeapCreate/HeapAlloc.
|
||||
var pfnThunkBytes = (byte*)NativeFunctions.VirtualAlloc(
|
||||
0,
|
||||
12,
|
||||
NativeFunctions.AllocationType.Reserve | NativeFunctions.AllocationType.Commit,
|
||||
MemoryProtection.ExecuteReadWrite);
|
||||
if (pfnThunkBytes == null)
|
||||
{
|
||||
throw new OutOfMemoryException("Failed to allocate memory for import hooks.");
|
||||
|
|
|
|||
|
|
@ -16,13 +16,6 @@ namespace Dalamud.Hooking.Internal;
|
|||
[ServiceManager.EarlyLoadedService]
|
||||
internal class HookManager : IDisposable, IServiceType
|
||||
{
|
||||
/// <summary>
|
||||
/// Handle to an executable heap that we shall never free anything unless we can be absolutely sure that nothing is
|
||||
/// referencing to it anymore.
|
||||
/// </summary>
|
||||
internal static readonly nint NoFreeExecutableHeap =
|
||||
NativeFunctions.HeapCreate(NativeFunctions.HeapOptions.CreateEnableExecute, 0, 0);
|
||||
|
||||
private static readonly ModuleLog Log = new("HM");
|
||||
|
||||
[ServiceManager.ServiceConstructor]
|
||||
|
|
|
|||
|
|
@ -706,7 +706,7 @@ internal class DalamudInterface : IDisposable, IServiceType
|
|||
{
|
||||
this.OpenProfiler();
|
||||
}
|
||||
|
||||
|
||||
if (ImGui.MenuItem("Open Hitch Settings"))
|
||||
{
|
||||
this.OpenHitchSettings();
|
||||
|
|
@ -768,7 +768,7 @@ internal class DalamudInterface : IDisposable, IServiceType
|
|||
|
||||
ImGui.MenuItem(Util.AssemblyVersion, false);
|
||||
ImGui.MenuItem(startInfo.GameVersion?.ToString() ?? "Unknown version", false);
|
||||
ImGui.MenuItem($"D: {Util.GetGitHash()} CS: {Util.GetGitHashClientStructs()} [{FFXIVClientStructs.Interop.Resolver.Version}]", false);
|
||||
ImGui.MenuItem($"D: {Util.GetGitHash()}[{Util.GetGitCommitCount()}] CS: {Util.GetGitHashClientStructs()}[{FFXIVClientStructs.Interop.Resolver.Version}]", false);
|
||||
ImGui.MenuItem($"CLR: {Environment.Version}", false);
|
||||
|
||||
ImGui.EndMenu();
|
||||
|
|
@ -944,7 +944,7 @@ internal class DalamudInterface : IDisposable, IServiceType
|
|||
{
|
||||
ImGui.PushFont(InterfaceManager.MonoFont);
|
||||
|
||||
ImGui.BeginMenu(Util.GetGitHash(), false);
|
||||
ImGui.BeginMenu($"{Util.GetGitHash()}({Util.GetGitCommitCount()})", false);
|
||||
ImGui.BeginMenu(this.FrameCount.ToString("000000"), false);
|
||||
ImGui.BeginMenu(ImGui.GetIO().Framerate.ToString("000"), false);
|
||||
ImGui.BeginMenu($"W:{Util.FormatBytes(GC.GetTotalMemory(false))}", false);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ internal record LocalPluginManifest : PluginManifest
|
|||
/// Save a plugin manifest to file.
|
||||
/// </summary>
|
||||
/// <param name="manifestFile">Path to save at.</param>
|
||||
public void Save(FileInfo manifestFile) => File.WriteAllText(manifestFile.FullName, JsonConvert.SerializeObject(this, Formatting.Indented));
|
||||
public void Save(FileInfo manifestFile) => Util.WriteAllTextSafe(manifestFile.FullName, JsonConvert.SerializeObject(this, Formatting.Indented));
|
||||
|
||||
/// <summary>
|
||||
/// Loads a plugin manifest from file.
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ namespace Dalamud.Utility;
|
|||
public static class Util
|
||||
{
|
||||
private static string? gitHashInternal;
|
||||
private static int? gitCommitCountInternal;
|
||||
private static string? gitHashClientStructsInternal;
|
||||
|
||||
private static ulong moduleStartAddr;
|
||||
|
|
@ -114,6 +115,26 @@ public static class Util
|
|||
return gitHashInternal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the amount of commits in the current branch, or null if undetermined.
|
||||
/// </summary>
|
||||
/// <returns>The amount of commits in the current branch.</returns>
|
||||
public static int? GetGitCommitCount()
|
||||
{
|
||||
if (gitCommitCountInternal != null)
|
||||
return gitCommitCountInternal.Value;
|
||||
|
||||
var asm = typeof(Util).Assembly;
|
||||
var attrs = asm.GetCustomAttributes<AssemblyMetadataAttribute>();
|
||||
|
||||
var value = attrs.First(a => a.Key == "GitCommitCount").Value;
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
gitCommitCountInternal = int.Parse(value);
|
||||
return gitCommitCountInternal.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the git hash value from the assembly
|
||||
/// or null if it cannot be found.
|
||||
|
|
@ -568,6 +589,22 @@ public static class Util
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overwrite text in a file by first writing it to a temporary file, and then
|
||||
/// moving that file to the path specified.
|
||||
/// </summary>
|
||||
/// <param name="path">The path of the file to write to.</param>
|
||||
/// <param name="text">The text to write.</param>
|
||||
internal static void WriteAllTextSafe(string path, string text)
|
||||
{
|
||||
var tmpPath = path + ".tmp";
|
||||
if (File.Exists(tmpPath))
|
||||
File.Delete(tmpPath);
|
||||
|
||||
File.WriteAllText(tmpPath, text);
|
||||
File.Move(tmpPath, path, true);
|
||||
}
|
||||
|
||||
private static unsafe void ShowValue(ulong addr, IEnumerable<string> path, Type type, object value)
|
||||
{
|
||||
if (type.IsPointer)
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 9e97396f98c20eff17a71aacb24296efcaa04808
|
||||
Subproject commit 74345c97468f310d555929f4e40c844556bc64e7
|
||||
Loading…
Add table
Add a link
Reference in a new issue