mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-19 14:27:45 +01:00
Fix StyleCop warnings
This commit is contained in:
parent
790669e60a
commit
6e19aca481
4 changed files with 72 additions and 56 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
using Dalamud.Data;
|
using Dalamud.Data;
|
||||||
using Dalamud.Utility;
|
using Dalamud.Utility;
|
||||||
|
|
||||||
|
|
@ -10,8 +12,6 @@ using FFXIVClientStructs.Interop;
|
||||||
using Lumina.Excel;
|
using Lumina.Excel;
|
||||||
using Lumina.Text.ReadOnly;
|
using Lumina.Text.ReadOnly;
|
||||||
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
|
||||||
|
|
||||||
namespace Dalamud.Game.Chat;
|
namespace Dalamud.Game.Chat;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -88,30 +88,41 @@ internal unsafe readonly struct LogMessage(LogMessageQueueItem* ptr) : ILogMessa
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public RowRef<Lumina.Excel.Sheets.LogMessage> GameData => LuminaUtils.CreateRef<Lumina.Excel.Sheets.LogMessage>(ptr->LogMessageId);
|
public RowRef<Lumina.Excel.Sheets.LogMessage> GameData => LuminaUtils.CreateRef<Lumina.Excel.Sheets.LogMessage>(ptr->LogMessageId);
|
||||||
|
|
||||||
public LogMessageEntity SourceEntity => new LogMessageEntity(ptr, true);
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
ILogMessageEntity? ILogMessage.SourceEntity => ptr->SourceKind == EntityRelationKind.None ? null : this.SourceEntity;
|
ILogMessageEntity? ILogMessage.SourceEntity => ptr->SourceKind == EntityRelationKind.None ? null : this.SourceEntity;
|
||||||
|
|
||||||
public LogMessageEntity TargetEntity => new LogMessageEntity(ptr, false);
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
ILogMessageEntity? ILogMessage.TargetEntity => ptr->TargetKind == EntityRelationKind.None ? null : this.TargetEntity;
|
ILogMessageEntity? ILogMessage.TargetEntity => ptr->TargetKind == EntityRelationKind.None ? null : this.TargetEntity;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public int ParameterCount => ptr->Parameters.Count;
|
public int ParameterCount => ptr->Parameters.Count;
|
||||||
|
|
||||||
public bool TryGetParameter(int index, out TextParameter value)
|
private LogMessageEntity SourceEntity => new(ptr, true);
|
||||||
{
|
|
||||||
if (index < 0 || index >= ptr->Parameters.Count)
|
|
||||||
{
|
|
||||||
value = default;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = ptr->Parameters[index];
|
private LogMessageEntity TargetEntity => new(ptr, false);
|
||||||
return true;
|
|
||||||
|
public static bool operator ==(LogMessage x, LogMessage y) => x.Equals(y);
|
||||||
|
|
||||||
|
public static bool operator !=(LogMessage x, LogMessage y) => !(x == y);
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public bool Equals(ILogMessage? other)
|
||||||
|
{
|
||||||
|
return other is LogMessage logMessage && this.Equals(logMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override bool Equals([NotNullWhen(true)] object? obj)
|
||||||
|
{
|
||||||
|
return obj is LogMessage logMessage && this.Equals(logMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return HashCode.Combine(this.LogMessageId, this.SourceEntity, this.TargetEntity);
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public bool TryGetIntParameter(int index, out int value)
|
public bool TryGetIntParameter(int index, out int value)
|
||||||
{
|
{
|
||||||
|
|
@ -132,6 +143,7 @@ internal unsafe readonly struct LogMessage(LogMessageQueueItem* ptr) : ILogMessa
|
||||||
value = new(parameter.StringValue.AsSpan());
|
value = new(parameter.StringValue.AsSpan());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parameter.Type == TextParameterType.ReferencedUtf8String)
|
if (parameter.Type == TextParameterType.ReferencedUtf8String)
|
||||||
{
|
{
|
||||||
value = new(parameter.ReferencedUtf8StringValue->Utf8String.AsSpan());
|
value = new(parameter.ReferencedUtf8StringValue->Utf8String.AsSpan());
|
||||||
|
|
@ -157,7 +169,7 @@ internal unsafe readonly struct LogMessage(LogMessageQueueItem* ptr) : ILogMessa
|
||||||
|
|
||||||
return new ReadOnlySeString(utf8.AsSpan());
|
return new ReadOnlySeString(utf8.AsSpan());
|
||||||
|
|
||||||
void SetName(RaptureLogModule* self, LogMessageEntity item)
|
static void SetName(RaptureLogModule* self, LogMessageEntity item)
|
||||||
{
|
{
|
||||||
var name = item.NameSpan.GetPointer(0);
|
var name = item.NameSpan.GetPointer(0);
|
||||||
|
|
||||||
|
|
@ -190,31 +202,20 @@ internal unsafe readonly struct LogMessage(LogMessageQueueItem* ptr) : ILogMessa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool TryGetParameter(int index, out TextParameter value)
|
||||||
|
{
|
||||||
|
if (index < 0 || index >= ptr->Parameters.Count)
|
||||||
|
{
|
||||||
|
value = default;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static bool operator ==(LogMessage x, LogMessage y) => x.Equals(y);
|
value = ptr->Parameters[index];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static bool operator !=(LogMessage x, LogMessage y) => !(x == y);
|
private bool Equals(LogMessage other)
|
||||||
|
|
||||||
public bool Equals(LogMessage other)
|
|
||||||
{
|
{
|
||||||
return this.LogMessageId == other.LogMessageId && this.SourceEntity == other.SourceEntity && this.TargetEntity == other.TargetEntity;
|
return this.LogMessageId == other.LogMessageId && this.SourceEntity == other.SourceEntity && this.TargetEntity == other.TargetEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public bool Equals(ILogMessage? other)
|
|
||||||
{
|
|
||||||
return other is LogMessage logMessage && this.Equals(logMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override bool Equals([NotNullWhen(true)] object? obj)
|
|
||||||
{
|
|
||||||
return obj is LogMessage logMessage && this.Equals(logMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return HashCode.Combine(this.LogMessageId, this.SourceEntity, this.TargetEntity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,46 +37,57 @@ public interface ILogMessageEntity : IEquatable<ILogMessageEntity>
|
||||||
uint ObjStrId { get; }
|
uint ObjStrId { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a boolean indicating if this entity is a player.
|
/// Gets a value indicating whether this entity is a player.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsPlayer { get; }
|
bool IsPlayer { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This struct represents an entity related to a log message.
|
/// This struct represents an entity related to a log message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ptr">A pointer to the log message item.</param>
|
/// <param name="ptr">A pointer to the log message item.</param>
|
||||||
/// <param name="source">If <see langword="true"/> represents the source entity of the log message, otherwise represents the target entity</param>
|
/// <param name="source">If <see langword="true"/> represents the source entity of the log message, otherwise represents the target entity.</param>
|
||||||
internal unsafe readonly struct LogMessageEntity(LogMessageQueueItem* ptr, bool source) : ILogMessageEntity
|
internal unsafe readonly struct LogMessageEntity(LogMessageQueueItem* ptr, bool source) : ILogMessageEntity
|
||||||
{
|
{
|
||||||
public Span<byte> NameSpan => source ? ptr->SourceName : ptr->TargetName;
|
/// <inheritdoc/>
|
||||||
|
public ReadOnlySeString Name => new(this.NameSpan[..this.NameSpan.IndexOf((byte)0)]);
|
||||||
public ReadOnlySeString Name => new ReadOnlySeString(this.NameSpan[..this.NameSpan.IndexOf((byte)0)]);
|
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public ushort HomeWorldId => source ? ptr->SourceHomeWorld : ptr->TargetHomeWorld;
|
public ushort HomeWorldId => source ? ptr->SourceHomeWorld : ptr->TargetHomeWorld;
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public RowRef<World> HomeWorld => LuminaUtils.CreateRef<World>(this.HomeWorldId);
|
public RowRef<World> HomeWorld => LuminaUtils.CreateRef<World>(this.HomeWorldId);
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
public uint ObjStrId => source ? ptr->SourceObjStrId : ptr->TargetObjStrId;
|
public uint ObjStrId => source ? ptr->SourceObjStrId : ptr->TargetObjStrId;
|
||||||
|
|
||||||
public byte Kind => source ? (byte)ptr->SourceKind : (byte)ptr->TargetKind;
|
/// <inheritdoc/>
|
||||||
|
|
||||||
public byte Sex => source ? ptr->SourceSex : ptr->TargetSex;
|
|
||||||
|
|
||||||
public bool IsPlayer => source ? ptr->SourceIsPlayer : ptr->TargetIsPlayer;
|
public bool IsPlayer => source ? ptr->SourceIsPlayer : ptr->TargetIsPlayer;
|
||||||
|
|
||||||
public bool IsSourceEntity => source;
|
/// <summary>
|
||||||
|
/// Gets the Span containing the raw name of this entity.
|
||||||
|
/// </summary>
|
||||||
|
internal Span<byte> NameSpan => source ? ptr->SourceName : ptr->TargetName;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the kind of the entity.
|
||||||
|
/// </summary>
|
||||||
|
internal byte Kind => source ? (byte)ptr->SourceKind : (byte)ptr->TargetKind;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the Sex of this entity.
|
||||||
|
/// </summary>
|
||||||
|
internal byte Sex => source ? ptr->SourceSex : ptr->TargetSex;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether this entity is the source entity of a log message.
|
||||||
|
/// </summary>
|
||||||
|
internal bool IsSourceEntity => source;
|
||||||
|
|
||||||
public static bool operator ==(LogMessageEntity x, LogMessageEntity y) => x.Equals(y);
|
public static bool operator ==(LogMessageEntity x, LogMessageEntity y) => x.Equals(y);
|
||||||
|
|
||||||
public static bool operator !=(LogMessageEntity x, LogMessageEntity y) => !(x == y);
|
public static bool operator !=(LogMessageEntity x, LogMessageEntity y) => !(x == y);
|
||||||
|
|
||||||
public bool Equals(LogMessageEntity other)
|
|
||||||
{
|
|
||||||
return this.Name == other.Name && this.HomeWorldId == other.HomeWorldId && this.ObjStrId == other.ObjStrId && this.Kind == other.Kind && this.Sex == other.Sex && this.IsPlayer == other.IsPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public bool Equals(ILogMessageEntity other)
|
public bool Equals(ILogMessageEntity other)
|
||||||
{
|
{
|
||||||
|
|
@ -94,4 +105,9 @@ internal unsafe readonly struct LogMessageEntity(LogMessageQueueItem* ptr, bool
|
||||||
{
|
{
|
||||||
return HashCode.Combine(this.Name, this.HomeWorldId, this.ObjStrId, this.Sex, this.IsPlayer);
|
return HashCode.Combine(this.Name, this.HomeWorldId, this.ObjStrId, this.Sex, this.IsPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool Equals(LogMessageEntity other)
|
||||||
|
{
|
||||||
|
return this.Name == other.Name && this.HomeWorldId == other.HomeWorldId && this.ObjStrId == other.ObjStrId && this.Kind == other.Kind && this.Sex == other.Sex && this.IsPlayer == other.IsPlayer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@ internal class ChatSelfTestStep : ISelfTestStep
|
||||||
private bool subscribedLogMessage = false;
|
private bool subscribedLogMessage = false;
|
||||||
private bool hasSeenEchoMessage = false;
|
private bool hasSeenEchoMessage = false;
|
||||||
private bool hasSeenActionMessage = false;
|
private bool hasSeenActionMessage = false;
|
||||||
private string actionName = "";
|
private string actionName = string.Empty;
|
||||||
private string actionUser = "";
|
private string actionUser = string.Empty;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string Name => "Test Chat";
|
public string Name => "Test Chat";
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,6 @@ public interface IChatGui : IDalamudService
|
||||||
/// <param name="message">The message sent.</param>
|
/// <param name="message">The message sent.</param>
|
||||||
public delegate void OnMessageUnhandledDelegate(XivChatType type, int timestamp, SeString sender, SeString message);
|
public delegate void OnMessageUnhandledDelegate(XivChatType type, int timestamp, SeString sender, SeString message);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A delegate type used with the <see cref="IChatGui.LogMessage"/> event.
|
/// A delegate type used with the <see cref="IChatGui.LogMessage"/> event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue