Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions PostNamazu/Actions/WayMark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public void Public(WayMarks waymarks)
{
if (waymarks == null || waymarks.All(waymark => waymark?.Active == false))
{ // clear all
Memory.CallInjected64<IntPtr>(ExecuteCommandPtr, 313, 0, 0, 0, 0);
ExecuteCommand(313);
if (waymarks == null)
{
Log(GetLocalizedString("ClearPublic"));
Expand All @@ -219,17 +219,24 @@ public void Public(WayMarks waymarks)
if (waymark == null) continue;
if (waymark.Active)
{ // mark single
Memory.CallInjected64<IntPtr>(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<IntPtr>(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<IntPtr>(ExecuteCommandPtr, command, a1, a2, a3, a4);

public bool GetInCombat()
{
var op = ActGlobals.oFormActMain.ActPlugins
Expand Down
4 changes: 2 additions & 2 deletions PostNamazu/Controls/PostNamazuUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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<WayMark>().ReadCurrentWaymarks();
return waymarks.ToJsonString();
Expand Down
9 changes: 9 additions & 0 deletions PostNamazu/PostNamazu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
{
Expand All @@ -217,6 +219,7 @@ private void Attach()
{
m.Setup();
}
LogACT("ModulesInitialized");
}

/// <summary>
Expand Down Expand Up @@ -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);
}

/// <summary>
/// 代替ProcessChanged委托,手动循环检测当前活动进程并进行注入。
/// </summary>
Expand Down
Loading