Snapshot for release 2026.10.28.3 (internal db7f094)
This commit is contained in:
parent
636adfcef2
commit
e6642d0e10
102 changed files with 4821 additions and 782 deletions
|
|
@ -41,6 +41,8 @@
|
|||
<ItemGroup>
|
||||
<!-- Install-folder resolver (env, HKCU, HKLM, default C:\Games). Read only; same file as RynthCore src\Shared. -->
|
||||
<Compile Include="..\Shared\RynthInstallPaths.cs" Link="Shared\RynthInstallPaths.cs" />
|
||||
<!-- How a chat command answers (2026-10-28): the shared reply queue and colours. -->
|
||||
<Compile Include="..\Shared\CommandReply.cs" Link="Shared\CommandReply.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<!-- The Characters window (2026-10-21): RynthNet draws it with ImGui.NET bound to the engine's
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public sealed partial class RynthNetPlugin
|
|||
{
|
||||
if (!CommandParser.TagsAndRest(args, out List<string> tags, out string after))
|
||||
{
|
||||
ChatLine("usage: /rn bct <tag[,tag]> [delayMs] <command>");
|
||||
ChatFail("usage: /rn bct <tag[,tag]> [delayMs] <command>");
|
||||
break;
|
||||
}
|
||||
CommandParser.DelayAndCommand(after, out int delay, out string command);
|
||||
|
|
@ -57,12 +57,12 @@ public sealed partial class RynthNetPlugin
|
|||
var known = node.GetPeers().Select(p => p.Identity.Character).Where(c => c.Length > 0);
|
||||
if (!CommandParser.NameAndCommand(args, known, out string name, out string command))
|
||||
{
|
||||
ChatLine("usage: /rn tell <character>[,] <command>");
|
||||
ChatFail("usage: /rn tell <character>[,] <command>");
|
||||
break;
|
||||
}
|
||||
if (!node.GetPeers().Any(p => string.Equals(p.Identity.Character, name, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
ChatLine($"no client is playing {name} (/rn list).");
|
||||
ChatFail($"no client is playing {name} (/rn list).");
|
||||
break;
|
||||
}
|
||||
Report(SendCommand(new NetTarget(TargetKind.Character, name), command, 0, includeSelf: false), command, name);
|
||||
|
|
@ -93,7 +93,7 @@ public sealed partial class RynthNetPlugin
|
|||
break;
|
||||
case "followme":
|
||||
{
|
||||
if (!_loggedIn) { ChatLine("log in first."); break; }
|
||||
if (!_loggedIn) { ChatFail("log in first."); break; }
|
||||
NetTarget target = args.Length > 0 && CommandParser.TagsAndRest(args, out List<string> tags, out _)
|
||||
? new NetTarget(TargetKind.Tags, string.Join(",", tags)) : NetTarget.All;
|
||||
string command = "/ra follow " + _character;
|
||||
|
|
@ -104,7 +104,7 @@ public sealed partial class RynthNetPlugin
|
|||
case "useselected":
|
||||
{
|
||||
uint sel = Host.GetSelectedItemId();
|
||||
if (sel == 0) { ChatLine("select something first."); break; }
|
||||
if (sel == 0) { ChatFail("select something first."); break; }
|
||||
NetTarget target = args.Length > 0 && CommandParser.TagsAndRest(args, out List<string> tags, out _)
|
||||
? new NetTarget(TargetKind.Tags, string.Join(",", tags)) : NetTarget.All;
|
||||
// The same command UtilityBelt's network window sends (RynthAi's meta expressions run it).
|
||||
|
|
@ -113,7 +113,7 @@ public sealed partial class RynthNetPlugin
|
|||
break;
|
||||
}
|
||||
default:
|
||||
ChatLine($"unknown command '{verb}'. /rn help lists them.");
|
||||
ChatFail($"unknown command '{verb}'. /rn help lists them.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ public sealed partial class RynthNetPlugin
|
|||
{
|
||||
if (!CommandParser.TagsAndRest(args, out List<string> tags, out string after))
|
||||
{
|
||||
ChatLine("usage: /ub bct <tag[,tag]> [millisecondDelay] <command>");
|
||||
ChatFail("usage: /ub bct <tag[,tag]> [millisecondDelay] <command>");
|
||||
break;
|
||||
}
|
||||
CommandParser.DelayAndCommand(after, out int delay, out string command);
|
||||
|
|
@ -146,7 +146,7 @@ public sealed partial class RynthNetPlugin
|
|||
ListClients(node, args);
|
||||
break;
|
||||
default:
|
||||
ChatLine($"/ub {verb} isn't a network command.");
|
||||
ChatFail($"/ub {verb} isn't a network command.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ public sealed partial class RynthNetPlugin
|
|||
private void Report(List<string>? names, string command, string to)
|
||||
{
|
||||
if (names == null) return;
|
||||
if (names.Count == 0) { ChatLine($"nobody to send '{command}' to ({to}). /rn list shows the clients."); return; }
|
||||
if (names.Count == 0) { ChatFail($"nobody to send '{command}' to ({to}). /rn list shows the clients."); return; }
|
||||
ChatLine($"'{command}' -> {string.Join(", ", names)}");
|
||||
}
|
||||
|
||||
|
|
@ -188,7 +188,7 @@ public sealed partial class RynthNetPlugin
|
|||
{
|
||||
List<string> filter = new();
|
||||
if (args.Length > 0) CommandParser.TagsAndRest(args, out filter, out _);
|
||||
if (!node.IsRunning) { ChatLine("offline: " + (_offlineReason.Length > 0 ? _offlineReason : "stopped")); return; }
|
||||
if (!node.IsRunning) { ChatFail("offline: " + (_offlineReason.Length > 0 ? _offlineReason : "stopped")); return; }
|
||||
|
||||
var peers = new List<PeerInfo>(node.GetPeers());
|
||||
peers.Sort((a, b) => string.Compare(a.Identity.Character, b.Identity.Character, StringComparison.OrdinalIgnoreCase));
|
||||
|
|
@ -252,7 +252,7 @@ public sealed partial class RynthNetPlugin
|
|||
private void TagCommand(string args)
|
||||
{
|
||||
string verb = FirstWord(args, out string value).ToLowerInvariant();
|
||||
if (!_loggedIn) { ChatLine("log in first: tags belong to a character."); return; }
|
||||
if (!_loggedIn) { ChatFail("log in first: tags belong to a character."); return; }
|
||||
switch (verb)
|
||||
{
|
||||
case "":
|
||||
|
|
@ -260,12 +260,13 @@ public sealed partial class RynthNetPlugin
|
|||
ChatLine(MyTags.Count > 0 ? $"{_character}'s tags: {string.Join(", ", MyTags)}" : $"{_character} has no tags. /rn tag add <tag>");
|
||||
break;
|
||||
case "add":
|
||||
ChatLine(SetTag(value, on: true, out string whyAdd) ? $"tagged {_character}: {string.Join(", ", MyTags)}" : whyAdd);
|
||||
if (SetTag(value, on: true, out string whyAdd)) ChatLine($"tagged {_character}: {string.Join(", ", MyTags)}");
|
||||
else ChatFail(whyAdd);
|
||||
break;
|
||||
case "remove":
|
||||
case "rm":
|
||||
case "del":
|
||||
if (!SetTag(value, on: false, out string whyRemove)) ChatLine(whyRemove);
|
||||
if (!SetTag(value, on: false, out string whyRemove)) ChatFail(whyRemove);
|
||||
else ChatLine(MyTags.Count > 0 ? $"{_character}'s tags: {string.Join(", ", MyTags)}" : $"{_character} has no tags now.");
|
||||
break;
|
||||
case "clear":
|
||||
|
|
@ -273,7 +274,7 @@ public sealed partial class RynthNetPlugin
|
|||
if (UpdateSettings(s => s.Character(key).Tags.Clear())) ChatLine($"{_character} has no tags now.");
|
||||
break;
|
||||
default:
|
||||
ChatLine("usage: /rn tag [list | add <tag> | remove <tag> | clear]");
|
||||
ChatFail("usage: /rn tag [list | add <tag> | remove <tag> | clear]");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -308,7 +309,7 @@ public sealed partial class RynthNetPlugin
|
|||
{
|
||||
if (!node.IsRunning)
|
||||
{
|
||||
ChatLine("offline: " + (_offlineReason.Length > 0 ? _offlineReason : "stopped"));
|
||||
ChatFail("offline: " + (_offlineReason.Length > 0 ? _offlineReason : "stopped"));
|
||||
return;
|
||||
}
|
||||
RynthNetPolicy p = MyPolicy;
|
||||
|
|
@ -332,7 +333,7 @@ public sealed partial class RynthNetPlugin
|
|||
}
|
||||
else if (a is "on" or "off" or "default")
|
||||
{
|
||||
if (!_loggedIn) { ChatLine("log in first: the policy belongs to a character (the file's \"defaults\" cover the rest)."); return; }
|
||||
if (!_loggedIn) { ChatFail("log in first: the policy belongs to a character (the file's \"defaults\" cover the rest)."); return; }
|
||||
if (a == "default")
|
||||
UpdateSettings(s => { if (s.Characters.TryGetValue(key, out RynthNetCharacter? c)) c.Policy = null; });
|
||||
else
|
||||
|
|
@ -348,7 +349,7 @@ public sealed partial class RynthNetPlugin
|
|||
}
|
||||
else if (a.Length > 0)
|
||||
{
|
||||
ChatLine("usage: /rn remote on|off|default /rn remote log on|off");
|
||||
ChatFail("usage: /rn remote on|off|default /rn remote log on|off");
|
||||
return;
|
||||
}
|
||||
ChatLine($"commands from your other clients {(MyPolicy.AcceptRemoteCommands ? "run here" : "are refused here")}" +
|
||||
|
|
@ -368,10 +369,10 @@ public sealed partial class RynthNetPlugin
|
|||
}
|
||||
if (verb is not ("add" or "remove" or "rm" or "clear") || (verb != "clear" && value.Length == 0))
|
||||
{
|
||||
ChatLine($"usage: /rn {name} [list | add <x> | remove <x> | clear] - {meaning}");
|
||||
ChatFail($"usage: /rn {name} [list | add <x> | remove <x> | clear] - {meaning}");
|
||||
return;
|
||||
}
|
||||
if (!_loggedIn) { ChatLine("log in first: the policy belongs to a character (the file's \"defaults\" cover the rest)."); return; }
|
||||
if (!_loggedIn) { ChatFail("log in first: the policy belongs to a character (the file's \"defaults\" cover the rest)."); return; }
|
||||
bool had = select(MyPolicy).Exists(x => string.Equals(x, value, StringComparison.OrdinalIgnoreCase));
|
||||
string key = CharacterKey;
|
||||
bool saved = UpdateSettings(s =>
|
||||
|
|
@ -385,7 +386,7 @@ public sealed partial class RynthNetPlugin
|
|||
});
|
||||
if (!saved) return;
|
||||
List<string> now = select(MyPolicy);
|
||||
if (verb is "remove" or "rm" && !had) ChatLine($"{name} has no '{value}'.");
|
||||
if (verb is "remove" or "rm" && !had) ChatFail($"{name} has no '{value}'.");
|
||||
else ChatLine(now.Count == 0 ? $"{name}: empty." : $"{name}: {string.Join(" | ", now)}");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using RynthCore.Plugin.RynthNet.Transport;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.PluginCore;
|
||||
|
||||
namespace RynthCore.Plugin.RynthNet;
|
||||
|
|
@ -58,6 +59,7 @@ public sealed partial class RynthNetPlugin : RynthPluginBase
|
|||
|
||||
public override int Initialize()
|
||||
{
|
||||
_ = Reply;
|
||||
// The Characters window draws with ImGui.NET bound to the engine's cimgui, in the engine's look.
|
||||
RynthCore.Plugin.Shared.ImGuiNativeBinding.Ensure(msg => Host.Log("[RynthNet] " + msg));
|
||||
RynthCore.Plugin.Shared.RynthUi.RynthUi.Init(Host);
|
||||
|
|
@ -153,6 +155,7 @@ public sealed partial class RynthNetPlugin : RynthPluginBase
|
|||
|
||||
public override void OnTick()
|
||||
{
|
||||
Reply.Flush();
|
||||
NetNode? node = _node;
|
||||
if (node == null) return;
|
||||
long now = NetNode.NowMs;
|
||||
|
|
@ -184,7 +187,7 @@ public sealed partial class RynthNetPlugin : RynthPluginBase
|
|||
// A typed /ub bc: RynthAi, when loaded, saw the same line and forwards its own copy.
|
||||
if (queued.TypedUb && RynthAiLoaded()) continue;
|
||||
try { HandleLocal(node, queued.Line); }
|
||||
catch (Exception ex) { ChatLine($"'{queued.Line}' failed: {ex.Message}"); }
|
||||
catch (Exception ex) { ChatFail($"'{queued.Line}' failed: {ex.Message}"); }
|
||||
}
|
||||
|
||||
RunScheduled(now);
|
||||
|
|
@ -250,18 +253,29 @@ public sealed partial class RynthNetPlugin : RynthPluginBase
|
|||
});
|
||||
}
|
||||
|
||||
private void ChatLine(string text)
|
||||
// Chat lines wait in the shared reply queue (Plugins/Shared/CommandReply.cs): the host drops a line
|
||||
// within 100 ms of another plugin's, so /rn help's and /rn list's later lines used to go missing.
|
||||
private CommandReply? _reply;
|
||||
private CommandReply Reply => _reply ??= new CommandReply("[RynthNet]",
|
||||
(t, c) => Host.HasWriteToChat ? Host.WriteToChat(t, c) : LogInstead(t), t => Host.Log(t));
|
||||
|
||||
private bool LogInstead(string line)
|
||||
{
|
||||
if (Host.HasWriteToChat) Host.WriteToChat("[RynthNet] " + text, 1);
|
||||
else Host.Log("[RynthNet] " + text);
|
||||
Host.Log(line);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void ChatLine(string text) => Reply.Ok(text);
|
||||
|
||||
/// <summary>A command that didn't work: why, and the usage (the failure colour).</summary>
|
||||
private void ChatFail(string text) => Reply.Fail(text);
|
||||
|
||||
/// <summary>Applies one change to the shared settings file (merged with the other clients'), then pushes tags.</summary>
|
||||
private bool UpdateSettings(Action<RynthNetSettings> change)
|
||||
{
|
||||
if (!RynthNetSettings.Update(change, out RynthNetSettings current, out string? error))
|
||||
{
|
||||
ChatLine("couldn't save settings: " + error);
|
||||
ChatFail("couldn't save settings: " + error);
|
||||
return false;
|
||||
}
|
||||
_settings = current;
|
||||
|
|
@ -316,7 +330,7 @@ public sealed partial class RynthNetPlugin : RynthPluginBase
|
|||
if (!e.Ok)
|
||||
{
|
||||
string what = _sent.TryGetValue(e.Id, out string? t) ? $"'{t}'" : "the command";
|
||||
ChatLine($"{e.From} didn't run {what}: {e.Text}");
|
||||
ChatFail($"{e.From} didn't run {what}: {e.Text}");
|
||||
}
|
||||
break;
|
||||
case NetEventKind.Data:
|
||||
|
|
@ -373,7 +387,7 @@ public sealed partial class RynthNetPlugin : RynthPluginBase
|
|||
}
|
||||
if (!Host.HasInvokeChatParser)
|
||||
{
|
||||
ChatLine("this engine can't run chat commands for plugins (no InvokeChatParser).");
|
||||
ChatFail("this engine can't run chat commands for plugins (no InvokeChatParser).");
|
||||
return;
|
||||
}
|
||||
// Same as typing it: plugins (/ra, /ub, /lua...) get it first, then AC.
|
||||
|
|
@ -391,11 +405,11 @@ public sealed partial class RynthNetPlugin : RynthPluginBase
|
|||
{
|
||||
NetNode? node = _node;
|
||||
command = (command ?? "").Trim();
|
||||
if (command.Length == 0) { if (!quiet) ChatLine("no command given."); return null; }
|
||||
if (command.Length > Wire.MaxText) { if (!quiet) ChatLine($"command too long (max {Wire.MaxText})."); return null; }
|
||||
if (command.Length == 0) { if (!quiet) ChatFail("no command given."); return null; }
|
||||
if (command.Length > Wire.MaxText) { if (!quiet) ChatFail($"command too long (max {Wire.MaxText})."); return null; }
|
||||
if (CommandPolicy.Rebroadcasts(command))
|
||||
{
|
||||
if (!quiet) ChatLine("a broadcast can't contain another broadcast (/rn, /ub bc, /ub bct).");
|
||||
if (!quiet) ChatFail("a broadcast can't contain another broadcast (/rn, /ub bc, /ub bct).");
|
||||
return null;
|
||||
}
|
||||
delayMs = Math.Clamp(delayMs, 0, 600_000);
|
||||
|
|
|
|||
Loading…
Reference in a new issue