fix: Optimizes OPL using string interpolation (#1041)

## Breaking Changes (New API)
ObjectPropertyList supports the following API:
```cs
list.Add(500000);
list.Add(500001, stringArgument);
list.Add("Some text");
list.Add($"Some text with {argument}");
list.Add(500002, $"{arg1}\t{arg2}");
```

## Notes
1. All API uses that require a formatter like this:
    ```cs
    list.Add(500002, "{0}\t{1}", arg1, arg2);
    ```
    Should be changed to use string interpolation, for example:
    ```cs
    list.Add(500002, $"{arg1}\t{arg2}");
    ```
2. The following paradigm should no longer be used:
    ```cs
    list.Add(1061170, prop.ToString()); // strength requirement ~1_val~
    ```
    The new string interpolation API will avoid having to convert the argument to a string before writing it to the packet. Instead use the following:
    ```cs
    list.Add(1061170, $"{prop}"); // strength requirement ~1_val~
    ```

### Benchmarks
```cs
|                         Method |     Mean |   Error |  StdDev |  Gen 0 | Allocated |
|------------------------------- |---------:|--------:|--------:|-------:|----------:|
|                BenchmarkOldOPL | 241.0 ns | 0.56 ns | 0.47 ns | 0.0105 |      88 B |
| BenchmarkStringInterpolatedOPL | 199.9 ns | 2.44 ns | 2.39 ns |      - |         - |
```

### Changes
- [X] Removes crash in STArray.Return when array is null.
- [X] Fixes NPE in OPL when entity is null. Serial in packet will be 0 when entity is null.
- [X] Fixes NPE in AosAttributes when Parent is null.
- [X] Changes OPL to use string interpolation.
- [X] Introduces `IPropertyList` to allow extending PropertyList for other uses.
This commit is contained in:
Kamron Batman 2022-06-02 10:09:53 -07:00 committed by GitHub
parent fe31470f05
commit ecbee17690
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
227 changed files with 1426 additions and 1008 deletions

View file

@ -78,7 +78,7 @@ public ref struct RawInterpolatedStringHandler
/// <param name="formattedCount">The number of interpolation expressions in the interpolated string.</param> /// <param name="formattedCount">The number of interpolation expressions in the interpolated string.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)] // becomes a constant when inputs are constant [MethodImpl(MethodImplOptions.AggressiveInlining)] // becomes a constant when inputs are constant
internal static int GetDefaultLength(int literalLength, int formattedCount) => internal static int GetDefaultLength(int literalLength, int formattedCount) =>
Math.Max(MinimumArrayPoolLength, literalLength + (formattedCount * GuessedLengthPerHole)); Math.Max(MinimumArrayPoolLength, literalLength + formattedCount * GuessedLengthPerHole);
/// <summary>Clears the handler, returning any rented array to the pool.</summary> /// <summary>Clears the handler, returning any rented array to the pool.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)] // used only on a few hot paths [MethodImpl(MethodImplOptions.AggressiveInlining)] // used only on a few hot paths

View file

@ -78,7 +78,7 @@ public class STArrayPool<T> : ArrayPool<T>
{ {
if (array is null) if (array is null)
{ {
throw new ArgumentNullException(nameof(array)); return;
} }
var bucketIndex = SelectBucketIndex(array.Length); var bucketIndex = SelectBucketIndex(array.Length);

View file

@ -755,7 +755,7 @@ namespace Server.Items
public virtual void SendContentTo(NetState state) => state.SendContainerContent(state.Mobile, this); public virtual void SendContentTo(NetState state) => state.SendContainerContent(state.Mobile, this);
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
@ -767,21 +767,14 @@ namespace Server.Items
{ {
list.Add( list.Add(
1073841, // Contents: ~1_COUNT~/~2_MAXCOUNT~ items, ~3_WEIGHT~ stones 1073841, // Contents: ~1_COUNT~/~2_MAXCOUNT~ items, ~3_WEIGHT~ stones
"{0}\t{1}\t{2}", $"{TotalItems}\t{MaxItems}\t{TotalWeight}"
TotalItems,
MaxItems,
TotalWeight
); );
} }
else else
{ {
list.Add( list.Add(
1072241, // Contents: ~1_COUNT~/~2_MAXCOUNT~ items, ~3_WEIGHT~/~4_MAXWEIGHT~ stones 1072241, // Contents: ~1_COUNT~/~2_MAXCOUNT~ items, ~3_WEIGHT~/~4_MAXWEIGHT~ stones
"{0}\t{1}\t{2}\t{3}", $"{TotalItems}\t{MaxItems}\t{TotalWeight}\t{MaxWeight}"
TotalItems,
MaxItems,
TotalWeight,
MaxWeight
); );
} }
@ -790,7 +783,7 @@ namespace Server.Items
else else
{ {
// ~1_COUNT~ items, ~2_WEIGHT~ stones // ~1_COUNT~ items, ~2_WEIGHT~ stones
list.Add(1050044, "{0}\t{1}", TotalItems, TotalWeight); list.Add(1050044, $"{TotalItems}\t{TotalWeight}");
} }
} }
} }

View file

@ -176,7 +176,7 @@ namespace Server
Spawner = 0x100 Spawner = 0x100
} }
public class Item : IHued, IComparable<Item>, ISpawnable, IPropertyListObject public class Item : IHued, IComparable<Item>, ISpawnable, IObjectPropertyListEntity
{ {
private static readonly ILogger logger = LogFactory.GetLogger(typeof(Item)); private static readonly ILogger logger = LogFactory.GetLogger(typeof(Item));
@ -769,7 +769,7 @@ namespace Server
/// custom /// custom
/// properties. /// properties.
/// </summary> /// </summary>
public virtual void GetProperties(ObjectPropertyList list) public virtual void GetProperties(IPropertyList list)
{ {
AddNameProperties(list); AddNameProperties(list);
} }
@ -1817,7 +1817,7 @@ namespace Server
/// Overridable. Adds the name of this item to the given <see cref="ObjectPropertyList" />. This method should be overridden /// Overridable. Adds the name of this item to the given <see cref="ObjectPropertyList" />. This method should be overridden
/// if the item requires a complex naming format. /// if the item requires a complex naming format.
/// </summary> /// </summary>
public virtual void AddNameProperty(ObjectPropertyList list) public virtual void AddNameProperty(IPropertyList list)
{ {
var name = Name; var name = Name;
@ -1829,7 +1829,7 @@ namespace Server
} }
else else
{ {
list.Add(1050039, "{0}\t#{1}", m_Amount, LabelNumber); // ~1_NUMBER~ ~2_ITEMNAME~ list.Add(1050039, $"{m_Amount}\t#{LabelNumber}"); // ~1_NUMBER~ ~2_ITEMNAME~
} }
} }
else else
@ -1840,7 +1840,7 @@ namespace Server
} }
else else
{ {
list.Add(1050039, "{0}\t{1}", m_Amount, Name); // ~1_NUMBER~ ~2_ITEMNAME~ list.Add(1050039, $"{m_Amount}\t{Name}"); // ~1_NUMBER~ ~2_ITEMNAME~
} }
} }
} }
@ -1849,7 +1849,7 @@ namespace Server
/// Overridable. Adds the loot type of this item to the given <see cref="ObjectPropertyList" />. By default, this will be /// Overridable. Adds the loot type of this item to the given <see cref="ObjectPropertyList" />. By default, this will be
/// either 'blessed', 'cursed', or 'insured'. /// either 'blessed', 'cursed', or 'insured'.
/// </summary> /// </summary>
public virtual void AddLootTypeProperty(ObjectPropertyList list) public virtual void AddLootTypeProperty(IPropertyList list)
{ {
if (m_LootType == LootType.Blessed) if (m_LootType == LootType.Blessed)
{ {
@ -1868,59 +1868,51 @@ namespace Server
/// <summary> /// <summary>
/// Overridable. Adds any elemental resistances of this item to the given <see cref="ObjectPropertyList" />. /// Overridable. Adds any elemental resistances of this item to the given <see cref="ObjectPropertyList" />.
/// </summary> /// </summary>
public virtual void AddResistanceProperties(ObjectPropertyList list) public virtual void AddResistanceProperties(IPropertyList list)
{ {
var v = PhysicalResistance; var v = PhysicalResistance;
if (v != 0) if (v != 0)
{ {
list.Add(1060448, v.ToString()); // physical resist ~1_val~% list.Add(1060448, $"{v}"); // physical resist ~1_val~%
} }
v = FireResistance; v = FireResistance;
if (v != 0) if (v != 0)
{ {
list.Add(1060447, v.ToString()); // fire resist ~1_val~% list.Add(1060447, $"{v}"); // fire resist ~1_val~%
} }
v = ColdResistance; v = ColdResistance;
if (v != 0) if (v != 0)
{ {
list.Add(1060445, v.ToString()); // cold resist ~1_val~% list.Add(1060445, $"{v}"); // cold resist ~1_val~%
} }
v = PoisonResistance; v = PoisonResistance;
if (v != 0) if (v != 0)
{ {
list.Add(1060449, v.ToString()); // poison resist ~1_val~% list.Add(1060449, $"{v}"); // poison resist ~1_val~%
} }
v = EnergyResistance; v = EnergyResistance;
if (v != 0) if (v != 0)
{ {
list.Add(1060446, v.ToString()); // energy resist ~1_val~% list.Add(1060446, $"{v}"); // energy resist ~1_val~%
} }
} }
/// <summary> /// <summary>
/// Overridable. Displays cliloc 1072788-1072789. /// Overridable. Displays cliloc 1072788-1072789.
/// </summary> /// </summary>
public virtual void AddWeightProperty(ObjectPropertyList list) public virtual void AddWeightProperty(IPropertyList list)
{ {
var weight = PileWeight + TotalWeight; var weight = PileWeight + TotalWeight;
list.Add(weight == 1 ? 1072788 : 1072789, $"{weight}");
if (weight == 1)
{
list.Add(1072788, weight.ToString()); // Weight: ~1_WEIGHT~ stone
}
else
{
list.Add(1072789, weight.ToString()); // Weight: ~1_WEIGHT~ stones
}
} }
/// <summary> /// <summary>
@ -1928,7 +1920,7 @@ namespace Server
/// <see cref="AddBlessedForProperty" /> (if applicable), and <see cref="AddLootTypeProperty" /> (if /// <see cref="AddBlessedForProperty" /> (if applicable), and <see cref="AddLootTypeProperty" /> (if
/// <see cref="DisplayLootType" />). /// <see cref="DisplayLootType" />).
/// </summary> /// </summary>
public virtual void AddNameProperties(ObjectPropertyList list) public virtual void AddNameProperties(IPropertyList list)
{ {
AddNameProperty(list); AddNameProperty(list);
@ -1969,7 +1961,7 @@ namespace Server
/// <summary> /// <summary>
/// Overridable. Adds the "Quest Item" property to the given <see cref="ObjectPropertyList" />. /// Overridable. Adds the "Quest Item" property to the given <see cref="ObjectPropertyList" />.
/// </summary> /// </summary>
public virtual void AddQuestItemProperty(ObjectPropertyList list) public virtual void AddQuestItemProperty(IPropertyList list)
{ {
list.Add(1072351); // Quest Item list.Add(1072351); // Quest Item
} }
@ -1977,7 +1969,7 @@ namespace Server
/// <summary> /// <summary>
/// Overridable. Adds the "Locked Down & Secure" property to the given <see cref="ObjectPropertyList" />. /// Overridable. Adds the "Locked Down & Secure" property to the given <see cref="ObjectPropertyList" />.
/// </summary> /// </summary>
public virtual void AddSecureProperty(ObjectPropertyList list) public virtual void AddSecureProperty(IPropertyList list)
{ {
list.Add(501644); // locked down & secure list.Add(501644); // locked down & secure
} }
@ -1985,7 +1977,7 @@ namespace Server
/// <summary> /// <summary>
/// Overridable. Adds the "Locked Down" property to the given <see cref="ObjectPropertyList" />. /// Overridable. Adds the "Locked Down" property to the given <see cref="ObjectPropertyList" />.
/// </summary> /// </summary>
public virtual void AddLockedDownProperty(ObjectPropertyList list) public virtual void AddLockedDownProperty(IPropertyList list)
{ {
list.Add(501643); // locked down list.Add(501643); // locked down
} }
@ -1993,9 +1985,9 @@ namespace Server
/// <summary> /// <summary>
/// Overridable. Adds the "Blessed for ~1_NAME~" property to the given <see cref="ObjectPropertyList" />. /// Overridable. Adds the "Blessed for ~1_NAME~" property to the given <see cref="ObjectPropertyList" />.
/// </summary> /// </summary>
public virtual void AddBlessedForProperty(ObjectPropertyList list, Mobile m) public virtual void AddBlessedForProperty(IPropertyList list, Mobile m)
{ {
list.Add(1062203, "{0}", m.Name); // Blessed for ~1_NAME~ list.Add(1062203, m.Name); // Blessed for ~1_NAME~
} }
/// <summary> /// <summary>
@ -2003,7 +1995,7 @@ namespace Server
/// Recursively calls <see cref="Item.GetChildProperties">Item.GetChildProperties</see> or /// Recursively calls <see cref="Item.GetChildProperties">Item.GetChildProperties</see> or
/// <see cref="Mobile.GetChildProperties">Mobile.GetChildProperties</see>. /// <see cref="Mobile.GetChildProperties">Mobile.GetChildProperties</see>.
/// </summary> /// </summary>
public virtual void GetChildProperties(ObjectPropertyList list, Item item) public virtual void GetChildProperties(IPropertyList list, Item item)
{ {
if (m_Parent is Item parentItem) if (m_Parent is Item parentItem)
{ {
@ -2021,7 +2013,7 @@ namespace Server
/// . Recursively calls <see cref="Item.GetChildProperties">Item.GetChildNameProperties</see> or /// . Recursively calls <see cref="Item.GetChildProperties">Item.GetChildNameProperties</see> or
/// <see cref="Mobile.GetChildProperties">Mobile.GetChildNameProperties</see>. /// <see cref="Mobile.GetChildProperties">Mobile.GetChildNameProperties</see>.
/// </summary> /// </summary>
public virtual void GetChildNameProperties(ObjectPropertyList list, Item item) public virtual void GetChildNameProperties(IPropertyList list, Item item)
{ {
if (m_Parent is Item parentItem) if (m_Parent is Item parentItem)
{ {
@ -2377,7 +2369,7 @@ namespace Server
return bounds; return bounds;
} }
public virtual void AppendChildProperties(ObjectPropertyList list) public virtual void AppendChildProperties(IPropertyList list)
{ {
if (m_Parent is Item item) if (m_Parent is Item item)
{ {
@ -2389,7 +2381,7 @@ namespace Server
} }
} }
public virtual void AppendChildNameProperties(ObjectPropertyList list) public virtual void AppendChildNameProperties(IPropertyList list)
{ {
if (m_Parent is Item item) if (m_Parent is Item item)
{ {

View file

@ -120,7 +120,7 @@ namespace Server.Items
LabelTo(from, "Offer: {0:#,0} platinum, {1:#,0} gold", Plat, Gold); LabelTo(from, "Offer: {0:#,0} platinum, {1:#,0} gold", Plat, Gold);
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);

View file

@ -403,7 +403,7 @@ namespace Server
/// <summary> /// <summary>
/// Base class representing players, npcs, and creatures. /// Base class representing players, npcs, and creatures.
/// </summary> /// </summary>
public class Mobile : IHued, IComparable<Mobile>, ISpawnable, IPropertyListObject public class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPropertyListEntity
{ {
// Allow four warmode changes in 0.5 seconds, any more will be delay for two seconds // Allow four warmode changes in 0.5 seconds, any more will be delay for two seconds
private const int WarmodeCatchCount = 4; private const int WarmodeCatchCount = 4;
@ -2476,7 +2476,7 @@ namespace Server
public virtual int HuedItemID => m_Female ? 0x2107 : 0x2106; public virtual int HuedItemID => m_Female ? 0x2107 : 0x2106;
public ObjectPropertyList PropertyList => m_PropertyList ??= InitializePropertyList(new ObjectPropertyList(this)); public ObjectPropertyList PropertyList => m_PropertyList ??= InitializePropertyList(new ObjectPropertyList(this));
public virtual void GetProperties(ObjectPropertyList list) public virtual void GetProperties(IPropertyList list)
{ {
AddNameProperties(list); AddNameProperties(list);
} }
@ -3445,57 +3445,51 @@ namespace Server
public virtual string ApplyNameSuffix(string suffix) => suffix; public virtual string ApplyNameSuffix(string suffix) => suffix;
public virtual void AddNameProperties(ObjectPropertyList list) public virtual void AddNameProperties(IPropertyList list)
{ {
var name = Name ?? ""; var name = Name ?? " ";
string prefix; string prefix;
if (ShowFameTitle && (m_Player || m_Body.IsHuman) && m_Fame >= 10000) if (ShowFameTitle && (m_Player || m_Body.IsHuman) && m_Fame >= 10000)
{ {
prefix = m_Female ? "Lady" : "Lord"; prefix = m_Female ? "Lady " : "Lord ";
} }
else else
{ {
prefix = ""; prefix = " ";
} }
var suffix = ""; var title = PropertyTitle && !string.IsNullOrEmpty(Title) ? Title : "";
if (PropertyTitle && !string.IsNullOrEmpty(Title))
{
suffix = Title;
}
string suffix;
var guild = m_Guild; var guild = m_Guild;
if (guild != null && (m_Player || m_DisplayGuildTitle)) if (guild != null && (m_Player || m_DisplayGuildTitle))
{ {
suffix = suffix.Length > 0 suffix = title.Length > 0
? $"{suffix} [{Utility.FixHtml(guild.Abbreviation)}]" ? $"{title} [{Utility.FixHtml(guild.Abbreviation)}]"
: $"[{Utility.FixHtml(guild.Abbreviation)}]"; : $"[{Utility.FixHtml(guild.Abbreviation)}]";
} }
else
{
suffix = " ";
}
suffix = ApplyNameSuffix(suffix); list.Add(1050045, $"{prefix}\t{name}\t{ApplyNameSuffix(suffix)}"); // ~1_PREFIX~~2_NAME~~3_SUFFIX~
list.Add(1050045, "{0} \t{1}\t {2}", prefix, name, suffix); // ~1_PREFIX~~2_NAME~~3_SUFFIX~
if (guild != null && (m_DisplayGuildTitle || m_Player && guild.Type != GuildType.Regular)) if (guild != null && (m_DisplayGuildTitle || m_Player && guild.Type != GuildType.Regular))
{ {
var type = guild.Type >= 0 && (int)guild.Type < m_GuildTypes.Length ? m_GuildTypes[(int)guild.Type] : ""; var type = guild.Type >= 0 && (int)guild.Type < m_GuildTypes.Length ? m_GuildTypes[(int)guild.Type] : "";
var title = GuildTitle?.Trim() ?? ""; var guildTitle = GuildTitle?.Trim() ?? "";
if (title.Length > 0) if (guildTitle.Length > 0)
{ {
if (NewGuildDisplay) list.Add(
{ NewGuildDisplay
list.Add("{0}, {1}", Utility.FixHtml(title), Utility.FixHtml(guild.Name)); ? $"{Utility.FixHtml(guildTitle)}, {Utility.FixHtml(guild.Name)}"
} : $"{Utility.FixHtml(guildTitle)}, {Utility.FixHtml(guild.Name)} Guild{type}"
else );
{
list.Add("{0}, {1} Guild{2}", Utility.FixHtml(title), Utility.FixHtml(guild.Name), type);
}
} }
else else
{ {
@ -3504,11 +3498,11 @@ namespace Server
} }
} }
public virtual void GetChildProperties(ObjectPropertyList list, Item item) public virtual void GetChildProperties(IPropertyList list, Item item)
{ {
} }
public virtual void GetChildNameProperties(ObjectPropertyList list, Item item) public virtual void GetChildNameProperties(IPropertyList list, Item item)
{ {
} }

View file

@ -41,7 +41,7 @@ public static class OutgoingEntityPackets
writer.Write(hash); writer.Write(hash);
} }
public static void SendOPLInfo(this NetState ns, IPropertyListObject obj) => public static void SendOPLInfo(this NetState ns, IObjectPropertyListEntity obj) =>
ns.SendOPLInfo(obj.Serial, obj.PropertyList.Hash); ns.SendOPLInfo(obj.Serial, obj.PropertyList.Hash);
public static void SendOPLInfo(this NetState ns, Serial serial, int hash) public static void SendOPLInfo(this NetState ns, Serial serial, int hash)

View file

@ -1,184 +0,0 @@
using System;
using System.Buffers;
using System.IO;
using System.Runtime.CompilerServices;
using Server.Network;
namespace Server
{
public interface IPropertyListObject : IEntity
{
ObjectPropertyList PropertyList { get; }
void GetProperties(ObjectPropertyList list);
}
public sealed class ObjectPropertyList
{
// Each of these are localized to "~1_NOTHING~" which allows the string argument to be used
private static readonly int[] m_StringNumbers =
{
1042971,
1070722
};
private int _hash;
private int _strings;
private byte[] _buffer;
private int _position;
public ObjectPropertyList(IEntity e)
{
Entity = e;
_buffer = GC.AllocateUninitializedArray<byte>(64);
var writer = new SpanWriter(_buffer);
writer.Write((byte)0xD6); // Packet ID
writer.Seek(2, SeekOrigin.Current);
writer.Write((ushort)1);
writer.Write(e.Serial);
writer.Write((ushort)0);
_position = writer.Position + 4; // Hash
}
public IEntity Entity { get; }
public int Hash => 0x40000000 + _hash;
public int Header { get; set; }
public string HeaderArgs { get; set; }
public static bool Enabled { get; set; }
public byte[] Buffer => _buffer;
public void Reset()
{
_position = 15;
_hash = 0;
_strings = 0;
Header = 0;
HeaderArgs = null;
}
public void Flush()
{
Resize(_buffer.Length * 2);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void Resize(int amount)
{
var newBuffer = GC.AllocateUninitializedArray<byte>(amount);
_buffer.AsSpan(0, Math.Min(amount, _buffer.Length)).CopyTo(newBuffer);
_buffer = newBuffer;
}
public void Terminate()
{
int length = _position + 4;
if (length != _buffer.Length)
{
Resize(length);
}
var writer = new SpanWriter(_buffer);
writer.Seek(_position, SeekOrigin.Begin);
writer.Write(0);
writer.Seek(11, SeekOrigin.Begin);
writer.Write(_hash);
writer.WritePacketLength();
}
public void AddHash(int val)
{
_hash ^= val & 0x3FFFFFF;
_hash ^= (val >> 26) & 0x3F;
}
public void Add(int number, string arguments = null)
{
if (number == 0)
{
return;
}
arguments ??= "";
if (Header == 0)
{
Header = number;
HeaderArgs = arguments;
}
AddHash(number);
if (arguments.Length > 0)
{
AddHash(arguments.GetHashCode(StringComparison.Ordinal));
}
int strLength = arguments.Length * 2;
int length = _position + 6 + strLength;
while (length > _buffer.Length)
{
Flush();
}
var writer = new SpanWriter(_buffer.AsSpan(_position));
writer.Write(number);
writer.Write((ushort)strLength);
writer.WriteLittleUni(arguments);
_position += writer.BytesWritten;
}
public void Add(int number, string format, object arg0)
{
Add(number, string.Format(format, arg0));
}
public void Add(int number, string format, object arg0, object arg1)
{
Add(number, string.Format(format, arg0, arg1));
}
public void Add(int number, string format, object arg0, object arg1, object arg2)
{
Add(number, string.Format(format, arg0, arg1, arg2));
}
public void Add(int number, string format, params object[] args)
{
Add(number, string.Format(format, args));
}
private int GetStringNumber() => m_StringNumbers[_strings++ % m_StringNumbers.Length];
public void Add(string text)
{
Add(GetStringNumber(), text);
}
public void Add(string format, string arg0)
{
Add(GetStringNumber(), string.Format(format, arg0));
}
public void Add(string format, string arg0, string arg1)
{
Add(GetStringNumber(), string.Format(format, arg0, arg1));
}
public void Add(string format, string arg0, string arg1, string arg2)
{
Add(GetStringNumber(), string.Format(format, arg0, arg1, arg2));
}
public void Add(string format, params object[] args)
{
Add(GetStringNumber(), string.Format(format, args));
}
}
}

View file

@ -0,0 +1,23 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2022 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: IObjectPropertyListEntity.cs *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
namespace Server;
public interface IObjectPropertyListEntity : IEntity
{
ObjectPropertyList PropertyList { get; }
void GetProperties(IPropertyList list);
}

View file

@ -0,0 +1,30 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2022 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: IPropertyList.cs *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System.Runtime.CompilerServices;
using Server.Text;
namespace Server;
public interface IPropertyList : ISelfInterpolatedStringHandler
{
public void Reset();
public void Terminate();
public void Add(int number, string argument = null);
public void Add(string text);
// String Interpolation
public void Add(int number, [InterpolatedStringHandlerArgument("")] ref InterpolatedStringHandler handler);
}

View file

@ -0,0 +1,508 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2022 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: ObjectPropertyList.cs *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
#nullable enable
using System;
using System.Buffers;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using Server.Buffers;
using Server.Network;
using Server.Text;
namespace Server;
public sealed class ObjectPropertyList : IPropertyList, IDisposable
{
// Each of these are localized to "~1_NOTHING~" which allows the string argument to be used
private static readonly int[] _stringNumbers =
{
1042971,
1070722,
1114057, // ~1_val~
1114778, // ~1_val~
1114779 // ~1_val~
};
private int _hash;
private int _stringNumbersIndex;
private byte[] _buffer;
private int _bufferPos;
// For string interpolation
private int _pos;
private char[]? _arrayToReturnToPool;
public ObjectPropertyList(IEntity? e)
{
Entity = e;
_buffer = GC.AllocateUninitializedArray<byte>(64);
var writer = new SpanWriter(_buffer);
writer.Write((byte)0xD6); // Packet ID
writer.Seek(2, SeekOrigin.Current);
writer.Write((ushort)1);
writer.Write(e?.Serial ?? Serial.Zero);
writer.Write((ushort)0);
_bufferPos = writer.Position + 4; // Hash
}
public IEntity? Entity { get; }
public int Hash => 0x40000000 + _hash;
public int Header { get; set; }
public string HeaderArgs { get; set; }
public static bool Enabled { get; set; }
public byte[] Buffer => _buffer;
public void Reset()
{
_bufferPos = 15;
_hash = 0;
_stringNumbersIndex = 0;
Header = 0;
HeaderArgs = null;
STArrayPool<char>.Shared.Return(_arrayToReturnToPool);
_pos = 0;
}
private void Flush()
{
Resize(_buffer.Length * 2);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void Resize(int amount)
{
var newBuffer = GC.AllocateUninitializedArray<byte>(amount);
_buffer.AsSpan(0, Math.Min(amount, _buffer.Length)).CopyTo(newBuffer);
_buffer = newBuffer;
}
public void Terminate()
{
int length = _bufferPos + 4;
if (length != _buffer.Length)
{
Resize(length);
}
var writer = new SpanWriter(_buffer);
writer.Seek(_bufferPos, SeekOrigin.Begin);
writer.Write(0);
writer.Seek(11, SeekOrigin.Begin);
writer.Write(_hash);
writer.WritePacketLength();
}
private void AddHash(int val)
{
_hash ^= val & 0x3FFFFFF;
_hash ^= (val >> 26) & 0x3F;
}
public void Add(int number, string? arguments = null)
{
if (number == 0)
{
return;
}
arguments ??= "";
if (Header == 0)
{
Header = number;
HeaderArgs = arguments;
}
AddHash(number);
if (arguments.Length > 0)
{
AddHash(arguments.GetHashCode(StringComparison.Ordinal));
}
int strLength = arguments.Length * 2;
int length = _bufferPos + 6 + strLength;
while (length > _buffer.Length)
{
Flush();
}
var writer = new SpanWriter(_buffer.AsSpan(_bufferPos));
writer.Write(number);
writer.Write((ushort)strLength);
writer.WriteLittleUni(arguments);
_bufferPos += writer.BytesWritten;
_pos = 0;
}
private int GetStringNumber() => _stringNumbers[_stringNumbersIndex++ % _stringNumbers.Length];
public void Add(string argument) => Add(GetStringNumber(), argument);
public void Add(
[InterpolatedStringHandlerArgument("")]
ref IPropertyList.InterpolatedStringHandler handler
) => Add(GetStringNumber(), ref handler);
// String Interpolation
public void Add(
int number,
[InterpolatedStringHandlerArgument("")]
ref IPropertyList.InterpolatedStringHandler handler)
{
if (number == 0)
{
return;
}
var chars = _arrayToReturnToPool.AsSpan(0, _pos);
if (Header == 0)
{
Header = number;
HeaderArgs = chars.ToString();
HeaderArgs.GetHashCode(StringComparison.Ordinal);
}
AddHash(number);
if (chars.Length > 0)
{
AddHash(string.GetHashCode(chars, StringComparison.Ordinal));
}
int strLength = chars.Length * 2;
int length = _bufferPos + 6 + strLength;
while (length > _buffer.Length)
{
Flush();
}
var writer = new SpanWriter(_buffer.AsSpan(_bufferPos));
writer.Write(number);
writer.Write((ushort)strLength);
writer.Write(chars, TextEncoding.UnicodeLE);
_bufferPos += writer.BytesWritten;
}
public void InitializeInterpolation(int literalLength, int formattedCount)
{
_arrayToReturnToPool ??= STArrayPool<char>.Shared.Rent(GetDefaultLength(literalLength, formattedCount));
_pos = 0;
}
// Copied from RawInterpolatedStringHandler
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int GetDefaultLength(int literalLength, int formattedCount) =>
Math.Max(256, literalLength + formattedCount * 11);
public void AppendLiteral(string value)
{
if (value.Length == 1)
{
Span<char> chars = _arrayToReturnToPool.AsSpan();
int pos = _pos;
if ((uint)pos < (uint)chars.Length)
{
chars[pos] = value[0];
_pos = pos + 1;
}
else
{
GrowThenCopyString(value);
}
return;
}
AppendStringDirect(value);
}
private void AppendStringDirect(string value)
{
if (value.TryCopyTo(_arrayToReturnToPool.AsSpan(_pos..)))
{
_pos += value.Length;
}
else
{
GrowThenCopyString(value);
}
}
public void AppendFormatted<T>(T value)
{
string? s;
if (value is IFormattable)
{
if (value is ISpanFormattable)
{
int charsWritten;
while (!((ISpanFormattable)value).TryFormat(_arrayToReturnToPool.AsSpan(_pos..), out charsWritten, default, null))
{
Grow();
}
_pos += charsWritten;
return;
}
s = ((IFormattable)value).ToString(format: null, null);
}
else
{
s = value?.ToString();
}
if (s is not null)
{
AppendStringDirect(s);
}
}
public void AppendFormatted<T>(T value, string? format)
{
string? s;
if (value is IFormattable)
{
if (value is ISpanFormattable)
{
int charsWritten;
while (!((ISpanFormattable)value).TryFormat(_arrayToReturnToPool.AsSpan(_pos..), out charsWritten, format, null))
{
Grow();
}
_pos += charsWritten;
return;
}
s = ((IFormattable)value).ToString(format, null);
}
else
{
s = value?.ToString();
}
if (s is not null)
{
AppendStringDirect(s);
}
}
public void AppendFormatted<T>(T value, int alignment)
{
int startingPos = _pos;
AppendFormatted(value);
if (alignment != 0)
{
AppendOrInsertAlignmentIfNeeded(startingPos, alignment);
}
}
public void AppendFormatted<T>(T value, int alignment, string? format)
{
int startingPos = _pos;
AppendFormatted(value, format);
if (alignment != 0)
{
AppendOrInsertAlignmentIfNeeded(startingPos, alignment);
}
}
public void AppendFormatted(ReadOnlySpan<char> value)
{
if (value.TryCopyTo(_arrayToReturnToPool.AsSpan(_pos..)))
{
_pos += value.Length;
}
else
{
GrowThenCopySpan(value);
}
}
public void AppendFormatted(ReadOnlySpan<char> value, int alignment = 0, string? format = null)
{
bool leftAlign = false;
if (alignment < 0)
{
leftAlign = true;
alignment = -alignment;
}
int paddingRequired = alignment - value.Length;
if (paddingRequired <= 0)
{
AppendFormatted(value);
return;
}
EnsureCapacityForAdditionalChars(value.Length + paddingRequired);
var chars = _arrayToReturnToPool.AsSpan();
if (leftAlign)
{
value.CopyTo(chars[_pos..]);
_pos += value.Length;
chars.Slice(_pos, paddingRequired).Fill(' ');
_pos += paddingRequired;
}
else
{
chars.Slice(_pos, paddingRequired).Fill(' ');
_pos += paddingRequired;
value.CopyTo(chars[_pos..]);
_pos += value.Length;
}
}
public void AppendFormatted(string? value)
{
if (value?.TryCopyTo(_arrayToReturnToPool.AsSpan(_pos..)) == true)
{
_pos += value.Length;
}
else
{
AppendFormattedSlow(value);
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
private void AppendFormattedSlow(string? value)
{
if (value is not null)
{
EnsureCapacityForAdditionalChars(value.Length);
value.CopyTo(_arrayToReturnToPool.AsSpan(_pos..));
_pos += value.Length;
}
}
public void AppendFormatted(string? value, int alignment = 0, string? format = null) =>
AppendFormatted<string?>(value, alignment, format);
public void AppendFormatted(object? value, int alignment = 0, string? format = null) =>
AppendFormatted<object?>(value, alignment, format);
private void AppendOrInsertAlignmentIfNeeded(int startingPos, int alignment)
{
Debug.Assert(startingPos >= 0 && startingPos <= _pos);
Debug.Assert(alignment != 0);
int charsWritten = _pos - startingPos;
bool leftAlign = false;
if (alignment < 0)
{
leftAlign = true;
alignment = -alignment;
}
int paddingNeeded = alignment - charsWritten;
if (paddingNeeded > 0)
{
EnsureCapacityForAdditionalChars(paddingNeeded);
var chars = _arrayToReturnToPool.AsSpan();
if (leftAlign)
{
chars.Slice(_pos, paddingNeeded).Fill(' ');
}
else
{
chars.Slice(startingPos, charsWritten).CopyTo(chars[(startingPos + paddingNeeded)..]);
chars.Slice(startingPos, paddingNeeded).Fill(' ');
}
_pos += paddingNeeded;
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void EnsureCapacityForAdditionalChars(int additionalChars)
{
if (_arrayToReturnToPool.Length - _pos < additionalChars)
{
Grow(additionalChars);
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
private void GrowThenCopyString(string value)
{
Grow(value.Length);
value.CopyTo(_arrayToReturnToPool.AsSpan(_pos..));
_pos += value.Length;
}
[MethodImpl(MethodImplOptions.NoInlining)]
private void GrowThenCopySpan(ReadOnlySpan<char> value)
{
Grow(value.Length);
value.CopyTo(_arrayToReturnToPool.AsSpan(_pos..));
_pos += value.Length;
}
[MethodImpl(MethodImplOptions.NoInlining)]
private void Grow(int additionalChars)
{
Debug.Assert(additionalChars > _arrayToReturnToPool.Length - _pos);
GrowCore((uint)_pos + (uint)additionalChars);
}
[MethodImpl(MethodImplOptions.NoInlining)]
private void Grow()
{
GrowCore((uint)_arrayToReturnToPool.Length + 1);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void GrowCore(uint requiredMinCapacity)
{
uint newCapacity = Math.Max(requiredMinCapacity, Math.Min((uint)_arrayToReturnToPool.Length * 2, 0x3FFFFFDF));
int arraySize = (int)Math.Clamp(newCapacity, 256, int.MaxValue);
char[] newArray = STArrayPool<char>.Shared.Rent(arraySize);
_arrayToReturnToPool.AsSpan(.._pos).CopyTo(newArray);
char[] toReturn = _arrayToReturnToPool;
_arrayToReturnToPool = newArray;
STArrayPool<char>.Shared.Return(toReturn);
}
public void Dispose()
{
STArrayPool<char>.Shared.Return(_arrayToReturnToPool);
_arrayToReturnToPool = null;
}
~ObjectPropertyList()
{
STArrayPool<char>.Shared.Return(_arrayToReturnToPool);
_arrayToReturnToPool = null;
}
}

View file

@ -0,0 +1,71 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2022 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: ISelfInterpolatedStringHandler.cs *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
using System.Runtime.CompilerServices;
namespace Server.Text;
public interface ISelfInterpolatedStringHandler
{
public void Add([InterpolatedStringHandlerArgument("")] ref InterpolatedStringHandler handler);
public void InitializeInterpolation(int literalLength, int formattedCount);
public void AppendLiteral(string value);
public void AppendFormatted<T>(T value);
public void AppendFormatted<T>(T value, string? format);
public void AppendFormatted<T>(T value, int alignment);
public void AppendFormatted<T>(T value, int alignment, string? format);
public void AppendFormatted(ReadOnlySpan<char> value);
public void AppendFormatted(ReadOnlySpan<char> value, int alignment, string? format = null);
public void AppendFormatted(object? value, int alignment = 0, string? format = null);
public void AppendFormatted(string? value);
public void AppendFormatted(string? value, int alignment, string? format = null);
[InterpolatedStringHandler]
public ref struct InterpolatedStringHandler
{
private ISelfInterpolatedStringHandler _parent;
public InterpolatedStringHandler(int literalLength, int formattedCount, ISelfInterpolatedStringHandler parent)
{
_parent = parent;
_parent.InitializeInterpolation(literalLength, formattedCount);
}
public void AppendLiteral(string value) => _parent.AppendLiteral(value);
public void AppendFormatted<T>(T value) => _parent.AppendFormatted(value);
public void AppendFormatted<T>(T value, string? format) => _parent.AppendFormatted(value, format);
public void AppendFormatted<T>(T value, int alignment) => _parent.AppendFormatted(value, alignment);
public void AppendFormatted<T>(T value, int alignment, string? format) =>
_parent.AppendFormatted(value, alignment, format);
public void AppendFormatted(ReadOnlySpan<char> value) => _parent.AppendFormatted(value);
public void AppendFormatted(ReadOnlySpan<char> value, int alignment, string? format = null) =>
_parent.AppendFormatted(value, alignment, format);
public void AppendFormatted(object? value, int alignment = 0, string? format = null) =>
_parent.AppendFormatted(value, alignment, format);
public void AppendFormatted(string? value) => _parent.AppendFormatted(value);
public void AppendFormatted(string? value, int alignment, string? format = null) =>
_parent.AppendFormatted(value, alignment, format);
}
}

View file

@ -285,4 +285,22 @@ public static class StringHelpers
4 => MemoryMarshal.Cast<byte, uint>(buffer).IndexOf((uint)0) * 4, 4 => MemoryMarshal.Cast<byte, uint>(buffer).IndexOf((uint)0) * 4,
_ => buffer.IndexOf((byte)0) _ => buffer.IndexOf((byte)0)
}; };
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ReplaceAny(this Span<char> chars, ReadOnlySpan<char> invalidChars, ReadOnlySpan<char> replacementChars)
{
while (true)
{
var indexOf = chars.IndexOfAny(invalidChars);
if (indexOf == -1)
{
break;
}
var chr = chars[indexOf];
chars[indexOf] = replacementChars[invalidChars.IndexOf(chr)];
chars = chars[(indexOf + 1)..];
}
}
} }

View file

@ -560,7 +560,7 @@ namespace Server
return str; return str;
} }
using var sb = new ValueStringBuilder(str, stackalloc char[Math.Min(40960, str.Length)]); using var sb = new ValueStringBuilder(str, stackalloc char[Math.Min(128, str.Length)]);
ReadOnlySpan<char> invalid = stackalloc []{ '<', '>', '#' }; ReadOnlySpan<char> invalid = stackalloc []{ '<', '>', '#' };
ReadOnlySpan<char> replacement = stackalloc []{ '(', ')', '-' }; ReadOnlySpan<char> replacement = stackalloc []{ '(', ')', '-' };
sb.ReplaceAny(invalid, replacement, 0, sb.Length); sb.ReplaceAny(invalid, replacement, 0, sb.Length);
@ -568,6 +568,19 @@ namespace Server
return sb.ToString(); return sb.ToString();
} }
public static void FixHtml(Span<char> chars)
{
if (chars.Length == 0)
{
return;
}
ReadOnlySpan<char> invalid = stackalloc []{ '<', '>', '#' };
ReadOnlySpan<char> replacement = stackalloc []{ '(', ')', '-' };
chars.ReplaceAny(invalid, replacement);
}
public static int InsensitiveCompare(string first, string second) => first.InsensitiveCompare(second); public static int InsensitiveCompare(string first, string second) => first.InsensitiveCompare(second);
public static bool InsensitiveStartsWith(string first, string second) => first.InsensitiveStartsWith(second); public static bool InsensitiveStartsWith(string first, string second) => first.InsensitiveStartsWith(second);

View file

@ -258,11 +258,11 @@ namespace Server.Engines.BulkOrders
} }
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
list.Add(1062344, Entries.Count.ToString()); // Deeds in book: ~1_val~ list.Add(1062344, $"{Entries.Count}"); // Deeds in book: ~1_val~
if (!string.IsNullOrEmpty(m_BookName)) if (!string.IsNullOrEmpty(m_BookName))
{ {

View file

@ -38,7 +38,7 @@ namespace Server.Engines.BulkOrders
public override int LabelNumber => 1045151; // a bulk order deed public override int LabelNumber => 1045151; // a bulk order deed
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
@ -54,11 +54,12 @@ namespace Server.Engines.BulkOrders
list.Add(LargeBODGump.GetMaterialNumberFor(Material)); // All items must be made with x material. list.Add(LargeBODGump.GetMaterialNumberFor(Material)); // All items must be made with x material.
} }
list.Add(1060656, AmountMax.ToString()); // amount to make: ~1_val~ list.Add(1060656, $"{AmountMax}"); // amount to make: ~1_val~
for (var i = 0; i < _entries.Length; ++i) for (var i = 0; i < _entries.Length; ++i)
{ {
list.Add(1060658 + i, "#{0}\t{1}", _entries[i].Details.Number, _entries[i].Amount); // ~1_val~: ~2_val~ var entry = _entries[i];
list.Add(1060658 + i, $"#{entry.Details.Number}\t{entry.Amount}"); // ~1_val~: ~2_val~
} }
} }

View file

@ -61,7 +61,7 @@ namespace Server.Engines.BulkOrders
public override int LabelNumber => 1045151; // a bulk order deed public override int LabelNumber => 1045151; // a bulk order deed
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
@ -77,8 +77,8 @@ namespace Server.Engines.BulkOrders
list.Add(SmallBODGump.GetMaterialNumberFor(Material)); // All items must be made with x material. list.Add(SmallBODGump.GetMaterialNumberFor(Material)); // All items must be made with x material.
} }
list.Add(1060656, AmountMax.ToString()); // amount to make: ~1_val~ list.Add(1060656, $"{AmountMax}"); // amount to make: ~1_val~
list.Add(1060658, "#{0}\t{1}", m_Number, m_AmountCur); // ~1_val~: ~2_val~ list.Add(1060658, $"#{m_Number}\t{m_AmountCur}"); // ~1_val~: ~2_val~
} }
public override void OnDoubleClick(Mobile from) public override void OnDoubleClick(Mobile from)

View file

@ -934,21 +934,22 @@ namespace Server.Engines.CannedEvil
return new Point3D(X + x, Y + y, Z - 15); return new Point3D(X + x, Y + y, Z - 15);
} }
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(IPropertyList list)
{ {
list.Add("champion spawn"); list.Add("champion spawn");
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
if (m_Active) if (m_Active)
{ {
list.Add(1060742); // active list.Add(1060742); // active
list.Add(1060658, "Type\t{0}", m_Type); // ~1_val~: ~2_val~ list.Add(1060658, $"Type\t{m_Type}"); // ~1_val~: ~2_val~
list.Add(1060659, "Level\t{0}", Level); // ~1_val~: ~2_val~ list.Add(1060659, $"Level\t{Level}"); // ~1_val~: ~2_val~
list.Add(1060660, "Kills\t{0} of {1} ({2:F1}%)", m_Kills, MaxKills, 100.0 * ((double)m_Kills / MaxKills)); // ~1_val~: ~2_val~ var killRatio = 100.0 * ((double)m_Kills / MaxKills);
list.Add(1060660, $"Kills\t{m_Kills} of {MaxKills} ({killRatio:F1}%)"); // ~1_val~: ~2_val~
//list.Add(1060661, "Spawn Range\t{0}", m_SpawnRange); // ~1_val~: ~2_val~ //list.Add(1060661, "Spawn Range\t{0}", m_SpawnRange); // ~1_val~: ~2_val~
} }
else else
@ -961,11 +962,11 @@ namespace Server.Engines.CannedEvil
{ {
if (m_Active) if (m_Active)
{ {
LabelTo(from, "{0} (Active; Level: {1}; Kills: {2}/{3})", m_Type, Level, m_Kills, MaxKills); LabelTo(from, $"{m_Type} (Active; Level: {Level}; Kills: {m_Kills}/{MaxKills})");
} }
else else
{ {
LabelTo(from, "{0} (Inactive)", m_Type); LabelTo(from, $"{m_Type} (Inactive)");
} }
} }

View file

@ -163,23 +163,20 @@ namespace Server.Engines.ConPVP
AddBorderedText(35, y, 190, 20, $"Tiebreaker: {tieText}", LabelColor32, BlackColor32); AddBorderedText(35, y, 190, 20, $"Tiebreaker: {tieText}", LabelColor32, BlackColor32);
y += 20; y += 20;
var sdText = "Off"; string sdText;
if (tourney.SuddenDeath > TimeSpan.Zero) if (tourney.SuddenDeath > TimeSpan.Zero)
{ {
sdText = $"{(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2}"; sdText = tourney.SuddenDeathRounds > 0 ?
$"Sudden Death: {(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2} (first {tourney.SuddenDeathRounds} rounds)" :
if (tourney.SuddenDeathRounds > 0) $"Sudden Death: {(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2} (all rounds)";
{ }
sdText = $"{sdText} (first {tourney.SuddenDeathRounds} rounds)"; else
} {
else sdText = "Sudden Death: Off";
{
sdText = $"{sdText} (all rounds)";
}
} }
AddBorderedText(35, y, 240, 20, $"Sudden Death: {sdText}", LabelColor32, BlackColor32); AddBorderedText(35, y, 240, 20, sdText, LabelColor32, BlackColor32);
y += 20; y += 20;
y += 6; y += 6;

View file

@ -169,23 +169,20 @@ namespace Server.Engines.ConPVP
AddBorderedText(35, y, 190, 20, $"Tiebreaker: {tieText}", LabelColor32, BlackColor32); AddBorderedText(35, y, 190, 20, $"Tiebreaker: {tieText}", LabelColor32, BlackColor32);
y += 20; y += 20;
var sdText = "Off"; string sdText;
if (tourney.SuddenDeath > TimeSpan.Zero) if (tourney.SuddenDeath > TimeSpan.Zero)
{ {
sdText = $"{(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2}"; sdText = tourney.SuddenDeathRounds > 0 ?
$"Sudden Death: {(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2} (first {tourney.SuddenDeathRounds} rounds)" :
if (tourney.SuddenDeathRounds > 0) $"Sudden Death: {(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2} (all rounds)";
{ }
sdText = $"{sdText} (first {tourney.SuddenDeathRounds} rounds)"; else
} {
else sdText = "Sudden Death: Off";
{
sdText = $"{sdText} (all rounds)";
}
} }
AddBorderedText(35, y, 240, 20, $"Sudden Death: {sdText}", LabelColor32, BlackColor32); AddBorderedText(35, y, 240, 20, sdText, LabelColor32, BlackColor32);
y += 20; y += 20;
y += 6; y += 6;

View file

@ -214,23 +214,20 @@ namespace Server.Engines.ConPVP
AddHtml(35, y, 190, 20, $"Tiebreaker: {tieText}"); AddHtml(35, y, 190, 20, $"Tiebreaker: {tieText}");
y += 20; y += 20;
var sdText = "Off"; string sdText;
if (tourney.SuddenDeath > TimeSpan.Zero) if (tourney.SuddenDeath > TimeSpan.Zero)
{ {
sdText = $"{(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2}"; sdText = tourney.SuddenDeathRounds > 0 ?
$"Sudden Death: {(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2} (first {tourney.SuddenDeathRounds} rounds)" :
if (tourney.SuddenDeathRounds > 0) $"Sudden Death: {(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2} (all rounds)";
{ }
sdText = $"{sdText} (first {tourney.SuddenDeathRounds} rounds)"; else
} {
else sdText = "Sudden Death: Off";
{
sdText = $"{sdText} (all rounds)";
}
} }
AddHtml(35, y, 240, 20, $"Sudden Death: {sdText}"); AddHtml(35, y, 240, 20, sdText);
y += 20; y += 20;
y += 8; y += 8;

View file

@ -128,7 +128,7 @@ namespace Server.Factions
InvalidateProperties(); InvalidateProperties();
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);

View file

@ -30,12 +30,12 @@ namespace Server.Factions
} }
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
// NOTE: OSI does not list uses remaining; intentional difference // NOTE: OSI does not list uses remaining; intentional difference
list.Add(1060584, Charges.ToString()); // uses remaining: ~1_val~ list.Add(1060584, $"{Charges}"); // uses remaining: ~1_val~
} }
public override void Serialize(IGenericWriter writer) public override void Serialize(IGenericWriter writer)

View file

@ -308,7 +308,7 @@ namespace Server.Factions
} }
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);

View file

@ -15,7 +15,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -17,7 +17,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -13,7 +13,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -13,7 +13,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -13,7 +13,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -15,7 +15,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -17,7 +17,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -13,7 +13,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -13,7 +13,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -14,7 +14,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -13,7 +13,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -17,7 +17,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -13,7 +13,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -13,7 +13,7 @@ namespace Server.Items
public override int LabelNumber => 1075299; // Prismatic Amber public override int LabelNumber => 1075299; // Prismatic Amber
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);

View file

@ -27,7 +27,7 @@ namespace Server.Engines.MLQuests.Items
public List<MLQuest> MLQuests => m_MLQuests ?? public List<MLQuest> MLQuests => m_MLQuests ??
(m_MLQuests = MLQuestSystem.FindQuestList(GetType()) ?? MLQuestSystem.EmptyList); (m_MLQuests = MLQuestSystem.FindQuestList(GetType()) ?? MLQuestSystem.EmptyList);
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
@ -105,7 +105,7 @@ namespace Server.Engines.MLQuests.Items
{ {
} }
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);

View file

@ -13,7 +13,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -13,7 +13,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -14,7 +14,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -13,7 +13,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -13,7 +13,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -13,7 +13,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -17,7 +17,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -71,7 +71,7 @@ namespace Server.Engines.MLQuests.Items
return false; return false;
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
@ -179,7 +179,7 @@ namespace Server.Engines.MLQuests.Items
return true; return true;
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);

View file

@ -13,7 +13,7 @@ namespace Server.Items
public override bool Nontransferable => true; public override bool Nontransferable => true;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
AddQuestItemProperty(list); AddQuestItemProperty(list);

View file

@ -248,7 +248,7 @@ namespace Server.Engines.Plants
InvalidateProperties(); InvalidateProperties();
} }
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(IPropertyList list)
{ {
if (m_PlantStatus >= PlantStatus.DeadTwigs) if (m_PlantStatus >= PlantStatus.DeadTwigs)
{ {

View file

@ -124,7 +124,7 @@ namespace Server.Engines.Plants
return hueInfo.IsBright() ? 1113491 : 1113490; // ~1_amount~ [bright] ~2_val~ seeds return hueInfo.IsBright() ? 1113491 : 1113490; // ~1_amount~ [bright] ~2_val~ seeds
} }
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(IPropertyList list)
{ {
list.Add(GetLabel(out var args), args); list.Add(GetLabel(out var args), args);
} }

View file

@ -141,7 +141,7 @@ namespace Server.Engines.Quests.Collector
public static string RandomName(Mobile from) => m_Names.RandomElement() ?? from.Name; public static string RandomName(Mobile from) => m_Names.RandomElement() ?? from.Name;
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(IPropertyList list)
{ {
if (m_Quantity < m_Partial) if (m_Quantity < m_Partial)
{ {

View file

@ -31,7 +31,7 @@ namespace Server.Engines.Quests.Collector
} }
} }
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(IPropertyList list)
{ {
var info = ImageTypeInfo.Get(m_Image); var info = ImageTypeInfo.Get(m_Image);
list.Add(1060847, $"#1055126\t#{info.Name}"); // a painted image of: list.Add(1060847, $"#1055126\t#{info.Name}"); // a painted image of:

View file

@ -43,11 +43,11 @@ namespace Server.Engines.Quests
public virtual bool ValidateUse(Mobile from) => true; public virtual bool ValidateUse(Mobile from) => true;
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
list.Add(1060741, m_Charges.ToString()); // charges: ~1_val~ list.Add(1060741, $"{m_Charges}"); // charges: ~1_val~
} }
public override void OnDoubleClick(Mobile from) public override void OnDoubleClick(Mobile from)

View file

@ -70,7 +70,7 @@ namespace Server.Engines.Quests.Haven
return new FacialHairInfo(Race.Human.RandomFacialHair(false), m_HairHue); return new FacialHairInfo(Race.Human.RandomFacialHair(false), m_HairHue);
} }
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(IPropertyList list)
{ {
if (ItemID == 0x2006) // Corpse form if (ItemID == 0x2006) // Corpse form
{ {

View file

@ -108,7 +108,7 @@ namespace Server.Engines.Quests.Haven
{ {
} }
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(IPropertyList list)
{ {
if (ItemID == 0x2006) // Corpse form if (ItemID == 0x2006) // Corpse form
{ {

View file

@ -39,7 +39,7 @@ namespace Server.Engines.Quests.Hag
private static List<Item> GetEquipment() => new(); private static List<Item> GetEquipment() => new();
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(IPropertyList list)
{ {
list.Add("a charred corpse"); list.Add("a charred corpse");
} }

View file

@ -353,11 +353,11 @@ namespace Server.Engines.Spawners
from.SendGump(new SpawnerGump(this)); from.SendGump(new SpawnerGump(this));
} }
public virtual void GetSpawnerProperties(ObjectPropertyList list) public virtual void GetSpawnerProperties(IPropertyList list)
{ {
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
@ -365,18 +365,19 @@ namespace Server.Engines.Spawners
{ {
list.Add(1060742); // active list.Add(1060742); // active
list.Add(1060656, m_Count.ToString()); // amount to make: ~1_val~ list.Add(1060656, $"{m_Count}"); // amount to make: ~1_val~
list.Add(1061169, m_HomeRange.ToString()); // range ~1_val~ list.Add(1061169, $"{m_HomeRange}"); // range ~1_val~
list.Add(1050039, "walking range:\t{0}", m_WalkingRange); // ~1_NUMBER~ ~2_ITEMNAME~ list.Add(1050039, $"walking range:\t{m_WalkingRange}"); // ~1_NUMBER~ ~2_ITEMNAME~
list.Add(1053099, "group:\t{0}", m_Group); // ~1_oretype~: ~2_armortype~ list.Add(1053099, $"group:\t{m_Group}"); // ~1_oretype~: ~2_armortype~
list.Add(1060847, "team:\t{0}", m_Team); // ~1_val~ ~2_val~ list.Add(1060847, $"team:\t{m_Team}"); // ~1_val~ ~2_val~
list.Add(1063483, "delay:\t{0} to {1}", m_MinDelay, m_MaxDelay); // ~1_MATERIAL~: ~2_ITEMNAME~ list.Add(1063483, $"delay:\t{m_MinDelay} to {m_MaxDelay}"); // ~1_MATERIAL~: ~2_ITEMNAME~
GetSpawnerProperties(list); GetSpawnerProperties(list);
for (var i = 0; i < 6 && i < Entries.Count; ++i) for (var i = 0; i < 6 && i < Entries.Count; ++i)
{ {
list.Add(1060658 + i, "\t{0}\t{1}", Entries[i].SpawnedName, CountSpawns(Entries[i])); var entry = Entries[i];
list.Add(1060658 + i, $"\t{entry.SpawnedName}\t{CountSpawns(entry)}");
} }
} }
else else
@ -794,7 +795,7 @@ namespace Server.Engines.Spawners
} }
else else
{ {
m_Timer?.Stop(); m_Timer.Stop();
m_Timer.Delay = delay; m_Timer.Delay = delay;
} }

View file

@ -88,13 +88,13 @@ namespace Server.Engines.Spawners
json.SetProperty("region", options, SpawnRegion.Name); json.SetProperty("region", options, SpawnRegion.Name);
} }
public override void GetSpawnerProperties(ObjectPropertyList list) public override void GetSpawnerProperties(IPropertyList list)
{ {
base.GetSpawnerProperties(list); base.GetSpawnerProperties(list);
if (Running && m_SpawnRegion != null) if (Running && m_SpawnRegion != null)
{ {
list.Add(1076228, "region:\t{0}", m_SpawnRegion.Name); // ~1_DUMMY~ ~2_DUMMY~ list.Add(1076228, $"region:\t{m_SpawnRegion.Name}"); // ~1_DUMMY~ ~2_DUMMY~
} }
} }

View file

@ -113,7 +113,7 @@ namespace Server.Items
set { } set { }
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
@ -122,7 +122,7 @@ namespace Server.Items
TextDefinition.AddTo(list, m_Label); TextDefinition.AddTo(list, m_Label);
} }
list.Add(1060584, m_UsesRemaining.ToString()); // uses remaining: ~1_val~ list.Add(1060584, $"{m_UsesRemaining}"); // uses remaining: ~1_val~
} }
public override void OnDoubleClick(Mobile from) public override void OnDoubleClick(Mobile from)

View file

@ -713,7 +713,7 @@ namespace Server.Items
Utility.Intern(ref m_UrnName); Utility.Intern(ref m_UrnName);
} }
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(IPropertyList list)
{ {
list.Add(1070935, m_UrnName); // Ancient Urn of ~1_name~ list.Add(1070935, m_UrnName); // Ancient Urn of ~1_name~
} }
@ -772,7 +772,7 @@ namespace Server.Items
Utility.Intern(ref m_SwordsName); Utility.Intern(ref m_SwordsName);
} }
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(IPropertyList list)
{ {
list.Add(1070936, m_SwordsName); // Honorable Swords of ~1_name~ list.Add(1070936, m_SwordsName); // Honorable Swords of ~1_name~
} }

View file

@ -128,7 +128,7 @@ namespace Server.Mobiles
DisplayPaperdollTo(from); DisplayPaperdollTo(from);
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
@ -496,7 +496,7 @@ namespace Server.Mobiles
} }
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);

View file

@ -71,7 +71,7 @@ namespace Server.Items
} }
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);

View file

@ -12,7 +12,7 @@ namespace Server.Items
public override bool AllowEquippedCast(Mobile from) => true; public override bool AllowEquippedCast(Mobile from) => true;
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);

View file

@ -47,7 +47,7 @@ namespace Server.Items
public bool CanSign => !IsSigned || Core.Now <= EditLimit; public bool CanSign => !IsSigned || Core.Now <= EditLimit;
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(IPropertyList list)
{ {
if (_owner != null) if (_owner != null)
{ {
@ -63,7 +63,7 @@ namespace Server.Items
AddLine(list, 1150303, _line3); // [ ~1_LINE2~ ] AddLine(list, 1150303, _line3); // [ ~1_LINE2~ ]
} }
private static void AddLine(ObjectPropertyList list, int cliloc, string line) private static void AddLine(IPropertyList list, int cliloc, string line)
{ {
if (line != null) if (line != null)
{ {

View file

@ -27,7 +27,7 @@ namespace Server.Items
public bool IsSigned => _from != null && _to != null; public bool IsSigned => _from != null && _to != null;
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(IPropertyList list)
{ {
base.AddNameProperty(list); base.AddNameProperty(list);

View file

@ -160,7 +160,7 @@ namespace Server.Items
} }
} }
/* /*
public override void GetProperties(ObjectPropertyList list) => _addon?.GetProperties(list); public override void GetProperties(IPropertyList list) => _addon?.GetProperties(list);
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list) => public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list) =>
_addon?.GetContextMenuEntries(from, list); _addon?.GetContextMenuEntries(from, list);

View file

@ -77,7 +77,7 @@ namespace Server.Items
} }
} }
public override void GetProperties(ObjectPropertyList list) => _addon?.GetProperties(list); public override void GetProperties(IPropertyList list) => _addon?.GetProperties(list);
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list) => public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list) =>
_addon?.GetContextMenuEntries(from, list); _addon?.GetContextMenuEntries(from, list);

View file

@ -168,7 +168,7 @@ namespace Server.Items
base.OnDelete(); base.OnDelete();
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);

View file

@ -97,7 +97,7 @@ namespace Server.Items
} }
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);

View file

@ -364,18 +364,18 @@ namespace Server.Items
} }
} }
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
if (_vacationLeft > 0) if (_vacationLeft > 0)
{ {
list.Add(1074430, _vacationLeft.ToString()); // Vacation days left: ~1_DAYS list.Add(1074430, $"{_vacationLeft}"); // Vacation days left: ~1_DAYS
} }
if (_events.Count > 0) if (_events.Count > 0)
{ {
list.Add(1074426, _events.Count.ToString()); // ~1_NUM~ event(s) to view! list.Add(1074426, $"{_events.Count}"); // ~1_NUM~ event(s) to view!
} }
if (_rewardAvailable) if (_rewardAvailable)
@ -383,60 +383,54 @@ namespace Server.Items
list.Add(1074362); // A reward is available! list.Add(1074362); // A reward is available!
} }
list.Add(1074247, "{0}\t{1}", LiveCreatures, MaxLiveCreatures); // Live Creatures: ~1_NUM~ / ~2_MAX~ list.Add(1074247, $"{LiveCreatures}\t{MaxLiveCreatures}"); // Live Creatures: ~1_NUM~ / ~2_MAX~
var dead = DeadCreatures; var dead = DeadCreatures;
if (dead > 0) if (dead > 0)
{ {
list.Add(1074248, dead.ToString()); // Dead Creatures: ~1_NUM~ list.Add(1074248, $"{dead}"); // Dead Creatures: ~1_NUM~
} }
var decorations = Items.Count - LiveCreatures - dead; var decorations = Items.Count - LiveCreatures - dead;
if (decorations > 0) if (decorations > 0)
{ {
list.Add(1074249, decorations.ToString()); // Decorations: ~1_NUM~ list.Add(1074249, $"{decorations}"); // Decorations: ~1_NUM~
} }
list.Add(1074250, "#{0}", FoodNumber()); // Food state: ~1_STATE~ list.Add(1074250, $"#{FoodNumber()}"); // Food state: ~1_STATE~
list.Add(1074251, "#{0}", WaterNumber()); // Water state: ~1_STATE~ list.Add(1074251, $"#{WaterNumber()}"); // Water state: ~1_STATE~
if (_food.State == (int)FoodState.Dead) if (_food.State == (int)FoodState.Dead)
{ {
list.Add(1074577, "{0}\t{1}", _food.Added, _food.Improve); // Food Added: ~1_CUR~ Needed: ~2_NEED~ list.Add(1074577, $"{_food.Added}\t{_food.Improve}"); // Food Added: ~1_CUR~ Needed: ~2_NEED~
} }
else if (_food.State == (int)FoodState.Overfed) else if (_food.State == (int)FoodState.Overfed)
{ {
list.Add(1074577, "{0}\t{1}", _food.Added, _food.Maintain); // Food Added: ~1_CUR~ Needed: ~2_NEED~ list.Add(1074577, $"{_food.Added}\t{_food.Maintain}"); // Food Added: ~1_CUR~ Needed: ~2_NEED~
} }
else else
{ {
list.Add( list.Add(
1074253, // Food Added: ~1_CUR~ Feed: ~2_NEED~ Improve: ~3_GROW~ 1074253, // Food Added: ~1_CUR~ Feed: ~2_NEED~ Improve: ~3_GROW~
"{0}\t{1}\t{2}", $"{_food.Added}\t{_food.Maintain}\t{_food.Improve}"
_food.Added,
_food.Maintain,
_food.Improve
); );
} }
if (_water.State == (int)WaterState.Dead) if (_water.State == (int)WaterState.Dead)
{ {
list.Add(1074578, "{0}\t{1}", _water.Added, _water.Improve); // Water Added: ~1_CUR~ Needed: ~2_NEED~ list.Add(1074578, $"{_water.Added}\t{_water.Improve}"); // Water Added: ~1_CUR~ Needed: ~2_NEED~
} }
else if (_water.State == (int)WaterState.Strong) else if (_water.State == (int)WaterState.Strong)
{ {
list.Add(1074578, "{0}\t{1}", _water.Added, _water.Maintain); // Water Added: ~1_CUR~ Needed: ~2_NEED~ list.Add(1074578, $"{_water.Added}\t{_water.Maintain}"); // Water Added: ~1_CUR~ Needed: ~2_NEED~
} }
else else
{ {
list.Add( list.Add(
1074254, // Water Added: ~1_CUR~ Maintain: ~2_NEED~ Improve: ~3_GROW~ 1074254, // Water Added: ~1_CUR~ Maintain: ~2_NEED~ Improve: ~3_GROW~
"{0}\t{1}\t{2}", $"{_water.Added}\t{_water.Maintain}\t{_water.Improve}"
_water.Added,
_water.Maintain,
_water.Improve
); );
} }
} }

View file

@ -15,7 +15,7 @@ namespace Server.Items
public override bool RequireDeepWater => false; public override bool RequireDeepWater => false;
protected override void AddNetProperties(ObjectPropertyList list) protected override void AddNetProperties(IPropertyList list)
{ {
} }

View file

@ -60,7 +60,7 @@ namespace Server.Items
return Dead ? 1073623 : 1073622; // A [dead/live] aquarium creature return Dead ? 1073623 : 1073622; // A [dead/live] aquarium creature
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);

View file

@ -78,7 +78,7 @@ namespace Server.Items
return base.CheckLift(from, item, ref reject); return base.CheckLift(from, item, ref reject);
} }
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
@ -88,7 +88,7 @@ namespace Server.Items
if (fish != null) if (fish != null)
{ {
list.Add(1074494, "#{0}", fish.LabelNumber); // Contains: ~1_CREATURE~ list.Add(1074494, $"#{fish.LabelNumber}"); // Contains: ~1_CREATURE~
} }
} }
} }

View file

@ -12,7 +12,7 @@ namespace Server.Items
public override int LabelNumber => 1073894; // Message in a Bottle public override int LabelNumber => 1073894; // Message in a Bottle
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);

View file

@ -12,7 +12,7 @@ namespace Server.Items
public override int LabelNumber => 1074571; // Captain Blackheart's Fishing Pole public override int LabelNumber => 1074571; // Captain Blackheart's Fishing Pole
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);

View file

@ -21,7 +21,7 @@ namespace Server.Items
public override int InitMinHits => 20; public override int InitMinHits => 20;
public override int InitMaxHits => 30; public override int InitMaxHits => 30;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);

View file

@ -13,7 +13,7 @@ namespace Server.Items
public override int LabelNumber => 1074601; // Fish bones public override int LabelNumber => 1074601; // Fish bones
public override double DefaultWeight => 1.0; public override double DefaultWeight => 1.0;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);

View file

@ -13,7 +13,7 @@ namespace Server.Items
public override int LabelNumber => 1074600; // An island statue public override int LabelNumber => 1074600; // An island statue
public override double DefaultWeight => 1.0; public override double DefaultWeight => 1.0;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);

View file

@ -13,7 +13,7 @@ namespace Server.Items
public override int LabelNumber => 1074598; // A shell public override int LabelNumber => 1074598; // A shell
public override double DefaultWeight => 1.0; public override double DefaultWeight => 1.0;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);

View file

@ -14,7 +14,7 @@ namespace Server.Items
public override int LabelNumber => 1074363; // A toy boat public override int LabelNumber => 1074363; // A toy boat
public override double DefaultWeight => 1.0; public override double DefaultWeight => 1.0;
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);

View file

@ -24,7 +24,7 @@ namespace Server.Items
public override int LabelNumber => 1074364; // Waterlogged boots public override int LabelNumber => 1074364; // Waterlogged boots
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);

View file

@ -14,11 +14,11 @@ namespace Server.Items
public override int LabelNumber => 1074431; // An aquarium flake sphere public override int LabelNumber => 1074431; // An aquarium flake sphere
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);
list.Add(1074432, VacationDays.ToString()); // Vacation days: ~1_DAYS~ list.Add(1074432, $"{VacationDays}"); // Vacation days: ~1_DAYS~
} }
} }
} }

View file

@ -1223,9 +1223,7 @@ namespace Server.Items
base.OnRemoved(parent); base.OnRemoved(parent);
} }
private string GetNameString() => Name ?? $"#{LabelNumber}"; public override void AddNameProperty(IPropertyList list)
public override void AddNameProperty(ObjectPropertyList list)
{ {
var oreType = _rawResource switch var oreType = _rawResource switch
{ {
@ -1249,31 +1247,26 @@ namespace Server.Items
_ => 0 _ => 0
}; };
if (_quality == ArmorQuality.Exceptional) var name = Name;
if (oreType != 0)
{ {
if (oreType != 0) list.Add(
{ _quality == ArmorQuality.Exceptional ? 1053100 : 1053099,
list.Add(1053100, "#{0}\t{1}", oreType, GetNameString()); // exceptional ~1_oretype~ ~2_armortype~ name != null ? $"#{oreType}\t{Name}" : $"#{oreType}\t#{LabelNumber}"
} );
else }
{ else if (_quality == ArmorQuality.Exceptional)
list.Add(1050040, GetNameString()); // exceptional ~1_ITEMNAME~ {
} list.Add(1050040, name ?? $"#{LabelNumber}"); // exceptional ~1_ITEMNAME~
}
else if (name == null)
{
list.Add(LabelNumber);
} }
else else
{ {
if (oreType != 0) list.Add(Name);
{
list.Add(1053099, "#{0}\t{1}", oreType, GetNameString()); // ~1_oretype~ ~2_armortype~
}
else if (Name == null)
{
list.Add(LabelNumber);
}
else
{
list.Add(Name);
}
} }
} }
@ -1289,7 +1282,7 @@ namespace Server.Items
public virtual int GetLuckBonus() => CraftResources.GetInfo(_rawResource)?.AttributeInfo?.ArmorLuck ?? 0; public virtual int GetLuckBonus() => CraftResources.GetInfo(_rawResource)?.AttributeInfo?.ArmorLuck ?? 0;
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
@ -1319,72 +1312,72 @@ namespace Server.Items
if ((prop = ArtifactRarity) > 0) if ((prop = ArtifactRarity) > 0)
{ {
list.Add(1061078, prop.ToString()); // artifact rarity ~1_val~ list.Add(1061078, $"{prop}"); // artifact rarity ~1_val~
} }
if ((prop = Attributes.WeaponDamage) != 0) if ((prop = Attributes.WeaponDamage) != 0)
{ {
list.Add(1060401, prop.ToString()); // damage increase ~1_val~% list.Add(1060401, $"{prop}"); // damage increase ~1_val~%
} }
if ((prop = Attributes.DefendChance) != 0) if ((prop = Attributes.DefendChance) != 0)
{ {
list.Add(1060408, prop.ToString()); // defense chance increase ~1_val~% list.Add(1060408, $"{prop}"); // defense chance increase ~1_val~%
} }
if ((prop = Attributes.BonusDex) != 0) if ((prop = Attributes.BonusDex) != 0)
{ {
list.Add(1060409, prop.ToString()); // dexterity bonus ~1_val~ list.Add(1060409, $"{prop}"); // dexterity bonus ~1_val~
} }
if ((prop = Attributes.EnhancePotions) != 0) if ((prop = Attributes.EnhancePotions) != 0)
{ {
list.Add(1060411, prop.ToString()); // enhance potions ~1_val~% list.Add(1060411, $"{prop}"); // enhance potions ~1_val~%
} }
if ((prop = Attributes.CastRecovery) != 0) if ((prop = Attributes.CastRecovery) != 0)
{ {
list.Add(1060412, prop.ToString()); // faster cast recovery ~1_val~ list.Add(1060412, $"{prop}"); // faster cast recovery ~1_val~
} }
if ((prop = Attributes.CastSpeed) != 0) if ((prop = Attributes.CastSpeed) != 0)
{ {
list.Add(1060413, prop.ToString()); // faster casting ~1_val~ list.Add(1060413, $"{prop}"); // faster casting ~1_val~
} }
if ((prop = Attributes.AttackChance) != 0) if ((prop = Attributes.AttackChance) != 0)
{ {
list.Add(1060415, prop.ToString()); // hit chance increase ~1_val~% list.Add(1060415, $"{prop}"); // hit chance increase ~1_val~%
} }
if ((prop = Attributes.BonusHits) != 0) if ((prop = Attributes.BonusHits) != 0)
{ {
list.Add(1060431, prop.ToString()); // hit point increase ~1_val~ list.Add(1060431, $"{prop}"); // hit point increase ~1_val~
} }
if ((prop = Attributes.BonusInt) != 0) if ((prop = Attributes.BonusInt) != 0)
{ {
list.Add(1060432, prop.ToString()); // intelligence bonus ~1_val~ list.Add(1060432, $"{prop}"); // intelligence bonus ~1_val~
} }
if ((prop = Attributes.LowerManaCost) != 0) if ((prop = Attributes.LowerManaCost) != 0)
{ {
list.Add(1060433, prop.ToString()); // lower mana cost ~1_val~% list.Add(1060433, $"{prop}"); // lower mana cost ~1_val~%
} }
if ((prop = Attributes.LowerRegCost) != 0) if ((prop = Attributes.LowerRegCost) != 0)
{ {
list.Add(1060434, prop.ToString()); // lower reagent cost ~1_val~% list.Add(1060434, $"{prop}"); // lower reagent cost ~1_val~%
} }
if ((prop = GetLowerStatReq()) != 0) if ((prop = GetLowerStatReq()) != 0)
{ {
list.Add(1060435, prop.ToString()); // lower requirements ~1_val~% list.Add(1060435, $"{prop}"); // lower requirements ~1_val~%
} }
if ((prop = GetLuckBonus() + Attributes.Luck) != 0) if ((prop = GetLuckBonus() + Attributes.Luck) != 0)
{ {
list.Add(1060436, prop.ToString()); // luck ~1_val~ list.Add(1060436, $"{prop}"); // luck ~1_val~
} }
if (ArmorAttributes.MageArmor != 0) if (ArmorAttributes.MageArmor != 0)
@ -1394,12 +1387,12 @@ namespace Server.Items
if ((prop = Attributes.BonusMana) != 0) if ((prop = Attributes.BonusMana) != 0)
{ {
list.Add(1060439, prop.ToString()); // mana increase ~1_val~ list.Add(1060439, $"{prop}"); // mana increase ~1_val~
} }
if ((prop = Attributes.RegenMana) != 0) if ((prop = Attributes.RegenMana) != 0)
{ {
list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~ list.Add(1060440, $"{prop}"); // mana regeneration ~1_val~
} }
if (Attributes.NightSight != 0) if (Attributes.NightSight != 0)
@ -1409,22 +1402,22 @@ namespace Server.Items
if ((prop = Attributes.ReflectPhysical) != 0) if ((prop = Attributes.ReflectPhysical) != 0)
{ {
list.Add(1060442, prop.ToString()); // reflect physical damage ~1_val~% list.Add(1060442, $"{prop}"); // reflect physical damage ~1_val~%
} }
if ((prop = Attributes.RegenStam) != 0) if ((prop = Attributes.RegenStam) != 0)
{ {
list.Add(1060443, prop.ToString()); // stamina regeneration ~1_val~ list.Add(1060443, $"{prop}"); // stamina regeneration ~1_val~
} }
if ((prop = Attributes.RegenHits) != 0) if ((prop = Attributes.RegenHits) != 0)
{ {
list.Add(1060444, prop.ToString()); // hit point regeneration ~1_val~ list.Add(1060444, $"{prop}"); // hit point regeneration ~1_val~
} }
if ((prop = ArmorAttributes.SelfRepair) != 0) if ((prop = ArmorAttributes.SelfRepair) != 0)
{ {
list.Add(1060450, prop.ToString()); // self repair ~1_val~ list.Add(1060450, $"{prop}"); // self repair ~1_val~
} }
if (Attributes.SpellChanneling != 0) if (Attributes.SpellChanneling != 0)
@ -1434,44 +1427,44 @@ namespace Server.Items
if ((prop = Attributes.SpellDamage) != 0) if ((prop = Attributes.SpellDamage) != 0)
{ {
list.Add(1060483, prop.ToString()); // spell damage increase ~1_val~% list.Add(1060483, $"{prop}"); // spell damage increase ~1_val~%
} }
if ((prop = Attributes.BonusStam) != 0) if ((prop = Attributes.BonusStam) != 0)
{ {
list.Add(1060484, prop.ToString()); // stamina increase ~1_val~ list.Add(1060484, $"{prop}"); // stamina increase ~1_val~
} }
if ((prop = Attributes.BonusStr) != 0) if ((prop = Attributes.BonusStr) != 0)
{ {
list.Add(1060485, prop.ToString()); // strength bonus ~1_val~ list.Add(1060485, $"{prop}"); // strength bonus ~1_val~
} }
if ((prop = Attributes.WeaponSpeed) != 0) if ((prop = Attributes.WeaponSpeed) != 0)
{ {
list.Add(1060486, prop.ToString()); // swing speed increase ~1_val~% list.Add(1060486, $"{prop}"); // swing speed increase ~1_val~%
} }
if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0) if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0)
{ {
list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~% list.Add(1075210, $"{prop}"); // Increased Karma Loss ~1val~%
} }
AddResistanceProperties(list); AddResistanceProperties(list);
if ((prop = GetDurabilityBonus()) > 0) if ((prop = GetDurabilityBonus()) > 0)
{ {
list.Add(1060410, prop.ToString()); // durability ~1_val~% list.Add(1060410, $"{prop}"); // durability ~1_val~%
} }
if ((prop = ComputeStatReq(StatType.Str)) > 0) if ((prop = ComputeStatReq(StatType.Str)) > 0)
{ {
list.Add(1061170, prop.ToString()); // strength requirement ~1_val~ list.Add(1061170, $"{prop}"); // strength requirement ~1_val~
} }
if (_hitPoints >= 0 && _maxHitPoints > 0) if (_hitPoints >= 0 && _maxHitPoints > 0)
{ {
list.Add(1060639, "{0}\t{1}", _hitPoints, _maxHitPoints); // durability ~1_val~ / ~2_val~ list.Add(1060639, $"{_hitPoints}\t{_maxHitPoints}"); // durability ~1_val~ / ~2_val~
} }
} }

View file

@ -42,7 +42,7 @@ namespace Server.Items
[SerializableFieldDefault(0)] [SerializableFieldDefault(0)]
private AosWeaponAttributes WeaponAttributesDefaultValue() => new(this); private AosWeaponAttributes WeaponAttributesDefaultValue() => new(this);
public override void AppendChildNameProperties(ObjectPropertyList list) public override void AppendChildNameProperties(IPropertyList list)
{ {
base.AppendChildNameProperties(list); base.AppendChildNameProperties(list);
@ -50,77 +50,77 @@ namespace Server.Items
if ((prop = _weaponAttributes.HitColdArea) != 0) if ((prop = _weaponAttributes.HitColdArea) != 0)
{ {
list.Add(1060416, prop.ToString()); // hit cold area ~1_val~% list.Add(1060416, $"{prop}"); // hit cold area ~1_val~%
} }
if ((prop = _weaponAttributes.HitDispel) != 0) if ((prop = _weaponAttributes.HitDispel) != 0)
{ {
list.Add(1060417, prop.ToString()); // hit dispel ~1_val~% list.Add(1060417, $"{prop}"); // hit dispel ~1_val~%
} }
if ((prop = _weaponAttributes.HitEnergyArea) != 0) if ((prop = _weaponAttributes.HitEnergyArea) != 0)
{ {
list.Add(1060418, prop.ToString()); // hit energy area ~1_val~% list.Add(1060418, $"{prop}"); // hit energy area ~1_val~%
} }
if ((prop = _weaponAttributes.HitFireArea) != 0) if ((prop = _weaponAttributes.HitFireArea) != 0)
{ {
list.Add(1060419, prop.ToString()); // hit fire area ~1_val~% list.Add(1060419, $"{prop}"); // hit fire area ~1_val~%
} }
if ((prop = _weaponAttributes.HitFireball) != 0) if ((prop = _weaponAttributes.HitFireball) != 0)
{ {
list.Add(1060420, prop.ToString()); // hit fireball ~1_val~% list.Add(1060420, $"{prop}"); // hit fireball ~1_val~%
} }
if ((prop = _weaponAttributes.HitHarm) != 0) if ((prop = _weaponAttributes.HitHarm) != 0)
{ {
list.Add(1060421, prop.ToString()); // hit harm ~1_val~% list.Add(1060421, $"{prop}"); // hit harm ~1_val~%
} }
if ((prop = _weaponAttributes.HitLeechHits) != 0) if ((prop = _weaponAttributes.HitLeechHits) != 0)
{ {
list.Add(1060422, prop.ToString()); // hit life leech ~1_val~% list.Add(1060422, $"{prop}"); // hit life leech ~1_val~%
} }
if ((prop = _weaponAttributes.HitLightning) != 0) if ((prop = _weaponAttributes.HitLightning) != 0)
{ {
list.Add(1060423, prop.ToString()); // hit lightning ~1_val~% list.Add(1060423, $"{prop}"); // hit lightning ~1_val~%
} }
if ((prop = _weaponAttributes.HitLowerAttack) != 0) if ((prop = _weaponAttributes.HitLowerAttack) != 0)
{ {
list.Add(1060424, prop.ToString()); // hit lower attack ~1_val~% list.Add(1060424, $"{prop}"); // hit lower attack ~1_val~%
} }
if ((prop = _weaponAttributes.HitLowerDefend) != 0) if ((prop = _weaponAttributes.HitLowerDefend) != 0)
{ {
list.Add(1060425, prop.ToString()); // hit lower defense ~1_val~% list.Add(1060425, $"{prop}"); // hit lower defense ~1_val~%
} }
if ((prop = _weaponAttributes.HitMagicArrow) != 0) if ((prop = _weaponAttributes.HitMagicArrow) != 0)
{ {
list.Add(1060426, prop.ToString()); // hit magic arrow ~1_val~% list.Add(1060426, $"{prop}"); // hit magic arrow ~1_val~%
} }
if ((prop = _weaponAttributes.HitLeechMana) != 0) if ((prop = _weaponAttributes.HitLeechMana) != 0)
{ {
list.Add(1060427, prop.ToString()); // hit mana leech ~1_val~% list.Add(1060427, $"{prop}"); // hit mana leech ~1_val~%
} }
if ((prop = _weaponAttributes.HitPhysicalArea) != 0) if ((prop = _weaponAttributes.HitPhysicalArea) != 0)
{ {
list.Add(1060428, prop.ToString()); // hit physical area ~1_val~% list.Add(1060428, $"{prop}"); // hit physical area ~1_val~%
} }
if ((prop = _weaponAttributes.HitPoisonArea) != 0) if ((prop = _weaponAttributes.HitPoisonArea) != 0)
{ {
list.Add(1060429, prop.ToString()); // hit poison area ~1_val~% list.Add(1060429, $"{prop}"); // hit poison area ~1_val~%
} }
if ((prop = _weaponAttributes.HitLeechStam) != 0) if ((prop = _weaponAttributes.HitLeechStam) != 0)
{ {
list.Add(1060430, prop.ToString()); // hit stamina leech ~1_val~% list.Add(1060430, $"{prop}"); // hit stamina leech ~1_val~%
} }
} }
} }

View file

@ -89,13 +89,13 @@ namespace Server.Items
} }
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
if (IsArcane) if (IsArcane)
{ {
list.Add(1061837, "{0}\t{1}", _curArcaneCharges, _maxArcaneCharges); // arcane charges: ~1_val~ / ~2_val~ list.Add(1061837, $"{_curArcaneCharges}\t{_maxArcaneCharges}"); // arcane charges: ~1_val~ / ~2_val~
} }
} }

View file

@ -88,13 +88,13 @@ namespace Server.Items
} }
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
if (IsArcane) if (IsArcane)
{ {
list.Add(1061837, "{0}\t{1}", _curArcaneCharges, _maxArcaneCharges); // arcane charges: ~1_val~ / ~2_val~ list.Add(1061837, $"{_curArcaneCharges}\t{_maxArcaneCharges}"); // arcane charges: ~1_val~ / ~2_val~
} }
} }

View file

@ -174,7 +174,7 @@ namespace Server.Items
} }
} }
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(IPropertyList list)
{ {
if (!string.IsNullOrEmpty(_title)) if (!string.IsNullOrEmpty(_title))
{ {

View file

@ -137,7 +137,7 @@ namespace Server.Items
public override BookContent DefaultContent => Content; public override BookContent DefaultContent => Content;
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(IPropertyList list)
{ {
list.Add("Fropoz's Journal"); list.Add("Fropoz's Journal");
} }

View file

@ -216,7 +216,7 @@ namespace Server.Items
public override BookContent DefaultContent => Content; public override BookContent DefaultContent => Content;
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(IPropertyList list)
{ {
list.Add("Khabur's Journal"); list.Add("Khabur's Journal");
} }

View file

@ -118,7 +118,7 @@ namespace Server.Items
public override BookContent DefaultContent => Content; public override BookContent DefaultContent => Content;
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(IPropertyList list)
{ {
list.Add("Translated Gargoyle Journal"); list.Add("Translated Gargoyle Journal");
} }

View file

@ -662,9 +662,7 @@ namespace Server.Items
}; };
} }
private string GetNameString() => Name ?? $"#{LabelNumber}"; public override void AddNameProperty(IPropertyList list)
public override void AddNameProperty(ObjectPropertyList list)
{ {
var oreType = _rawResource switch var oreType = _rawResource switch
{ {
@ -688,21 +686,23 @@ namespace Server.Items
_ => 0 _ => 0
}; };
var name = Name;
if (oreType != 0) if (oreType != 0)
{ {
list.Add(1053099, "#{0}\t{1}", oreType, GetNameString()); // ~1_oretype~ ~2_armortype~ list.Add(1053099, name != null ? $"#{oreType}\t{name}" : $"#{oreType}\t#{LabelNumber}"); // ~1_oretype~ ~2_armortype~
} }
else if (Name == null) else if (name == null)
{ {
list.Add(LabelNumber); list.Add(LabelNumber);
} }
else else
{ {
list.Add(Name); list.Add(name);
} }
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
@ -737,72 +737,72 @@ namespace Server.Items
if ((prop = ArtifactRarity) > 0) if ((prop = ArtifactRarity) > 0)
{ {
list.Add(1061078, prop.ToString()); // artifact rarity ~1_val~ list.Add(1061078, $"{prop}"); // artifact rarity ~1_val~
} }
if ((prop = Attributes.WeaponDamage) != 0) if ((prop = Attributes.WeaponDamage) != 0)
{ {
list.Add(1060401, prop.ToString()); // damage increase ~1_val~% list.Add(1060401, $"{prop}"); // damage increase ~1_val~%
} }
if ((prop = Attributes.DefendChance) != 0) if ((prop = Attributes.DefendChance) != 0)
{ {
list.Add(1060408, prop.ToString()); // defense chance increase ~1_val~% list.Add(1060408, $"{prop}"); // defense chance increase ~1_val~%
} }
if ((prop = Attributes.BonusDex) != 0) if ((prop = Attributes.BonusDex) != 0)
{ {
list.Add(1060409, prop.ToString()); // dexterity bonus ~1_val~ list.Add(1060409, $"{prop}"); // dexterity bonus ~1_val~
} }
if ((prop = Attributes.EnhancePotions) != 0) if ((prop = Attributes.EnhancePotions) != 0)
{ {
list.Add(1060411, prop.ToString()); // enhance potions ~1_val~% list.Add(1060411, $"{prop}"); // enhance potions ~1_val~%
} }
if ((prop = Attributes.CastRecovery) != 0) if ((prop = Attributes.CastRecovery) != 0)
{ {
list.Add(1060412, prop.ToString()); // faster cast recovery ~1_val~ list.Add(1060412, $"{prop}"); // faster cast recovery ~1_val~
} }
if ((prop = Attributes.CastSpeed) != 0) if ((prop = Attributes.CastSpeed) != 0)
{ {
list.Add(1060413, prop.ToString()); // faster casting ~1_val~ list.Add(1060413, $"{prop}"); // faster casting ~1_val~
} }
if ((prop = Attributes.AttackChance) != 0) if ((prop = Attributes.AttackChance) != 0)
{ {
list.Add(1060415, prop.ToString()); // hit chance increase ~1_val~% list.Add(1060415, $"{prop}"); // hit chance increase ~1_val~%
} }
if ((prop = Attributes.BonusHits) != 0) if ((prop = Attributes.BonusHits) != 0)
{ {
list.Add(1060431, prop.ToString()); // hit point increase ~1_val~ list.Add(1060431, $"{prop}"); // hit point increase ~1_val~
} }
if ((prop = Attributes.BonusInt) != 0) if ((prop = Attributes.BonusInt) != 0)
{ {
list.Add(1060432, prop.ToString()); // intelligence bonus ~1_val~ list.Add(1060432, $"{prop}"); // intelligence bonus ~1_val~
} }
if ((prop = Attributes.LowerManaCost) != 0) if ((prop = Attributes.LowerManaCost) != 0)
{ {
list.Add(1060433, prop.ToString()); // lower mana cost ~1_val~% list.Add(1060433, $"{prop}"); // lower mana cost ~1_val~%
} }
if ((prop = Attributes.LowerRegCost) != 0) if ((prop = Attributes.LowerRegCost) != 0)
{ {
list.Add(1060434, prop.ToString()); // lower reagent cost ~1_val~% list.Add(1060434, $"{prop}"); // lower reagent cost ~1_val~%
} }
if ((prop = ClothingAttributes.LowerStatReq) != 0) if ((prop = ClothingAttributes.LowerStatReq) != 0)
{ {
list.Add(1060435, prop.ToString()); // lower requirements ~1_val~% list.Add(1060435, $"{prop}"); // lower requirements ~1_val~%
} }
if ((prop = Attributes.Luck) != 0) if ((prop = Attributes.Luck) != 0)
{ {
list.Add(1060436, prop.ToString()); // luck ~1_val~ list.Add(1060436, $"{prop}"); // luck ~1_val~
} }
if (ClothingAttributes.MageArmor != 0) if (ClothingAttributes.MageArmor != 0)
@ -812,12 +812,12 @@ namespace Server.Items
if ((prop = Attributes.BonusMana) != 0) if ((prop = Attributes.BonusMana) != 0)
{ {
list.Add(1060439, prop.ToString()); // mana increase ~1_val~ list.Add(1060439, $"{prop}"); // mana increase ~1_val~
} }
if ((prop = Attributes.RegenMana) != 0) if ((prop = Attributes.RegenMana) != 0)
{ {
list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~ list.Add(1060440, $"{prop}"); // mana regeneration ~1_val~
} }
if (Attributes.NightSight != 0) if (Attributes.NightSight != 0)
@ -827,22 +827,22 @@ namespace Server.Items
if ((prop = Attributes.ReflectPhysical) != 0) if ((prop = Attributes.ReflectPhysical) != 0)
{ {
list.Add(1060442, prop.ToString()); // reflect physical damage ~1_val~% list.Add(1060442, $"{prop}"); // reflect physical damage ~1_val~%
} }
if ((prop = Attributes.RegenStam) != 0) if ((prop = Attributes.RegenStam) != 0)
{ {
list.Add(1060443, prop.ToString()); // stamina regeneration ~1_val~ list.Add(1060443, $"{prop}"); // stamina regeneration ~1_val~
} }
if ((prop = Attributes.RegenHits) != 0) if ((prop = Attributes.RegenHits) != 0)
{ {
list.Add(1060444, prop.ToString()); // hit point regeneration ~1_val~ list.Add(1060444, $"{prop}"); // hit point regeneration ~1_val~
} }
if ((prop = ClothingAttributes.SelfRepair) != 0) if ((prop = ClothingAttributes.SelfRepair) != 0)
{ {
list.Add(1060450, prop.ToString()); // self repair ~1_val~ list.Add(1060450, $"{prop}"); // self repair ~1_val~
} }
if (Attributes.SpellChanneling != 0) if (Attributes.SpellChanneling != 0)
@ -852,44 +852,44 @@ namespace Server.Items
if ((prop = Attributes.SpellDamage) != 0) if ((prop = Attributes.SpellDamage) != 0)
{ {
list.Add(1060483, prop.ToString()); // spell damage increase ~1_val~% list.Add(1060483, $"{prop}"); // spell damage increase ~1_val~%
} }
if ((prop = Attributes.BonusStam) != 0) if ((prop = Attributes.BonusStam) != 0)
{ {
list.Add(1060484, prop.ToString()); // stamina increase ~1_val~ list.Add(1060484, $"{prop}"); // stamina increase ~1_val~
} }
if ((prop = Attributes.BonusStr) != 0) if ((prop = Attributes.BonusStr) != 0)
{ {
list.Add(1060485, prop.ToString()); // strength bonus ~1_val~ list.Add(1060485, $"{prop}"); // strength bonus ~1_val~
} }
if ((prop = Attributes.WeaponSpeed) != 0) if ((prop = Attributes.WeaponSpeed) != 0)
{ {
list.Add(1060486, prop.ToString()); // swing speed increase ~1_val~% list.Add(1060486, $"{prop}"); // swing speed increase ~1_val~%
} }
if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0) if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0)
{ {
list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~% list.Add(1075210, $"{prop}"); // Increased Karma Loss ~1val~%
} }
AddResistanceProperties(list); AddResistanceProperties(list);
if ((prop = ClothingAttributes.DurabilityBonus) > 0) if ((prop = ClothingAttributes.DurabilityBonus) > 0)
{ {
list.Add(1060410, prop.ToString()); // durability ~1_val~% list.Add(1060410, $"{prop}"); // durability ~1_val~%
} }
if ((prop = ComputeStatReq(StatType.Str)) > 0) if ((prop = ComputeStatReq(StatType.Str)) > 0)
{ {
list.Add(1061170, prop.ToString()); // strength requirement ~1_val~ list.Add(1061170, $"{prop}"); // strength requirement ~1_val~
} }
if (_hitPoints >= 0 && _maxHitPoints > 0) if (_hitPoints >= 0 && _maxHitPoints > 0)
{ {
list.Add(1060639, "{0}\t{1}", _hitPoints, _maxHitPoints); // durability ~1_val~ / ~2_val~ list.Add(1060639, $"{_hitPoints}\t{_maxHitPoints}"); // durability ~1_val~ / ~2_val~
} }
} }

View file

@ -80,13 +80,13 @@ namespace Server.Items
} }
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
if (IsArcane) if (IsArcane)
{ {
list.Add(1061837, "{0}\t{1}", _curArcaneCharges, _maxArcaneCharges); // arcane charges: ~1_val~ / ~2_val~ list.Add(1061837, $"{_curArcaneCharges}\t{_maxArcaneCharges}"); // arcane charges: ~1_val~ / ~2_val~
} }
} }
@ -163,7 +163,7 @@ namespace Server.Items
return false; return false;
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);

View file

@ -28,7 +28,7 @@ namespace Server.Items
} }
} }
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);

View file

@ -193,7 +193,7 @@ namespace Server.Items
return false; return false;
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
@ -275,7 +275,7 @@ namespace Server.Items
return false; return false;
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
@ -374,13 +374,13 @@ namespace Server.Items
} }
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
if (IsArcane) if (IsArcane)
{ {
list.Add(1061837, "{0}\t{1}", _curArcaneCharges, _maxArcaneCharges); // arcane charges: ~1_val~ / ~2_val~ list.Add(1061837, $"{_curArcaneCharges}\t{_maxArcaneCharges}"); // arcane charges: ~1_val~ / ~2_val~
} }
} }

View file

@ -120,13 +120,13 @@ namespace Server.Items
} }
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);
if (IsArcane) if (IsArcane)
{ {
list.Add(1061837, "{0}\t{1}", _curArcaneCharges, _maxArcaneCharges); // arcane charges: ~1_val~ / ~2_val~ list.Add(1061837, $"{_curArcaneCharges}\t{_maxArcaneCharges}"); // arcane charges: ~1_val~ / ~2_val~
} }
} }

View file

@ -40,7 +40,7 @@ namespace Server.Items
} }
} }
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);

View file

@ -172,7 +172,7 @@ public partial class CreatureBackpack : Backpack // Used on BaseCreature
Weight = 3.0; Weight = 3.0;
} }
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(IPropertyList list)
{ {
if (Name != null) if (Name != null)
{ {

View file

@ -214,7 +214,7 @@ public abstract partial class LockableContainer : TrappableContainer, ILockable,
base.OnSnoop(from); base.OnSnoop(from);
} }
public override void AddNameProperties(ObjectPropertyList list) public override void AddNameProperties(IPropertyList list)
{ {
base.AddNameProperties(list); base.AddNameProperties(list);

View file

@ -35,7 +35,7 @@ public partial class ParagonChest : LockableContainer
LabelTo(from, 1063449, _name); LabelTo(from, 1063449, _name);
} }
public override void GetProperties(ObjectPropertyList list) public override void GetProperties(IPropertyList list)
{ {
base.GetProperties(list); base.GetProperties(list);

View file

@ -59,7 +59,7 @@ public partial class StrongBox : BaseContainer, IChoppable
} }
} }
public override void AddNameProperty(ObjectPropertyList list) public override void AddNameProperty(IPropertyList list)
{ {
if (_owner != null) if (_owner != null)
{ {

Some files were not shown because too many files have changed in this diff Show more