Code Cleanup & Fixes Warnings (#74)
This commit is contained in:
parent
e11d1f3ad9
commit
57b14ad690
143 changed files with 2960 additions and 3427 deletions
|
|
@ -55,7 +55,7 @@ namespace System.Buffers
|
|||
_isDisposed = true;
|
||||
|
||||
Array = null;
|
||||
NativePointer = IntPtr.Zero;;
|
||||
NativePointer = IntPtr.Zero;
|
||||
|
||||
if (_gcHandle.IsAllocated) _gcHandle.Free();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ namespace System.Buffers
|
|||
|
||||
var basePtr = slab.NativePointer;
|
||||
// Page align the blocks
|
||||
var offset = (int)((((ulong)basePtr + (uint)_blockSize - 1) & ~((uint)_blockSize - 1)) - (ulong)basePtr);
|
||||
var offset = (int)((((ulong)basePtr + _blockSize - 1) & ~((uint)_blockSize - 1)) - (ulong)basePtr);
|
||||
// Ensure page aligned
|
||||
Debug.Assert(((ulong)basePtr + (uint)offset) % _blockSize == 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -63,8 +63,7 @@ namespace Server
|
|||
{
|
||||
state.Mobile.ProcessDelta();
|
||||
|
||||
if (playSound == null)
|
||||
playSound = Packet.Acquire(new PlaySound(soundID, p));
|
||||
playSound ??= Packet.Acquire(new PlaySound(soundID, p));
|
||||
|
||||
state.Send(playSound);
|
||||
}
|
||||
|
|
@ -103,21 +102,18 @@ namespace Server
|
|||
{
|
||||
if (SendParticlesTo(state))
|
||||
{
|
||||
if (preEffect == null)
|
||||
preEffect = Packet.Acquire(new TargetParticleEffect(e, 0, 10, 5, 0, 0, 5031, 3, 0));
|
||||
preEffect ??= Packet.Acquire(new TargetParticleEffect(e, 0, 10, 5, 0, 0, 5031, 3, 0));
|
||||
|
||||
state.Send(preEffect);
|
||||
}
|
||||
|
||||
if (boltEffect == null)
|
||||
boltEffect = Packet.Acquire(new BoltEffect(e, hue));
|
||||
boltEffect ??= Packet.Acquire(new BoltEffect(e, hue));
|
||||
|
||||
state.Send(boltEffect);
|
||||
|
||||
if (sound)
|
||||
{
|
||||
if (playSound == null)
|
||||
playSound = Packet.Acquire(new PlaySound(0x29, e));
|
||||
playSound ??= Packet.Acquire(new PlaySound(0x29, e));
|
||||
|
||||
state.Send(playSound);
|
||||
}
|
||||
|
|
@ -178,16 +174,13 @@ namespace Server
|
|||
|
||||
if (SendParticlesTo(state))
|
||||
{
|
||||
if (particles == null)
|
||||
particles = Packet.Acquire(new LocationParticleEffect(e, itemID, speed, duration, hue,
|
||||
renderMode, effect, unknown));
|
||||
particles ??= Packet.Acquire(new LocationParticleEffect(e, itemID, speed, duration, hue, renderMode, effect, unknown));
|
||||
|
||||
state.Send(particles);
|
||||
}
|
||||
else if (itemID != 0)
|
||||
{
|
||||
if (regular == null)
|
||||
regular = Packet.Acquire(new LocationEffect(e, itemID, speed, duration, hue, renderMode));
|
||||
regular ??= Packet.Acquire(new LocationEffect(e, itemID, speed, duration, hue, renderMode));
|
||||
|
||||
state.Send(regular);
|
||||
}
|
||||
|
|
@ -257,16 +250,13 @@ namespace Server
|
|||
|
||||
if (SendParticlesTo(state))
|
||||
{
|
||||
if (particles == null)
|
||||
particles = Packet.Acquire(new TargetParticleEffect(target, itemID, speed, duration, hue,
|
||||
renderMode, effect, (int)layer, unknown));
|
||||
particles ??= Packet.Acquire(new TargetParticleEffect(target, itemID, speed, duration, hue, renderMode, effect, (int)layer, unknown));
|
||||
|
||||
state.Send(particles);
|
||||
}
|
||||
else if (itemID != 0)
|
||||
{
|
||||
if (regular == null)
|
||||
regular = Packet.Acquire(new TargetEffect(target, itemID, speed, duration, hue, renderMode));
|
||||
regular ??= Packet.Acquire(new TargetEffect(target, itemID, speed, duration, hue, renderMode));
|
||||
|
||||
state.Send(regular);
|
||||
}
|
||||
|
|
@ -340,18 +330,14 @@ namespace Server
|
|||
|
||||
if (SendParticlesTo(state))
|
||||
{
|
||||
if (particles == null)
|
||||
particles = Packet.Acquire(new MovingParticleEffect(from, to, itemID, speed, duration,
|
||||
fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, layer,
|
||||
unknown));
|
||||
particles ??= Packet.Acquire(new MovingParticleEffect(from, to, itemID, speed, duration,
|
||||
fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, layer, unknown));
|
||||
|
||||
state.Send(particles);
|
||||
}
|
||||
else if (itemID > 1)
|
||||
{
|
||||
if (regular == null)
|
||||
regular = Packet.Acquire(new MovingEffect(from, to, itemID, speed, duration, fixedDirection,
|
||||
explodes, hue, renderMode));
|
||||
regular ??= Packet.Acquire(new MovingEffect(from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode));
|
||||
|
||||
state.Send(regular);
|
||||
}
|
||||
|
|
@ -370,7 +356,7 @@ namespace Server
|
|||
{
|
||||
if (map == null)
|
||||
return;
|
||||
|
||||
|
||||
IPooledEnumerable<NetState> eable = map.GetClientsInRange(origin);
|
||||
|
||||
p.Acquire();
|
||||
|
|
@ -390,7 +376,7 @@ namespace Server
|
|||
{
|
||||
if (map == null)
|
||||
return;
|
||||
|
||||
|
||||
IPooledEnumerable<NetState> eable = map.GetClientsInRange(new Point3D(origin));
|
||||
|
||||
p.Acquire();
|
||||
|
|
@ -406,4 +392,4 @@ namespace Server
|
|||
eable.Free();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using Microsoft.AspNetCore.Connections;
|
||||
using Server.Accounting;
|
||||
using Server.Guilds;
|
||||
|
|
|
|||
|
|
@ -44,32 +44,27 @@ namespace Server.Gumps
|
|||
|
||||
protected void Delta(ref uint var, uint val)
|
||||
{
|
||||
if (var != val)
|
||||
var = val;
|
||||
var = val;
|
||||
}
|
||||
|
||||
protected void Delta(ref int var, int val)
|
||||
{
|
||||
if (var != val)
|
||||
var = val;
|
||||
var = val;
|
||||
}
|
||||
|
||||
protected void Delta(ref bool var, bool val)
|
||||
{
|
||||
if (var != val)
|
||||
var = val;
|
||||
var = val;
|
||||
}
|
||||
|
||||
protected void Delta(ref string var, string val)
|
||||
{
|
||||
if (var != val)
|
||||
var = val;
|
||||
var = val;
|
||||
}
|
||||
|
||||
protected void Delta(ref object[] var, object[] val)
|
||||
{
|
||||
if (var != val)
|
||||
var = val;
|
||||
var = val;
|
||||
}
|
||||
|
||||
public abstract string Compile(NetState ns);
|
||||
|
|
|
|||
|
|
@ -1522,26 +1522,26 @@ namespace Server
|
|||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridable. Method checked to see if the elemental resistances of this Item conflict with another Item on the
|
||||
/// <see cref="Mobile" />.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// <list type="table">
|
||||
/// <item>
|
||||
/// <term>True</term>
|
||||
/// <description>
|
||||
/// There is a confliction. The elemental resistance bonuses of this Item should not be applied to the
|
||||
/// <see cref="Mobile" />
|
||||
/// </description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term>False</term>
|
||||
/// <description>There is no confliction. The bonuses should be applied.</description>
|
||||
/// </item>
|
||||
/// </list>
|
||||
/// </returns>
|
||||
public virtual bool CheckPropertyConfliction(Mobile m) => false;
|
||||
/// <summary>
|
||||
/// Overridable. Method checked to see if the elemental resistances of this Item conflict with another Item on the
|
||||
/// <see cref="Mobile" />.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// <list type="table">
|
||||
/// <item>
|
||||
/// <term>True</term>
|
||||
/// <description>
|
||||
/// There is a confliction. The elemental resistance bonuses of this Item should not be applied to the
|
||||
/// <see cref="Mobile" />
|
||||
/// </description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term>False</term>
|
||||
/// <description>There is no confliction. The bonuses should be applied.</description>
|
||||
/// </item>
|
||||
/// </list>
|
||||
/// </returns>
|
||||
public virtual bool CheckPropertyConfliction(Mobile m) => false;
|
||||
|
||||
/// <summary>
|
||||
/// Overridable. Sends the <see cref="PropertyList">object property list</see> to <paramref name="from" />.
|
||||
|
|
@ -1697,23 +1697,23 @@ namespace Server
|
|||
list.Add(1062203, "{0}", m.Name); // Blessed for ~1_NAME~
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridable. Fills an <see cref="ObjectPropertyList" /> with everything applicable. By default, this invokes
|
||||
/// <see cref="AddNameProperties" />, then <see cref="Item.GetChildProperties">Item.GetChildProperties</see> or
|
||||
/// <see cref="Mobile.GetChildProperties">Mobile.GetChildProperties</see>. This method should be overridden to add any custom
|
||||
/// properties.
|
||||
/// </summary>
|
||||
public virtual void GetProperties(ObjectPropertyList list)
|
||||
/// <summary>
|
||||
/// Overridable. Fills an <see cref="ObjectPropertyList" /> with everything applicable. By default, this invokes
|
||||
/// <see cref="AddNameProperties" />, then <see cref="Item.GetChildProperties">Item.GetChildProperties</see> or
|
||||
/// <see cref="Mobile.GetChildProperties">Mobile.GetChildProperties</see>. This method should be overridden to add any custom
|
||||
/// properties.
|
||||
/// </summary>
|
||||
public virtual void GetProperties(ObjectPropertyList list)
|
||||
{
|
||||
AddNameProperties(list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridable. Event invoked when a child (<paramref name="item" />) is building it's <see cref="ObjectPropertyList" />.
|
||||
/// Recursively calls <see cref="Item.GetChildProperties">Item.GetChildProperties</see> or
|
||||
/// <see cref="Mobile.GetChildProperties">Mobile.GetChildProperties</see>.
|
||||
/// </summary>
|
||||
public virtual void GetChildProperties(ObjectPropertyList list, Item item)
|
||||
/// <summary>
|
||||
/// Overridable. Event invoked when a child (<paramref name="item" />) is building it's <see cref="ObjectPropertyList" />.
|
||||
/// Recursively calls <see cref="Item.GetChildProperties">Item.GetChildProperties</see> or
|
||||
/// <see cref="Mobile.GetChildProperties">Mobile.GetChildProperties</see>.
|
||||
/// </summary>
|
||||
public virtual void GetChildProperties(ObjectPropertyList list, Item item)
|
||||
{
|
||||
if (m_Parent is Item parentItem)
|
||||
parentItem.GetChildProperties(list, item);
|
||||
|
|
@ -1721,12 +1721,12 @@ namespace Server
|
|||
parentMobile.GetChildProperties(list, item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridable. Event invoked when a child (<paramref name="item" />) is building it's Name <see cref="ObjectPropertyList" />
|
||||
/// . Recursively calls <see cref="Item.GetChildProperties">Item.GetChildNameProperties</see> or
|
||||
/// <see cref="Mobile.GetChildProperties">Mobile.GetChildNameProperties</see>.
|
||||
/// </summary>
|
||||
public virtual void GetChildNameProperties(ObjectPropertyList list, Item item)
|
||||
/// <summary>
|
||||
/// Overridable. Event invoked when a child (<paramref name="item" />) is building it's Name <see cref="ObjectPropertyList" />
|
||||
/// . Recursively calls <see cref="Item.GetChildProperties">Item.GetChildNameProperties</see> or
|
||||
/// <see cref="Mobile.GetChildProperties">Mobile.GetChildNameProperties</see>.
|
||||
/// </summary>
|
||||
public virtual void GetChildNameProperties(ObjectPropertyList list, Item item)
|
||||
{
|
||||
if (m_Parent is Item parentItem)
|
||||
parentItem.GetChildNameProperties(list, item);
|
||||
|
|
@ -1788,24 +1788,24 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridable. Method checked to see if this item may be equipped while casting a spell. By default, this returns false. It
|
||||
/// is overridden on spellbook and spell channeling weapons or shields.
|
||||
/// </summary>
|
||||
/// <returns>True if it may, false if not.</returns>
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// public override bool AllowEquippedCast( Mobile from )
|
||||
/// {
|
||||
/// if ( from.Int >= 100 )
|
||||
/// return true;
|
||||
///
|
||||
/// return base.AllowEquippedCast( from );
|
||||
/// }</code>
|
||||
/// When placed in an Item script, the item may be cast when equipped if the <paramref name="from" /> has 100 or more
|
||||
/// intelligence. Otherwise, it will drop to their backpack.
|
||||
/// </example>
|
||||
public virtual bool AllowEquippedCast(Mobile from) => false;
|
||||
/// <summary>
|
||||
/// Overridable. Method checked to see if this item may be equipped while casting a spell. By default, this returns false. It
|
||||
/// is overridden on spellbook and spell channeling weapons or shields.
|
||||
/// </summary>
|
||||
/// <returns>True if it may, false if not.</returns>
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// public override bool AllowEquippedCast( Mobile from )
|
||||
/// {
|
||||
/// if ( from.Int >= 100 )
|
||||
/// return true;
|
||||
///
|
||||
/// return base.AllowEquippedCast( from );
|
||||
/// }</code>
|
||||
/// When placed in an Item script, the item may be cast when equipped if the <paramref name="from" /> has 100 or more
|
||||
/// intelligence. Otherwise, it will drop to their backpack.
|
||||
/// </example>
|
||||
public virtual bool AllowEquippedCast(Mobile from) => false;
|
||||
|
||||
public virtual bool CheckConflictingLayer(Mobile m, Item item, Layer layer) => m_Layer == layer;
|
||||
|
||||
|
|
@ -2824,8 +2824,7 @@ namespace Server
|
|||
|
||||
if (m.CanSee(this) && m.InRange(worldLoc, GetUpdateRange(m)))
|
||||
{
|
||||
if (p == null)
|
||||
p = Packet.Acquire(new MessageLocalized(Serial, m_ItemID, type, hue, 3, number, Name, args));
|
||||
p ??= Packet.Acquire(new MessageLocalized(Serial, m_ItemID, type, hue, 3, number, Name, args));
|
||||
|
||||
state.Send(p);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -485,9 +485,6 @@ namespace Server.Items
|
|||
int extraItems = 0;
|
||||
int extraWeight = 0;
|
||||
|
||||
// from.SendMessage( String.Format( "There are {0} items in this container.", this.Items.Count ) );
|
||||
// from.SendMessage( String.Format( "There are {0} items being dropped into this container.", droppedItems.Length ) );
|
||||
|
||||
for (int i = 0; i < droppedItems.Length; i++)
|
||||
{
|
||||
Item dropped = droppedItems[i];
|
||||
|
|
@ -679,8 +676,7 @@ namespace Server.Items
|
|||
|
||||
if (!contains)
|
||||
{
|
||||
if (Openers == null)
|
||||
Openers = new List<Mobile>();
|
||||
Openers ??= new List<Mobile>();
|
||||
|
||||
Openers.Add(opener);
|
||||
}
|
||||
|
|
@ -692,7 +688,10 @@ namespace Server.Items
|
|||
|
||||
public virtual void SendContentTo(NetState state)
|
||||
{
|
||||
if (state?.ContainerGridLines == true)
|
||||
if (state == null)
|
||||
return;
|
||||
|
||||
if (state.ContainerGridLines)
|
||||
state.Send(new ContainerContent6017(state.Mobile, this));
|
||||
else
|
||||
state.Send(new ContainerContent(state.Mobile, this));
|
||||
|
|
@ -1646,8 +1645,7 @@ namespace Server.Items
|
|||
|
||||
ContainerData data = new ContainerData(gumpID, bounds, dropSound);
|
||||
|
||||
if (Default == null)
|
||||
Default = data;
|
||||
Default ??= data;
|
||||
|
||||
if (split.Length >= 4)
|
||||
{
|
||||
|
|
@ -1672,8 +1670,7 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
|
||||
if (Default == null)
|
||||
Default = new ContainerData(0x3C, new Rectangle2D(44, 65, 142, 94), 0x48);
|
||||
Default ??= new ContainerData(0x3C, new Rectangle2D(44, 65, 142, 94), 0x48);
|
||||
}
|
||||
|
||||
public ContainerData(int gumpID, Rectangle2D bounds, int dropSound)
|
||||
|
|
|
|||
|
|
@ -76,6 +76,9 @@ namespace Libuv.Internal
|
|||
nBuffers++;
|
||||
|
||||
var pBuffers = (LibuvFunctions.uv_buf_t*)_bufs;
|
||||
if (pBuffers == null)
|
||||
throw new NullReferenceException();
|
||||
|
||||
if (nBuffers > BUFFER_COUNT)
|
||||
{
|
||||
// create and pin buffer array when it's larger than the pre-allocated one
|
||||
|
|
@ -83,6 +86,8 @@ namespace Libuv.Internal
|
|||
var gcHandle = GCHandle.Alloc(bufArray, GCHandleType.Pinned);
|
||||
_pins.Add(gcHandle);
|
||||
pBuffers = (LibuvFunctions.uv_buf_t*)gcHandle.AddrOfPinnedObject();
|
||||
if (pBuffers == null)
|
||||
throw new NullReferenceException();
|
||||
}
|
||||
|
||||
if (nBuffers == 1)
|
||||
|
|
@ -149,12 +154,15 @@ namespace Libuv.Internal
|
|||
UvStreamHandle handle,
|
||||
ArraySegment<ArraySegment<byte>> bufs,
|
||||
UvStreamHandle sendHandle,
|
||||
Action<UvWriteReq, int, UvException, object> callback,
|
||||
object state)
|
||||
Action<UvWriteReq, int, UvException, object> callback, object state
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
var pBuffers = (LibuvFunctions.uv_buf_t*)_bufs;
|
||||
if (pBuffers == null)
|
||||
throw new NullReferenceException();
|
||||
|
||||
var nBuffers = bufs.Count;
|
||||
if (nBuffers > BUFFER_COUNT)
|
||||
{
|
||||
|
|
@ -163,12 +171,14 @@ namespace Libuv.Internal
|
|||
var gcHandle = GCHandle.Alloc(bufArray, GCHandleType.Pinned);
|
||||
_pins.Add(gcHandle);
|
||||
pBuffers = (LibuvFunctions.uv_buf_t*)gcHandle.AddrOfPinnedObject();
|
||||
if (pBuffers == null)
|
||||
throw new NullReferenceException();
|
||||
}
|
||||
|
||||
for (var index = 0; index < nBuffers; index++)
|
||||
{
|
||||
// create and pin each segment being written
|
||||
var buf = bufs.Array[bufs.Offset + index];
|
||||
var buf = bufs.Array?[bufs.Offset + index] ?? throw new Exception("buffs.Array is null");
|
||||
|
||||
var gcHandle = GCHandle.Alloc(buf.Array, GCHandleType.Pinned);
|
||||
_pins.Add(gcHandle);
|
||||
|
|
|
|||
|
|
@ -537,7 +537,7 @@ namespace Server
|
|||
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly) ==
|
||||
null)
|
||||
{
|
||||
if (warningSb == null) warningSb = new StringBuilder();
|
||||
warningSb ??= new StringBuilder();
|
||||
|
||||
warningSb.AppendLine(" - No Serialize() method");
|
||||
}
|
||||
|
|
@ -548,7 +548,7 @@ namespace Server
|
|||
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly) ==
|
||||
null)
|
||||
{
|
||||
if (warningSb == null) warningSb = new StringBuilder();
|
||||
warningSb ??= new StringBuilder();
|
||||
|
||||
warningSb.AppendLine(" - No Deserialize() method");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -456,8 +456,7 @@ namespace Server
|
|||
pool = _FixPool.Dequeue();
|
||||
}
|
||||
|
||||
if (pool == null)
|
||||
pool = new List<Item>(128); // Arbitrary limit
|
||||
pool ??= new List<Item>(128); // Arbitrary limit
|
||||
|
||||
IPooledEnumerable<Item> eable = map.GetItemsInRange(new Point3D(x, y, 0), 0);
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -23,8 +23,6 @@ using System;
|
|||
using System.Buffers;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using SignalR;
|
||||
|
||||
namespace Server.Network
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Connections;
|
||||
using Server.Accounting;
|
||||
using Server.Diagnostics;
|
||||
using Server.Gumps;
|
||||
using Server.HuePickers;
|
||||
using Server.Items;
|
||||
|
|
@ -302,8 +301,7 @@ namespace Server.Network
|
|||
|
||||
public void AddMenu(IMenu menu)
|
||||
{
|
||||
if (Menus == null)
|
||||
Menus = new List<IMenu>();
|
||||
Menus ??= new List<IMenu>();
|
||||
|
||||
if (Menus.Count < MenuCap)
|
||||
Menus.Add(menu);
|
||||
|
|
@ -331,8 +329,7 @@ namespace Server.Network
|
|||
|
||||
public void AddHuePicker(HuePicker huePicker)
|
||||
{
|
||||
if (HuePickers == null)
|
||||
HuePickers = new List<HuePicker>();
|
||||
HuePickers ??= new List<HuePicker>();
|
||||
|
||||
if (HuePickers.Count < HuePickerCap)
|
||||
HuePickers.Add(huePicker);
|
||||
|
|
@ -360,8 +357,7 @@ namespace Server.Network
|
|||
|
||||
public void AddGump(Gump gump)
|
||||
{
|
||||
if (Gumps == null)
|
||||
Gumps = new List<Gump>();
|
||||
Gumps ??= new List<Gump>();
|
||||
|
||||
if (Gumps.Count < GumpCap)
|
||||
Gumps.Add(gump);
|
||||
|
|
@ -435,7 +431,9 @@ namespace Server.Network
|
|||
ConnectedOn = DateTime.UtcNow;
|
||||
Console.WriteLine("Client: {0}: Connected. [{1} Online]", this, Instances.Count);
|
||||
|
||||
_ = ProcessRecvs(pump);
|
||||
#pragma warning disable 4014
|
||||
ProcessRecvs(pump);
|
||||
#pragma warning restore 4014
|
||||
|
||||
CreatedCallback?.Invoke(this);
|
||||
}
|
||||
|
|
@ -566,9 +564,7 @@ namespace Server.Network
|
|||
|
||||
private int m_Disposing;
|
||||
|
||||
public bool IsDisposing { get => m_Disposing != 0;
|
||||
private set => m_Disposing = value ? 1 : 0;
|
||||
}
|
||||
public bool IsDisposing => m_Disposing != 0;
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2092,8 +2092,7 @@ namespace Server.Network
|
|||
race = Race.Races[(byte)(genderRace / 2)];
|
||||
}
|
||||
|
||||
if (race == null)
|
||||
race = Race.DefaultRace;
|
||||
race ??= Race.DefaultRace;
|
||||
|
||||
CityInfo[] info = state.CityInfo;
|
||||
IAccount a = state.Account;
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ namespace Server.Network
|
|||
public DisplaySecureTrade(Mobile them, Container first, Container second, string name)
|
||||
: base(0x6F)
|
||||
{
|
||||
if (name == null) name = "";
|
||||
name ??= "";
|
||||
|
||||
EnsureCapacity(18 + name.Length);
|
||||
|
||||
|
|
@ -405,13 +405,9 @@ namespace Server.Network
|
|||
m_Stream.Write((ushort)state.Item.Amount);
|
||||
m_Stream.Write((ushort)state.Price);
|
||||
|
||||
string name = state.Item.Name;
|
||||
|
||||
if (name == null || (name = name.Trim()).Length <= 0)
|
||||
name = state.Name;
|
||||
|
||||
if (name == null)
|
||||
name = "";
|
||||
string name = state.Item.Name?.Trim();
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = state.Name ?? "";
|
||||
|
||||
m_Stream.Write((ushort)name.Length);
|
||||
m_Stream.WriteAsciiFixed(name, (ushort)name.Length);
|
||||
|
|
@ -979,14 +975,9 @@ namespace Server.Network
|
|||
{
|
||||
public DisplayProfile(bool realSerial, Mobile m, string header, string body, string footer) : base(0xB8)
|
||||
{
|
||||
if (header == null)
|
||||
header = "";
|
||||
|
||||
if (body == null)
|
||||
body = "";
|
||||
|
||||
if (footer == null)
|
||||
footer = "";
|
||||
header ??= "";
|
||||
body ??= "";
|
||||
footer ??= "";
|
||||
|
||||
EnsureCapacity(12 + header.Length + footer.Length * 2 + body.Length * 2);
|
||||
|
||||
|
|
@ -2104,7 +2095,7 @@ namespace Server.Network
|
|||
{
|
||||
public LaunchBrowser(string url) : base(0xA5)
|
||||
{
|
||||
if (url == null) url = "";
|
||||
url ??= "";
|
||||
|
||||
EnsureCapacity(4 + url.Length);
|
||||
|
||||
|
|
@ -2121,8 +2112,8 @@ namespace Server.Network
|
|||
public MessageLocalized(Serial serial, int graphic, MessageType type, int hue, int font, int number, string name,
|
||||
string args) : base(0xC1)
|
||||
{
|
||||
if (name == null) name = "";
|
||||
if (args == null) args = "";
|
||||
name ??= "";
|
||||
args ??= "";
|
||||
|
||||
if (hue == 0)
|
||||
hue = 0x3B2;
|
||||
|
|
@ -2570,7 +2561,7 @@ namespace Server.Network
|
|||
{
|
||||
public DisplayGump(Gump g, string layout, string[] text) : base(0xB0)
|
||||
{
|
||||
if (layout == null) layout = "";
|
||||
layout ??= "";
|
||||
|
||||
EnsureCapacity(256);
|
||||
|
||||
|
|
@ -2673,7 +2664,7 @@ namespace Server.Network
|
|||
{
|
||||
public ScrollMessage(int type, int tip, string text) : base(0xA6)
|
||||
{
|
||||
if (text == null) text = "";
|
||||
text ??= "";
|
||||
|
||||
EnsureCapacity(10 + text.Length);
|
||||
|
||||
|
|
@ -2755,12 +2746,12 @@ namespace Server.Network
|
|||
|
||||
flags |= Value;
|
||||
|
||||
if (ns.Account is IAccount acct && acct.Limit >= 6)
|
||||
if (ns.Account.Limit >= 6)
|
||||
{
|
||||
flags |= FeatureFlags.LiveAccount;
|
||||
flags &= ~FeatureFlags.UOTD;
|
||||
|
||||
if (acct.Limit > 6)
|
||||
if (ns.Account.Limit > 6)
|
||||
flags |= FeatureFlags.SeventhCharacterSlot;
|
||||
else
|
||||
flags |= FeatureFlags.SixthCharacterSlot;
|
||||
|
|
@ -3618,11 +3609,8 @@ namespace Server.Network
|
|||
public AsciiMessage(Serial serial, int graphic, MessageType type, int hue, int font, string name, string text) :
|
||||
base(0x1C)
|
||||
{
|
||||
if (name == null)
|
||||
name = "";
|
||||
|
||||
if (text == null)
|
||||
text = "";
|
||||
name ??= "";
|
||||
text ??= "";
|
||||
|
||||
if (hue == 0)
|
||||
hue = 0x3B2;
|
||||
|
|
@ -3645,8 +3633,8 @@ namespace Server.Network
|
|||
string text) : base(0xAE)
|
||||
{
|
||||
if (string.IsNullOrEmpty(lang)) lang = "ENU";
|
||||
if (name == null) name = "";
|
||||
if (text == null) text = "";
|
||||
name ??= "";
|
||||
text ??= "";
|
||||
|
||||
if (hue == 0)
|
||||
hue = 0x3B2;
|
||||
|
|
@ -4051,9 +4039,9 @@ namespace Server.Network
|
|||
public MessageLocalizedAffix(Serial serial, int graphic, MessageType messageType, int hue, int font, int number,
|
||||
string name, AffixType affixType, string affix, string args) : base(0xCC)
|
||||
{
|
||||
if (name == null) name = "";
|
||||
if (affix == null) affix = "";
|
||||
if (args == null) args = "";
|
||||
name ??= "";
|
||||
affix ??= "";
|
||||
args ??= "";
|
||||
|
||||
if (hue == 0)
|
||||
hue = 0x3B2;
|
||||
|
|
@ -4128,8 +4116,8 @@ namespace Server.Network
|
|||
{
|
||||
public DisplaySignGump(Serial serial, int gumpID, string unknown, string caption) : base(0x8B)
|
||||
{
|
||||
if (unknown == null) unknown = "";
|
||||
if (caption == null) caption = "";
|
||||
unknown ??= "";
|
||||
caption ??= "";
|
||||
|
||||
EnsureCapacity(16 + unknown.Length + caption.Length);
|
||||
|
||||
|
|
|
|||
|
|
@ -106,8 +106,7 @@ namespace Server
|
|||
if (number == 0)
|
||||
return;
|
||||
|
||||
if (arguments == null)
|
||||
arguments = "";
|
||||
arguments ??= "";
|
||||
|
||||
if (Header == 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace Server
|
|||
|
||||
dataFile.Write(buffer, 0, length);
|
||||
|
||||
if (indexBuffer == null) indexBuffer = new byte[20];
|
||||
indexBuffer ??= new byte[20];
|
||||
|
||||
indexBuffer[0] = (byte)typeCode;
|
||||
indexBuffer[1] = (byte)(typeCode >> 8);
|
||||
|
|
@ -77,4 +77,4 @@ namespace Server
|
|||
return length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,8 +167,7 @@ namespace Server
|
|||
|
||||
while (size > 0)
|
||||
{
|
||||
if (buffered.buffer == null)
|
||||
buffered.buffer = ArrayPool<byte>.Shared.Rent(bufferSize);
|
||||
buffered.buffer ??= ArrayPool<byte>.Shared.Rent(bufferSize);
|
||||
|
||||
byte[] page = buffered.buffer; // buffer page
|
||||
int pageSpace = page.Length - buffered.length; // available bytes in page
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ namespace Server
|
|||
}
|
||||
else
|
||||
{
|
||||
if (writeCallback == null) writeCallback = OnWrite;
|
||||
writeCallback ??= OnWrite;
|
||||
|
||||
fileStream.BeginWrite(chunk.Buffer, chunk.Offset, chunk.Size, writeCallback, chunk);
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ namespace Server
|
|||
|
||||
fileStream.EndWrite(asyncResult);
|
||||
|
||||
chunk.Commit();
|
||||
chunk?.Commit();
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int size)
|
||||
|
|
@ -117,4 +117,4 @@ namespace Server
|
|||
fileStream.SetLength(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ namespace Server
|
|||
idx.Write(m.m_TypeRef);
|
||||
idx.Write(m.Serial);
|
||||
idx.Write(start);
|
||||
idx.Write((int)(m.SaveBuffer.Position));
|
||||
idx.Write((int)m.SaveBuffer.Position);
|
||||
|
||||
m.SaveBuffer.WriteTo(bin);
|
||||
m.FreeCache();
|
||||
|
|
@ -201,7 +201,7 @@ namespace Server
|
|||
idx.Write(0); //guilds have no typeid
|
||||
idx.Write(guild.Id);
|
||||
idx.Write(start);
|
||||
idx.Write((int)(guild.SaveBuffer.Position));
|
||||
idx.Write((int)guild.SaveBuffer.Position);
|
||||
|
||||
guild.SaveBuffer.WriteTo(bin);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ namespace Server
|
|||
|
||||
private void Add<T>(ref List<T> list, T value)
|
||||
{
|
||||
if (list == null) list = new List<T>();
|
||||
list ??= new List<T>();
|
||||
|
||||
list.Add(value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,259 +1,275 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Server.Guilds;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public sealed class BinaryFileReader : IGenericReader
|
||||
{
|
||||
private BinaryReader m_File;
|
||||
|
||||
public BinaryFileReader(BinaryReader br) => m_File = br;
|
||||
|
||||
public long Position => m_File.BaseStream.Position;
|
||||
|
||||
public void Close()
|
||||
{
|
||||
m_File.Close();
|
||||
}
|
||||
|
||||
public long Seek(long offset, SeekOrigin origin) => m_File.BaseStream.Seek(offset, origin);
|
||||
|
||||
public string ReadString() => ReadByte() != 0 ? m_File.ReadString() : null;
|
||||
|
||||
public DateTime ReadDeltaTime()
|
||||
{
|
||||
long ticks = m_File.ReadInt64();
|
||||
long now = DateTime.UtcNow.Ticks;
|
||||
|
||||
if (ticks > 0 && ticks + now < 0)
|
||||
return DateTime.MaxValue;
|
||||
if (ticks < 0 && ticks + now < 0)
|
||||
return DateTime.MinValue;
|
||||
|
||||
try
|
||||
{
|
||||
return new DateTime(now + ticks);
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (ticks > 0) return DateTime.MaxValue;
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
|
||||
public IPAddress ReadIPAddress() => new IPAddress(m_File.ReadInt64());
|
||||
|
||||
public int ReadEncodedInt()
|
||||
{
|
||||
int v = 0, shift = 0;
|
||||
byte b;
|
||||
|
||||
do
|
||||
{
|
||||
b = m_File.ReadByte();
|
||||
v |= (b & 0x7F) << shift;
|
||||
shift += 7;
|
||||
} while (b >= 0x80);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public DateTime ReadDateTime() => new DateTime(m_File.ReadInt64());
|
||||
|
||||
public DateTimeOffset ReadDateTimeOffset()
|
||||
{
|
||||
long ticks = m_File.ReadInt64();
|
||||
TimeSpan offset = new TimeSpan(m_File.ReadInt64());
|
||||
|
||||
return new DateTimeOffset(ticks, offset);
|
||||
}
|
||||
|
||||
public TimeSpan ReadTimeSpan() => new TimeSpan(m_File.ReadInt64());
|
||||
|
||||
public decimal ReadDecimal() => m_File.ReadDecimal();
|
||||
|
||||
public long ReadLong() => m_File.ReadInt64();
|
||||
|
||||
public ulong ReadULong() => m_File.ReadUInt64();
|
||||
|
||||
public int ReadInt() => m_File.ReadInt32();
|
||||
|
||||
public uint ReadUInt() => m_File.ReadUInt32();
|
||||
|
||||
public short ReadShort() => m_File.ReadInt16();
|
||||
|
||||
public ushort ReadUShort() => m_File.ReadUInt16();
|
||||
|
||||
public double ReadDouble() => m_File.ReadDouble();
|
||||
|
||||
public float ReadFloat() => m_File.ReadSingle();
|
||||
|
||||
public char ReadChar() => m_File.ReadChar();
|
||||
|
||||
public byte ReadByte() => m_File.ReadByte();
|
||||
|
||||
public sbyte ReadSByte() => m_File.ReadSByte();
|
||||
|
||||
public bool ReadBool() => m_File.ReadBoolean();
|
||||
|
||||
public Point3D ReadPoint3D() => new Point3D(ReadInt(), ReadInt(), ReadInt());
|
||||
|
||||
public Point2D ReadPoint2D() => new Point2D(ReadInt(), ReadInt());
|
||||
|
||||
public Rectangle2D ReadRect2D() => new Rectangle2D(ReadPoint2D(), ReadPoint2D());
|
||||
|
||||
public Rectangle3D ReadRect3D() => new Rectangle3D(ReadPoint3D(), ReadPoint3D());
|
||||
|
||||
public Map ReadMap() => Map.Maps[ReadByte()];
|
||||
|
||||
public IEntity ReadEntity()
|
||||
{
|
||||
Serial serial = ReadUInt();
|
||||
IEntity entity = World.FindEntity(serial);
|
||||
if (entity == null)
|
||||
return new Entity(serial, new Point3D(0, 0, 0), Map.Internal);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public Item ReadItem() => World.FindItem(ReadUInt());
|
||||
|
||||
public Mobile ReadMobile() => World.FindMobile(ReadUInt());
|
||||
|
||||
public BaseGuild ReadGuild() => BaseGuild.Find(ReadUInt());
|
||||
|
||||
public T ReadItem<T>() where T : Item => ReadItem() as T;
|
||||
|
||||
public T ReadMobile<T>() where T : Mobile => ReadMobile() as T;
|
||||
|
||||
public T ReadGuild<T>() where T : BaseGuild => ReadGuild() as T;
|
||||
|
||||
public List<Item> ReadStrongItemList() => ReadStrongItemList<Item>();
|
||||
|
||||
public List<T> ReadStrongItemList<T>() where T : Item
|
||||
{
|
||||
int count = ReadInt();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
List<T> list = new List<T>(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (ReadItem() is T item)
|
||||
list.Add(item);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
return new List<T>();
|
||||
}
|
||||
|
||||
public HashSet<Item> ReadItemSet() => ReadItemSet<Item>();
|
||||
|
||||
public HashSet<T> ReadItemSet<T>() where T : Item
|
||||
{
|
||||
int count = ReadInt();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
HashSet<T> set = new HashSet<T>();
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (ReadItem() is T item)
|
||||
set.Add(item);
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
return new HashSet<T>();
|
||||
}
|
||||
|
||||
public List<Mobile> ReadStrongMobileList() => ReadStrongMobileList<Mobile>();
|
||||
|
||||
public List<T> ReadStrongMobileList<T>() where T : Mobile
|
||||
{
|
||||
int count = ReadInt();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
List<T> list = new List<T>(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (ReadMobile() is T m)
|
||||
list.Add(m);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
return new List<T>();
|
||||
}
|
||||
|
||||
public HashSet<Mobile> ReadMobileSet() => ReadMobileSet<Mobile>();
|
||||
|
||||
public HashSet<T> ReadMobileSet<T>() where T : Mobile
|
||||
{
|
||||
int count = ReadInt();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
HashSet<T> set = new HashSet<T>();
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (ReadMobile() is T item)
|
||||
set.Add(item);
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
return new HashSet<T>();
|
||||
}
|
||||
|
||||
public List<BaseGuild> ReadStrongGuildList() => ReadStrongGuildList<BaseGuild>();
|
||||
|
||||
public List<T> ReadStrongGuildList<T>() where T : BaseGuild
|
||||
{
|
||||
int count = ReadInt();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
List<T> list = new List<T>(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (ReadGuild() is T g)
|
||||
list.Add(g);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
return new List<T>();
|
||||
}
|
||||
|
||||
public HashSet<BaseGuild> ReadGuildSet() => ReadGuildSet<BaseGuild>();
|
||||
|
||||
public HashSet<T> ReadGuildSet<T>() where T : BaseGuild
|
||||
{
|
||||
int count = ReadInt();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
HashSet<T> set = new HashSet<T>();
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (ReadGuild() is T item)
|
||||
set.Add(item);
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
return new HashSet<T>();
|
||||
}
|
||||
|
||||
public Race ReadRace() => Race.Races[ReadByte()];
|
||||
|
||||
public bool End() => m_File.PeekChar() == -1;
|
||||
}
|
||||
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: BinaryFileReader.cs *
|
||||
* Created: 2019/12/30 - Updated: 2020/01/18 *
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* 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.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using Server.Guilds;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public sealed class BinaryFileReader : IGenericReader
|
||||
{
|
||||
private BinaryReader m_File;
|
||||
|
||||
public BinaryFileReader(BinaryReader br) => m_File = br;
|
||||
|
||||
public long Position => m_File.BaseStream.Position;
|
||||
|
||||
public void Close()
|
||||
{
|
||||
m_File.Close();
|
||||
}
|
||||
|
||||
public long Seek(long offset, SeekOrigin origin) => m_File.BaseStream.Seek(offset, origin);
|
||||
|
||||
public string ReadString() => ReadByte() != 0 ? m_File.ReadString() : null;
|
||||
|
||||
public DateTime ReadDeltaTime()
|
||||
{
|
||||
long ticks = m_File.ReadInt64();
|
||||
long now = DateTime.UtcNow.Ticks;
|
||||
|
||||
if (ticks > 0 && ticks + now < 0)
|
||||
return DateTime.MaxValue;
|
||||
if (ticks < 0 && ticks + now < 0)
|
||||
return DateTime.MinValue;
|
||||
|
||||
try
|
||||
{
|
||||
return new DateTime(now + ticks);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return ticks > 0 ? DateTime.MaxValue : DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
|
||||
public IPAddress ReadIPAddress() => new IPAddress(m_File.ReadInt64());
|
||||
|
||||
public int ReadEncodedInt()
|
||||
{
|
||||
int v = 0, shift = 0;
|
||||
byte b;
|
||||
|
||||
do
|
||||
{
|
||||
b = m_File.ReadByte();
|
||||
v |= (b & 0x7F) << shift;
|
||||
shift += 7;
|
||||
} while (b >= 0x80);
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public DateTime ReadDateTime() => new DateTime(m_File.ReadInt64());
|
||||
|
||||
public DateTimeOffset ReadDateTimeOffset()
|
||||
{
|
||||
long ticks = m_File.ReadInt64();
|
||||
TimeSpan offset = new TimeSpan(m_File.ReadInt64());
|
||||
|
||||
return new DateTimeOffset(ticks, offset);
|
||||
}
|
||||
|
||||
public TimeSpan ReadTimeSpan() => new TimeSpan(m_File.ReadInt64());
|
||||
|
||||
public decimal ReadDecimal() => m_File.ReadDecimal();
|
||||
|
||||
public long ReadLong() => m_File.ReadInt64();
|
||||
|
||||
public ulong ReadULong() => m_File.ReadUInt64();
|
||||
|
||||
public int ReadInt() => m_File.ReadInt32();
|
||||
|
||||
public uint ReadUInt() => m_File.ReadUInt32();
|
||||
|
||||
public short ReadShort() => m_File.ReadInt16();
|
||||
|
||||
public ushort ReadUShort() => m_File.ReadUInt16();
|
||||
|
||||
public double ReadDouble() => m_File.ReadDouble();
|
||||
|
||||
public float ReadFloat() => m_File.ReadSingle();
|
||||
|
||||
public char ReadChar() => m_File.ReadChar();
|
||||
|
||||
public byte ReadByte() => m_File.ReadByte();
|
||||
|
||||
public sbyte ReadSByte() => m_File.ReadSByte();
|
||||
|
||||
public bool ReadBool() => m_File.ReadBoolean();
|
||||
|
||||
public Point3D ReadPoint3D() => new Point3D(ReadInt(), ReadInt(), ReadInt());
|
||||
|
||||
public Point2D ReadPoint2D() => new Point2D(ReadInt(), ReadInt());
|
||||
|
||||
public Rectangle2D ReadRect2D() => new Rectangle2D(ReadPoint2D(), ReadPoint2D());
|
||||
|
||||
public Rectangle3D ReadRect3D() => new Rectangle3D(ReadPoint3D(), ReadPoint3D());
|
||||
|
||||
public Map ReadMap() => Map.Maps[ReadByte()];
|
||||
|
||||
public IEntity ReadEntity()
|
||||
{
|
||||
Serial serial = ReadUInt();
|
||||
return World.FindEntity(serial) ?? new Entity(serial, new Point3D(0, 0, 0), Map.Internal);
|
||||
}
|
||||
|
||||
public Item ReadItem() => World.FindItem(ReadUInt());
|
||||
|
||||
public Mobile ReadMobile() => World.FindMobile(ReadUInt());
|
||||
|
||||
public BaseGuild ReadGuild() => BaseGuild.Find(ReadUInt());
|
||||
|
||||
public T ReadItem<T>() where T : Item => ReadItem() as T;
|
||||
|
||||
public T ReadMobile<T>() where T : Mobile => ReadMobile() as T;
|
||||
|
||||
public T ReadGuild<T>() where T : BaseGuild => ReadGuild() as T;
|
||||
|
||||
public List<Item> ReadStrongItemList() => ReadStrongItemList<Item>();
|
||||
|
||||
public List<T> ReadStrongItemList<T>() where T : Item
|
||||
{
|
||||
int count = ReadInt();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
List<T> list = new List<T>(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (ReadItem() is T item)
|
||||
list.Add(item);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
return new List<T>();
|
||||
}
|
||||
|
||||
public HashSet<Item> ReadItemSet() => ReadItemSet<Item>();
|
||||
|
||||
public HashSet<T> ReadItemSet<T>() where T : Item
|
||||
{
|
||||
int count = ReadInt();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
HashSet<T> set = new HashSet<T>();
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (ReadItem() is T item)
|
||||
set.Add(item);
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
return new HashSet<T>();
|
||||
}
|
||||
|
||||
public List<Mobile> ReadStrongMobileList() => ReadStrongMobileList<Mobile>();
|
||||
|
||||
public List<T> ReadStrongMobileList<T>() where T : Mobile
|
||||
{
|
||||
int count = ReadInt();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
List<T> list = new List<T>(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (ReadMobile() is T m)
|
||||
list.Add(m);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
return new List<T>();
|
||||
}
|
||||
|
||||
public HashSet<Mobile> ReadMobileSet() => ReadMobileSet<Mobile>();
|
||||
|
||||
public HashSet<T> ReadMobileSet<T>() where T : Mobile
|
||||
{
|
||||
int count = ReadInt();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
HashSet<T> set = new HashSet<T>();
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (ReadMobile() is T item)
|
||||
set.Add(item);
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
return new HashSet<T>();
|
||||
}
|
||||
|
||||
public List<BaseGuild> ReadStrongGuildList() => ReadStrongGuildList<BaseGuild>();
|
||||
|
||||
public List<T> ReadStrongGuildList<T>() where T : BaseGuild
|
||||
{
|
||||
int count = ReadInt();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
List<T> list = new List<T>(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (ReadGuild() is T g)
|
||||
list.Add(g);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
return new List<T>();
|
||||
}
|
||||
|
||||
public HashSet<BaseGuild> ReadGuildSet() => ReadGuildSet<BaseGuild>();
|
||||
|
||||
public HashSet<T> ReadGuildSet<T>() where T : BaseGuild
|
||||
{
|
||||
int count = ReadInt();
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
HashSet<T> set = new HashSet<T>();
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (ReadGuild() is T item)
|
||||
set.Add(item);
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
return new HashSet<T>();
|
||||
}
|
||||
|
||||
public Race ReadRace() => Race.Races[ReadByte()];
|
||||
|
||||
public bool End() => m_File.PeekChar() == -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,57 +1,78 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using Server.Guilds;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public interface IGenericReader
|
||||
{
|
||||
string ReadString();
|
||||
DateTime ReadDateTime();
|
||||
DateTimeOffset ReadDateTimeOffset();
|
||||
TimeSpan ReadTimeSpan();
|
||||
DateTime ReadDeltaTime();
|
||||
decimal ReadDecimal();
|
||||
long ReadLong();
|
||||
ulong ReadULong();
|
||||
int ReadInt();
|
||||
uint ReadUInt();
|
||||
short ReadShort();
|
||||
ushort ReadUShort();
|
||||
double ReadDouble();
|
||||
float ReadFloat();
|
||||
char ReadChar();
|
||||
byte ReadByte();
|
||||
sbyte ReadSByte();
|
||||
bool ReadBool();
|
||||
int ReadEncodedInt();
|
||||
IPAddress ReadIPAddress();
|
||||
Point3D ReadPoint3D();
|
||||
Point2D ReadPoint2D();
|
||||
Rectangle2D ReadRect2D();
|
||||
Rectangle3D ReadRect3D();
|
||||
Map ReadMap();
|
||||
IEntity ReadEntity();
|
||||
Item ReadItem();
|
||||
Mobile ReadMobile();
|
||||
BaseGuild ReadGuild();
|
||||
T ReadItem<T>() where T : Item;
|
||||
T ReadMobile<T>() where T : Mobile;
|
||||
T ReadGuild<T>() where T : BaseGuild;
|
||||
List<Item> ReadStrongItemList();
|
||||
List<T> ReadStrongItemList<T>() where T : Item;
|
||||
List<Mobile> ReadStrongMobileList();
|
||||
List<T> ReadStrongMobileList<T>() where T : Mobile;
|
||||
List<BaseGuild> ReadStrongGuildList();
|
||||
List<T> ReadStrongGuildList<T>() where T : BaseGuild;
|
||||
HashSet<Item> ReadItemSet();
|
||||
HashSet<T> ReadItemSet<T>() where T : Item;
|
||||
HashSet<Mobile> ReadMobileSet();
|
||||
HashSet<T> ReadMobileSet<T>() where T : Mobile;
|
||||
HashSet<BaseGuild> ReadGuildSet();
|
||||
HashSet<T> ReadGuildSet<T>() where T : BaseGuild;
|
||||
Race ReadRace();
|
||||
bool End();
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: IGenericReader.cs *
|
||||
* Created: 2019/12/30 - Updated: 2020/01/18 *
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* 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.Collections.Generic;
|
||||
using System.Net;
|
||||
using Server.Guilds;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public interface IGenericReader
|
||||
{
|
||||
string ReadString();
|
||||
DateTime ReadDateTime();
|
||||
DateTimeOffset ReadDateTimeOffset();
|
||||
TimeSpan ReadTimeSpan();
|
||||
DateTime ReadDeltaTime();
|
||||
decimal ReadDecimal();
|
||||
long ReadLong();
|
||||
ulong ReadULong();
|
||||
int ReadInt();
|
||||
uint ReadUInt();
|
||||
short ReadShort();
|
||||
ushort ReadUShort();
|
||||
double ReadDouble();
|
||||
float ReadFloat();
|
||||
char ReadChar();
|
||||
byte ReadByte();
|
||||
sbyte ReadSByte();
|
||||
bool ReadBool();
|
||||
int ReadEncodedInt();
|
||||
IPAddress ReadIPAddress();
|
||||
Point3D ReadPoint3D();
|
||||
Point2D ReadPoint2D();
|
||||
Rectangle2D ReadRect2D();
|
||||
Rectangle3D ReadRect3D();
|
||||
Map ReadMap();
|
||||
IEntity ReadEntity();
|
||||
Item ReadItem();
|
||||
Mobile ReadMobile();
|
||||
BaseGuild ReadGuild();
|
||||
T ReadItem<T>() where T : Item;
|
||||
T ReadMobile<T>() where T : Mobile;
|
||||
T ReadGuild<T>() where T : BaseGuild;
|
||||
List<Item> ReadStrongItemList();
|
||||
List<T> ReadStrongItemList<T>() where T : Item;
|
||||
List<Mobile> ReadStrongMobileList();
|
||||
List<T> ReadStrongMobileList<T>() where T : Mobile;
|
||||
List<BaseGuild> ReadStrongGuildList();
|
||||
List<T> ReadStrongGuildList<T>() where T : BaseGuild;
|
||||
HashSet<Item> ReadItemSet();
|
||||
HashSet<T> ReadItemSet<T>() where T : Item;
|
||||
HashSet<Mobile> ReadMobileSet();
|
||||
HashSet<T> ReadMobileSet<T>() where T : Mobile;
|
||||
HashSet<BaseGuild> ReadGuildSet();
|
||||
HashSet<T> ReadGuildSet<T>() where T : BaseGuild;
|
||||
Race ReadRace();
|
||||
bool End();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,91 +1,112 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using Server.Guilds;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public interface IGenericWriter
|
||||
{
|
||||
long Position { get; }
|
||||
|
||||
void Close();
|
||||
|
||||
void Write(string value);
|
||||
void Write(DateTime value);
|
||||
void Write(DateTimeOffset value);
|
||||
void Write(TimeSpan value);
|
||||
void Write(decimal value);
|
||||
void Write(long value);
|
||||
void Write(ulong value);
|
||||
void Write(int value);
|
||||
void Write(uint value);
|
||||
void Write(short value);
|
||||
void Write(ushort value);
|
||||
void Write(double value);
|
||||
void Write(float value);
|
||||
void Write(char value);
|
||||
void Write(byte value);
|
||||
void Write(byte[] value);
|
||||
void Write(byte[] value, int length);
|
||||
void Write(sbyte value);
|
||||
void Write(bool value);
|
||||
void WriteEncodedInt(int value);
|
||||
void Write(IPAddress value);
|
||||
|
||||
void WriteDeltaTime(DateTime value);
|
||||
|
||||
void Write(Point3D value);
|
||||
void Write(Point2D value);
|
||||
void Write(Rectangle2D value);
|
||||
void Write(Rectangle3D value);
|
||||
void Write(Map value);
|
||||
|
||||
void WriteEntity(IEntity value);
|
||||
void Write(Item value);
|
||||
void Write(Mobile value);
|
||||
void Write(BaseGuild value);
|
||||
|
||||
void WriteItem<T>(T value) where T : Item;
|
||||
void WriteMobile<T>(T value) where T : Mobile;
|
||||
void WriteGuild<T>(T value) where T : BaseGuild;
|
||||
|
||||
void Write(Race value);
|
||||
|
||||
void Write(List<Item> list);
|
||||
void Write(List<Item> list, bool tidy);
|
||||
|
||||
void WriteItemList<T>(List<T> list) where T : Item;
|
||||
void WriteItemList<T>(List<T> list, bool tidy) where T : Item;
|
||||
|
||||
void Write(HashSet<Item> list);
|
||||
void Write(HashSet<Item> list, bool tidy);
|
||||
|
||||
void WriteItemSet<T>(HashSet<T> set) where T : Item;
|
||||
void WriteItemSet<T>(HashSet<T> set, bool tidy) where T : Item;
|
||||
|
||||
void Write(List<Mobile> list);
|
||||
void Write(List<Mobile> list, bool tidy);
|
||||
|
||||
void WriteMobileList<T>(List<T> list) where T : Mobile;
|
||||
void WriteMobileList<T>(List<T> list, bool tidy) where T : Mobile;
|
||||
|
||||
void Write(HashSet<Mobile> list);
|
||||
void Write(HashSet<Mobile> list, bool tidy);
|
||||
|
||||
void WriteMobileSet<T>(HashSet<T> set) where T : Mobile;
|
||||
void WriteMobileSet<T>(HashSet<T> set, bool tidy) where T : Mobile;
|
||||
|
||||
void Write(List<BaseGuild> list);
|
||||
void Write(List<BaseGuild> list, bool tidy);
|
||||
|
||||
void WriteGuildList<T>(List<T> list) where T : BaseGuild;
|
||||
void WriteGuildList<T>(List<T> list, bool tidy) where T : BaseGuild;
|
||||
|
||||
void Write(HashSet<BaseGuild> list);
|
||||
void Write(HashSet<BaseGuild> list, bool tidy);
|
||||
|
||||
void WriteGuildSet<T>(HashSet<T> set) where T : BaseGuild;
|
||||
void WriteGuildSet<T>(HashSet<T> set, bool tidy) where T : BaseGuild;
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: IGenericWriter.cs *
|
||||
* Created: 2019/12/30 - Updated: 2020/01/18 *
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* 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.Collections.Generic;
|
||||
using System.Net;
|
||||
using Server.Guilds;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public interface IGenericWriter
|
||||
{
|
||||
long Position { get; }
|
||||
|
||||
void Close();
|
||||
|
||||
void Write(string value);
|
||||
void Write(DateTime value);
|
||||
void Write(DateTimeOffset value);
|
||||
void Write(TimeSpan value);
|
||||
void Write(decimal value);
|
||||
void Write(long value);
|
||||
void Write(ulong value);
|
||||
void Write(int value);
|
||||
void Write(uint value);
|
||||
void Write(short value);
|
||||
void Write(ushort value);
|
||||
void Write(double value);
|
||||
void Write(float value);
|
||||
void Write(char value);
|
||||
void Write(byte value);
|
||||
void Write(byte[] value);
|
||||
void Write(byte[] value, int length);
|
||||
void Write(sbyte value);
|
||||
void Write(bool value);
|
||||
void WriteEncodedInt(int value);
|
||||
void Write(IPAddress value);
|
||||
|
||||
void WriteDeltaTime(DateTime value);
|
||||
|
||||
void Write(Point3D value);
|
||||
void Write(Point2D value);
|
||||
void Write(Rectangle2D value);
|
||||
void Write(Rectangle3D value);
|
||||
void Write(Map value);
|
||||
|
||||
void WriteEntity(IEntity value);
|
||||
void Write(Item value);
|
||||
void Write(Mobile value);
|
||||
void Write(BaseGuild value);
|
||||
|
||||
void WriteItem<T>(T value) where T : Item;
|
||||
void WriteMobile<T>(T value) where T : Mobile;
|
||||
void WriteGuild<T>(T value) where T : BaseGuild;
|
||||
|
||||
void Write(Race value);
|
||||
|
||||
void Write(List<Item> list);
|
||||
void Write(List<Item> list, bool tidy);
|
||||
|
||||
void WriteItemList<T>(List<T> list) where T : Item;
|
||||
void WriteItemList<T>(List<T> list, bool tidy) where T : Item;
|
||||
|
||||
void Write(HashSet<Item> list);
|
||||
void Write(HashSet<Item> list, bool tidy);
|
||||
|
||||
void WriteItemSet<T>(HashSet<T> set) where T : Item;
|
||||
void WriteItemSet<T>(HashSet<T> set, bool tidy) where T : Item;
|
||||
|
||||
void Write(List<Mobile> list);
|
||||
void Write(List<Mobile> list, bool tidy);
|
||||
|
||||
void WriteMobileList<T>(List<T> list) where T : Mobile;
|
||||
void WriteMobileList<T>(List<T> list, bool tidy) where T : Mobile;
|
||||
|
||||
void Write(HashSet<Mobile> list);
|
||||
void Write(HashSet<Mobile> list, bool tidy);
|
||||
|
||||
void WriteMobileSet<T>(HashSet<T> set) where T : Mobile;
|
||||
void WriteMobileSet<T>(HashSet<T> set, bool tidy) where T : Mobile;
|
||||
|
||||
void Write(List<BaseGuild> list);
|
||||
void Write(List<BaseGuild> list, bool tidy);
|
||||
|
||||
void WriteGuildList<T>(List<T> list) where T : BaseGuild;
|
||||
void WriteGuildList<T>(List<T> list, bool tidy) where T : BaseGuild;
|
||||
|
||||
void Write(HashSet<BaseGuild> list);
|
||||
void Write(HashSet<BaseGuild> list, bool tidy);
|
||||
|
||||
void WriteGuildSet<T>(HashSet<T> set) where T : BaseGuild;
|
||||
void WriteGuildSet<T>(HashSet<T> set, bool tidy) where T : BaseGuild;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,32 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public interface ISerializable
|
||||
{
|
||||
BufferWriter SaveBuffer { get; }
|
||||
int TypeReference { get; }
|
||||
uint SerialIdentity { get; }
|
||||
void Serialize();
|
||||
void Serialize(IGenericWriter writer);
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: ISerializable.cs *
|
||||
* Created: 2019/12/30 - Updated: 2020/01/18 *
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* 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 ISerializable
|
||||
{
|
||||
BufferWriter SaveBuffer { get; }
|
||||
int TypeReference { get; }
|
||||
uint SerialIdentity { get; }
|
||||
void Serialize();
|
||||
void Serialize(IGenericWriter writer);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,14 +191,10 @@ namespace Server
|
|||
if (x < 0 || y < 0 || x >= BlockWidth || y >= BlockHeight)
|
||||
return;
|
||||
|
||||
if (m_StaticTiles[x] == null)
|
||||
m_StaticTiles[x] = new StaticTile[BlockHeight][][][];
|
||||
|
||||
m_StaticTiles[x] ??= new StaticTile[BlockHeight][][][];
|
||||
m_StaticTiles[x][y] = value;
|
||||
|
||||
if (m_StaticPatches[x] == null)
|
||||
m_StaticPatches[x] = new int[BlockHeight + 31 >> 5];
|
||||
|
||||
m_StaticPatches[x] ??= new int[BlockHeight + 31 >> 5];
|
||||
m_StaticPatches[x][y >> 5] |= 1 << (y & 0x1F);
|
||||
}
|
||||
|
||||
|
|
@ -208,8 +204,7 @@ namespace Server
|
|||
if (x < 0 || y < 0 || x >= BlockWidth || y >= BlockHeight || DataStream == null || IndexStream == null)
|
||||
return EmptyStaticBlock;
|
||||
|
||||
if (m_StaticTiles[x] == null)
|
||||
m_StaticTiles[x] = new StaticTile[BlockHeight][][][];
|
||||
m_StaticTiles[x] ??= new StaticTile[BlockHeight][][][];
|
||||
|
||||
StaticTile[][][] tiles = m_StaticTiles[x][y];
|
||||
|
||||
|
|
@ -287,14 +282,10 @@ namespace Server
|
|||
if (x < 0 || y < 0 || x >= BlockWidth || y >= BlockHeight)
|
||||
return;
|
||||
|
||||
if (m_LandTiles[x] == null)
|
||||
m_LandTiles[x] = new LandTile[BlockHeight][];
|
||||
|
||||
m_LandTiles[x] ??= new LandTile[BlockHeight][];
|
||||
m_LandTiles[x][y] = value;
|
||||
|
||||
if (m_LandPatches[x] == null)
|
||||
m_LandPatches[x] = new int[BlockHeight + 31 >> 5];
|
||||
|
||||
m_LandPatches[x] ??= new int[BlockHeight + 31 >> 5];
|
||||
m_LandPatches[x][y >> 5] |= 1 << (y & 0x1F);
|
||||
}
|
||||
|
||||
|
|
@ -304,8 +295,7 @@ namespace Server
|
|||
if (x < 0 || y < 0 || x >= BlockWidth || y >= BlockHeight || MapStream == null)
|
||||
return m_InvalidLandBlock;
|
||||
|
||||
if (m_LandTiles[x] == null)
|
||||
m_LandTiles[x] = new LandTile[BlockHeight][];
|
||||
m_LandTiles[x] ??= new LandTile[BlockHeight][];
|
||||
|
||||
LandTile[] tiles = m_LandTiles[x][y];
|
||||
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ namespace Server
|
|||
sb.Append(value);
|
||||
}
|
||||
|
||||
public static string Intern(string str) => str == null ? null : str.Length == 0 ? string.Empty : string.Intern(str);
|
||||
public static string Intern(string str) => str?.Length > 0 ? string.Intern(str) : str;
|
||||
|
||||
public static void Intern(ref string str)
|
||||
{
|
||||
|
|
@ -138,8 +138,7 @@ namespace Server
|
|||
|
||||
public static IPAddress Intern(IPAddress ipAddress)
|
||||
{
|
||||
if (_ipAddressTable == null)
|
||||
_ipAddressTable = new Dictionary<IPAddress, IPAddress>();
|
||||
_ipAddressTable ??= new Dictionary<IPAddress, IPAddress>();
|
||||
|
||||
if (!_ipAddressTable.TryGetValue(ipAddress, out IPAddress interned))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -121,18 +121,11 @@ namespace Server
|
|||
set => SetValue(7, value);
|
||||
}
|
||||
|
||||
public int GetValue(int index)
|
||||
{
|
||||
if (Values == null)
|
||||
return 0;
|
||||
return Values[index];
|
||||
}
|
||||
public int GetValue(int index) => Values?[index] ?? 0;
|
||||
|
||||
public void SetValue(int index, int value)
|
||||
{
|
||||
if (Values == null)
|
||||
Values = new int[8];
|
||||
|
||||
Values ??= new int[8];
|
||||
Values[index] = value;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue