Snapshot for release 2026.10.15.2 (internal 9094d68)

This commit is contained in:
Tom Bohar 2026-10-15 20:32:34 -04:00
commit 516ad2bdf2
121 changed files with 6486 additions and 781 deletions

View file

@ -10,7 +10,7 @@
// {"t":"mule","ready":false,"why":"loading"} (still loading on the server: never an empty vault)
//
// A field the reader does not know is ignored, so the mod can add fields. Pure code (no engine state);
// compiled into tools/NetMessageTests.
// compiled into tools/NetMessageTests (with Net/ChatOrigin.cs).
// ============================================================================
using System;
@ -48,20 +48,26 @@ internal static class AelrynthVaultWire
/// <summary>The command for a page (1 = the bare command).</summary>
public static string PageCommand(int page) => page <= 1 ? Command : Command + " " + page.ToString(System.Globalization.CultureInfo.InvariantCulture);
/// <summary>A "~ael1" data line whose kind is "mule" (another mod's data line is not ours).</summary>
/// <summary>
/// A "~ael1" data line whose kind is "mule" (another mod's data line is not ours). The prefix
/// must start the line: a player's copy has their name in front (ChatOrigin).
/// </summary>
public static bool IsMuleLine(string? line)
{
if (string.IsNullOrEmpty(line)) return false;
int at = line.IndexOf(Prefix, StringComparison.Ordinal);
return at >= 0 && line.IndexOf("\"t\":\"mule\"", at, StringComparison.Ordinal) >= 0;
if (!ChatOrigin.StartsWithMarker(line, Prefix)) return false;
return line!.IndexOf("\"t\":\"mule\"", ChatOrigin.ContentStart(line), StringComparison.Ordinal) >= 0;
}
/// <summary>ACE's reply to a command it does not have ("Unknown command: mule-data").</summary>
/// <summary>
/// ACE's reply to a command it does not have, "Unknown command: mule-data" (GameActionTalk names
/// the bare command; a leading / or @ is allowed). Anchored at the line's start.
/// </summary>
public static bool IsUnknownCommand(string? line)
{
if (string.IsNullOrEmpty(line)) return false;
return line.IndexOf("Unknown command", StringComparison.OrdinalIgnoreCase) >= 0
&& line.IndexOf(CommandName, StringComparison.OrdinalIgnoreCase) >= 0;
const string marker = "Unknown command:";
if (!ChatOrigin.StartsWithMarker(line, marker, StringComparison.OrdinalIgnoreCase)) return false;
string named = line!.Substring(ChatOrigin.ContentStart(line) + marker.Length).Trim().TrimStart('/', '@');
return string.Equals(named, CommandName, StringComparison.OrdinalIgnoreCase);
}
/// <summary>The page in a mule line; false when it is not one or is too damaged to read.</summary>
@ -71,7 +77,7 @@ internal static class AelrynthVaultWire
if (!IsMuleLine(line)) return false;
try
{
int at = line!.IndexOf(Prefix, StringComparison.Ordinal) + Prefix.Length;
int at = ChatOrigin.ContentStart(line!) + Prefix.Length;
using JsonDocument doc = JsonDocument.Parse(line.AsMemory(at));
JsonElement root = doc.RootElement;
if (root.ValueKind != JsonValueKind.Object) return false;

View file

@ -0,0 +1,54 @@
// ============================================================================
// RynthCore.Engine - Net/ChatOrigin.cs
// Telling a server line from a player's imitation of one.
//
// The engine eats its own "~ael1 " data replies (/mastery-data, /mule-data)
// and ACE's "Unknown command: ..." refusals before AC draws them. Another
// player can type the same text, so the readers need both checks here:
// - the chat type is not one a player writes in (ACE ChatMessageType, which
// is the client's eChatTypes: ACE.Entity/Enum/ChatMessageType.cs);
// - the line STARTS with the marker. The client puts the speaker in front
// of player text ("Name says, ...", "Name tells you, ...", "Name waves"),
// so a player's copy never starts with it.
// Pure code (no engine state); compiled into tools/NetMessageTests.
// Plugins have the same rules in RynthSuite Plugins/Shared/ChatSource.cs.
// ============================================================================
using System;
namespace RynthCore.Engine.Net;
internal static class ChatOrigin
{
// Chat types whose text another player writes.
public const uint Speech = 0x02;
public const uint Tell = 0x03;
public const uint OutgoingTell = 0x04;
public const uint Channel = 0x08;
public const uint ChannelSend = 0x09;
public const uint Social = 0x0A;
public const uint SocialSend = 0x0B;
public const uint Emote = 0x0C;
public const uint Allegiance = 0x12;
public const uint Fellowship = 0x13;
/// <summary>True when a line of this chat type is a player's words.</summary>
public static bool IsPlayerAuthored(uint chatType) => chatType switch
{
Speech or Tell or OutgoingTell or Channel or ChannelSend
or Social or SocialSend or Emote or Allegiance or Fellowship => true,
_ => false,
};
/// <summary>The index just past <paramref name="line"/>'s leading whitespace.</summary>
public static int ContentStart(string line)
{
int i = 0;
while (i < line.Length && char.IsWhiteSpace(line[i])) i++;
return i;
}
/// <summary>True when <paramref name="line"/>, past leading whitespace, starts with <paramref name="marker"/>.</summary>
public static bool StartsWithMarker(string? line, string marker, StringComparison comparison = StringComparison.Ordinal)
=> line != null && line.AsSpan(ContentStart(line)).StartsWith(marker.AsSpan(), comparison);
}