feat(chat): port retail client command families
Expand the typed client-command boundary across travel, character queries, local UI and layout controls, AFK and consent, emotes, friends, squelch and filters, and fill-components. Preserve retail packet layouts and queue ownership, import the confirmation dialog, and keep authoritative social state in Core. Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
parent
5a45a7ac7f
commit
9ea579bdd0
47 changed files with 6659 additions and 99 deletions
|
|
@ -70,6 +70,8 @@ public static class WeenieErrorMessages
|
|||
{
|
||||
// Command parser
|
||||
[0x0026] = "That is not a valid command.", // ThatIsNotAValidCommand
|
||||
[0x055F] = "Only Player Killer characters may use this command!",
|
||||
[0x0560] = "Only Player Killer Lite characters may use this command!",
|
||||
|
||||
// Tell-related
|
||||
[0x052B] = "That person is not available now.", // CharacterNotAvailable
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using AcDream.Core.Items;
|
||||
using AcDream.Core.Physics;
|
||||
using AcDream.Core.Spells;
|
||||
|
||||
namespace AcDream.Core.Player;
|
||||
|
|
@ -108,6 +109,7 @@ public sealed class LocalPlayerState
|
|||
private VitalSnapshot? _mana;
|
||||
private readonly Dictionary<AttributeKind, AttributeSnapshot> _attrs = new();
|
||||
private readonly Dictionary<uint, SkillSnapshot> _skills = new();
|
||||
private readonly Dictionary<uint, Position> _positions = new();
|
||||
private PropertyBundle _properties = new();
|
||||
private readonly Spellbook? _spellbook;
|
||||
|
||||
|
|
@ -185,6 +187,20 @@ public sealed class LocalPlayerState
|
|||
/// <summary>All known skill snapshots, keyed by SkillId.</summary>
|
||||
public IReadOnlyDictionary<uint, SkillSnapshot> Skills => _skills;
|
||||
|
||||
/// <summary>Player Position qualities keyed by retail PositionType.</summary>
|
||||
public IReadOnlyDictionary<uint, Position> Positions => _positions;
|
||||
|
||||
public Position? GetPosition(uint positionType) =>
|
||||
_positions.TryGetValue(positionType, out var value) ? value : null;
|
||||
|
||||
public void OnPositions(IReadOnlyDictionary<uint, Position> positions)
|
||||
{
|
||||
_positions.Clear();
|
||||
foreach (var pair in positions)
|
||||
_positions[pair.Key] = pair.Value;
|
||||
CharacterChanged?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>Snapshot for one skill, or <c>null</c> if it has not arrived yet.</summary>
|
||||
public SkillSnapshot? GetSkill(uint skillId) =>
|
||||
_skills.TryGetValue(skillId, out var s) ? s : null;
|
||||
|
|
|
|||
74
src/AcDream.Core/Social/FriendsState.cs
Normal file
74
src/AcDream.Core/Social/FriendsState.cs
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
namespace AcDream.Core.Social;
|
||||
|
||||
/// <summary>Authoritative client-side copy of retail's <c>FriendDataList</c>.</summary>
|
||||
public sealed class FriendsState
|
||||
{
|
||||
private readonly object _gate = new();
|
||||
private readonly List<FriendEntry> _entries = new();
|
||||
|
||||
public IReadOnlyList<FriendEntry> Snapshot()
|
||||
{
|
||||
lock (_gate) return _entries.ToArray();
|
||||
}
|
||||
|
||||
public void Apply(FriendsUpdate update)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(update);
|
||||
lock (_gate)
|
||||
{
|
||||
switch (update.Type)
|
||||
{
|
||||
case FriendsUpdateType.Full:
|
||||
_entries.Clear();
|
||||
_entries.AddRange(update.Entries);
|
||||
break;
|
||||
case FriendsUpdateType.Add:
|
||||
foreach (FriendEntry entry in update.Entries)
|
||||
{
|
||||
int index = _entries.FindIndex(candidate => candidate.Id == entry.Id);
|
||||
if (index >= 0) _entries[index] = entry;
|
||||
else _entries.Add(entry);
|
||||
}
|
||||
break;
|
||||
case FriendsUpdateType.Remove:
|
||||
case FriendsUpdateType.RemoveSilent:
|
||||
foreach (FriendEntry entry in update.Entries)
|
||||
_entries.RemoveAll(candidate => candidate.Id == entry.Id);
|
||||
break;
|
||||
case FriendsUpdateType.OnlineStatus:
|
||||
foreach (FriendEntry entry in update.Entries)
|
||||
{
|
||||
int index = _entries.FindIndex(candidate => candidate.Id == entry.Id);
|
||||
if (index >= 0) _entries[index] = entry;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
lock (_gate) _entries.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record FriendEntry(
|
||||
uint Id,
|
||||
string Name,
|
||||
bool Online,
|
||||
bool AppearOffline,
|
||||
IReadOnlyList<uint> Friends,
|
||||
IReadOnlyList<uint> FriendOf);
|
||||
|
||||
public enum FriendsUpdateType : uint
|
||||
{
|
||||
Full = 0,
|
||||
Add = 1,
|
||||
Remove = 2,
|
||||
RemoveSilent = 3,
|
||||
OnlineStatus = 4,
|
||||
}
|
||||
|
||||
public sealed record FriendsUpdate(
|
||||
FriendsUpdateType Type,
|
||||
IReadOnlyList<FriendEntry> Entries);
|
||||
35
src/AcDream.Core/Social/SquelchState.cs
Normal file
35
src/AcDream.Core/Social/SquelchState.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
namespace AcDream.Core.Social;
|
||||
|
||||
/// <summary>Authoritative copy of retail's server-supplied <c>SquelchDB</c>.</summary>
|
||||
public sealed class SquelchState
|
||||
{
|
||||
private readonly object _gate = new();
|
||||
private SquelchDatabase _database = SquelchDatabase.Empty;
|
||||
|
||||
public SquelchDatabase Snapshot()
|
||||
{
|
||||
lock (_gate) return _database;
|
||||
}
|
||||
|
||||
public void Replace(SquelchDatabase database)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(database);
|
||||
lock (_gate) _database = database;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record SquelchInfo(
|
||||
string Name,
|
||||
bool AccountWide,
|
||||
IReadOnlySet<uint> MessageTypes);
|
||||
|
||||
public sealed record SquelchDatabase(
|
||||
IReadOnlyDictionary<string, uint> Accounts,
|
||||
IReadOnlyDictionary<uint, SquelchInfo> Characters,
|
||||
SquelchInfo Global)
|
||||
{
|
||||
public static SquelchDatabase Empty { get; } = new(
|
||||
new Dictionary<string, uint>(StringComparer.OrdinalIgnoreCase),
|
||||
new Dictionary<uint, SquelchInfo>(),
|
||||
new SquelchInfo(string.Empty, false, new HashSet<uint>()));
|
||||
}
|
||||
31
src/AcDream.Core/Ui/RetailPositionFormatter.cs
Normal file
31
src/AcDream.Core/Ui/RetailPositionFormatter.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System.Globalization;
|
||||
using AcDream.Core.Physics;
|
||||
|
||||
namespace AcDream.Core.Ui;
|
||||
|
||||
/// <summary>Retail text formatting for world positions and outdoor cells.</summary>
|
||||
public static class RetailPositionFormatter
|
||||
{
|
||||
/// <summary>
|
||||
/// Verbatim field order and precision from
|
||||
/// <c>Position::ToString @ 0x005A9330</c>.
|
||||
/// </summary>
|
||||
public static string Format(Position position)
|
||||
{
|
||||
var p = position.Frame.Origin;
|
||||
var q = position.Frame.Orientation;
|
||||
return string.Create(CultureInfo.InvariantCulture,
|
||||
$"0x{position.ObjCellId:X8} [{p.X:F6} {p.Y:F6} {p.Z:F6}] " +
|
||||
$"{q.W:F6} {q.X:F6} {q.Y:F6} {q.Z:F6}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Port of <c>LandDefs::CellidToCoordinateString @ 0x005A9CB0</c>.
|
||||
/// Returns null for indoor/invalid cells, matching the underlying
|
||||
/// <c>gid_to_lcoord</c> failure.
|
||||
/// </summary>
|
||||
public static string? FormatOutdoorCell(uint cellId) =>
|
||||
RadarCoordinates.TryFromCell(cellId, out var coordinates)
|
||||
? coordinates.CombinedText
|
||||
: null;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue