diff --git a/PostNamazu/Actions/WayMark.cs b/PostNamazu/Actions/WayMark.cs index 6d6f9eb..624b460 100644 --- a/PostNamazu/Actions/WayMark.cs +++ b/PostNamazu/Actions/WayMark.cs @@ -204,7 +204,7 @@ public void Public(WayMarks waymarks) { if (waymarks == null || waymarks.All(waymark => waymark?.Active == false)) { // clear all - Memory.CallInjected64(ExecuteCommandPtr, 313, 0, 0, 0, 0); + ExecuteCommand(313); if (waymarks == null) { Log(GetLocalizedString("ClearPublic")); @@ -219,17 +219,24 @@ public void Public(WayMarks waymarks) if (waymark == null) continue; if (waymark.Active) { // mark single - Memory.CallInjected64(ExecuteCommandPtr, 317, idx, (int)(waymark.X * 1000), (int)(waymark.Y * 1000), (int)(waymark.Z * 1000)); + ExecuteCommand(317, (uint)idx, UIntEncode(waymark.X), UIntEncode(waymark.Y), UIntEncode(waymark.Z)); } else { // clear single - Memory.CallInjected64(ExecuteCommandPtr, 318, idx, 0, 0, 0); + ExecuteCommand(318, (uint)idx); } } } }); } + private uint UIntEncode(float x) => (uint)(x * 1000); + + // 统一使用 uint 调用此内部函数(参数常用于传入 id 等,uint 相比于 int 更合理) + // 防止 GreyMagic 多次调用时参数类型不一致报错 + private void ExecuteCommand(uint command, uint a1 = 0, uint a2 = 0, uint a3 = 0, uint a4 = 0) + => Memory.CallInjected64(ExecuteCommandPtr, command, a1, a2, a3, a4); + public bool GetInCombat() { var op = ActGlobals.oFormActMain.ActPlugins diff --git a/PostNamazu/Controls/PostNamazuUi.cs b/PostNamazu/Controls/PostNamazuUi.cs index 34f136f..159f5ac 100644 --- a/PostNamazu/Controls/PostNamazuUi.cs +++ b/PostNamazu/Controls/PostNamazuUi.cs @@ -266,7 +266,7 @@ public void btnWaymarksExport_Click(object sender, EventArgs e) string data; try { - data = GetCurrentWarmarksString(); + data = GetCurrentWaymarksString(); Clipboard.SetText(data); MessageBox.Show(I18n.Translate("PostNamazuUi/ExportWaymarks", "已将标点文本存入剪贴板。"), "PostNamazu", MessageBoxButtons.OK, MessageBoxIcon.Information); } @@ -277,7 +277,7 @@ public void btnWaymarksExport_Click(object sender, EventArgs e) } } - public static string GetCurrentWarmarksString() + public static string GetCurrentWaymarksString() { WayMarks waymarks = PostNamazu.Plugin.GetModuleInstance().ReadCurrentWaymarks(); return waymarks.ToJsonString(); diff --git a/PostNamazu/PostNamazu.cs b/PostNamazu/PostNamazu.cs index db9d8d7..490a237 100644 --- a/PostNamazu/PostNamazu.cs +++ b/PostNamazu/PostNamazu.cs @@ -100,6 +100,7 @@ public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText) Assembly.Load("GreyMagic"); // 直接加载而非首次调用时延迟加载,防止没开启游戏而没调用 GreyMagic 初始化 Memory 时其他插件找不到 GreyMagic _lblStatus.Text = I18n.Translate("PostNamazu/PluginInit", "鲶鱼精邮差已启动。"); + LogACT("Initialized"); } public void DeInitPlugin() @@ -205,6 +206,7 @@ private void Attach() Memory = new ExternalProcessMemory(FFXIV, true, false, _entrancePtr, false, 5, true); PluginUI.Log(I18n.Translate("PostNamazu/XivProcInject", "已找到 FFXIV 进程 {0}。", FFXIV.Id)); State = StateEnum.Ready; + LogACT("Attached"); foreach (var m in Modules) { @@ -217,6 +219,7 @@ private void Attach() { m.Setup(); } + LogACT("ModulesInitialized"); } /// @@ -415,6 +418,12 @@ private void LogRegion() ); } + internal void LogACT(string msg) + { + var log = $"00|{DateTime.Now:O}|FFFF|PostNamazu|{msg}|0000000000000000"; + ActGlobals.oFormActMain.ParseRawLogLine(false, DateTime.Now, log); + } + /// /// 代替ProcessChanged委托,手动循环检测当前活动进程并进行注入。 ///