Fixes packet length & PropertyList (#82)

This commit is contained in:
Kamron Batman 2020-01-21 21:00:56 -08:00 committed by GitHub
parent 1f1ceade8c
commit 27e8d823bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 251 additions and 225 deletions

View file

@ -1370,9 +1370,9 @@ namespace Server.Items
return base.CanEquip(from);
}
public override bool CheckPropertyConfliction(Mobile m)
public override bool CheckPropertyConflict(Mobile m)
{
if (base.CheckPropertyConfliction(m))
if (base.CheckPropertyConflict(m))
return true;
if (Layer == Layer.Pants)

View file

@ -544,9 +544,9 @@ namespace Server.Items
return Attributes.SpellChanneling != 0;
}
public override bool CheckPropertyConfliction(Mobile m)
public override bool CheckPropertyConflict(Mobile m)
{
if (base.CheckPropertyConfliction(m))
if (base.CheckPropertyConflict(m))
return true;
if (Layer == Layer.Pants)

View file

@ -541,31 +541,22 @@ namespace Server.Items
writer.WriteDeltaTime(TimeOfDeath);
List<KeyValuePair<Item, Point3D>> list = m_RestoreTable == null
? null
: new List<KeyValuePair<Item, Point3D>>(m_RestoreTable);
int count = list?.Count ?? 0;
int count = m_RestoreTable?.Count ?? 0;
writer.Write(count);
for (int i = 0; i < count; ++i)
{
KeyValuePair<Item, Point3D> kvp = list[i];
Item item = kvp.Key;
Point3D loc = kvp.Value;
writer.Write(item);
if (item.Location == loc)
if (m_RestoreTable != null)
foreach (var (item, loc) in m_RestoreTable)
{
writer.Write(false);
writer.Write(item);
if (item.Location == loc)
writer.Write(false);
else
{
writer.Write(true);
writer.Write(loc);
}
}
else
{
writer.Write(true);
writer.Write(loc);
}
}
writer.Write(m_DecayTimer != null);

View file

@ -13,6 +13,7 @@
<WarningsAsErrors />
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>8.0</LangVersion>
<OutDir>..\..\Distribution\Assemblies</OutDir>
<OutputPath>..\..\Distribution\Assemblies</OutputPath>
<PublishDir>..\..\Distribution\Assemblies</PublishDir>

View file

@ -1,23 +1,22 @@
/***************************************************************************
* AssemblyHandler.cs
* --------------------
* begin : May 1, 2002
* copyright : (C) The RunUO Software Team
* email : info@runuo.com
*
* $Id$
*
***************************************************************************/
/***************************************************************************
*
* 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 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
/*************************************************************************
* ModernUO *
* Copyright (C) 2019 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: AssemblyHandler.cs - Created: 2019/08/02 - Updated: 2020/01/19 *
* *
* 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;

View file

@ -1,3 +1,23 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: CityInfo.cs - Created: 2019/10/04 - Updated: 2020/01/19 *
* *
* 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 sealed class CityInfo

View file

@ -1,3 +1,23 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: Configuration.cs - Created: 2019/10/04 - Updated: 2020/01/19 *
* *
* 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;
@ -67,7 +87,7 @@ namespace Server
public void Flush()
{
using FileStream fs = new FileStream(FilePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write);
string configJson = JsonSerializer.Serialize(this, new JsonSerializerOptions {WriteIndented = true});
string configJson = JsonSerializer.Serialize(this, new JsonSerializerOptions { WriteIndented = true });
Span<byte> data = stackalloc byte[Utility.UTF8WithEncoding.GetMaxByteCount(configJson.Length)];
int bytesWritten = Utility.UTF8WithEncoding.GetBytes(configJson, data);
fs.Write(data.Slice(0, bytesWritten));

View file

@ -19,6 +19,7 @@
***************************************************************************/
using System.Collections.Generic;
using System.Linq;
namespace Server.Guilds
{
@ -32,7 +33,7 @@ namespace Server.Guilds
public abstract class BaseGuild : ISerializable
{
private BufferWriter m_SaveBuffer;
public BufferWriter SaveBuffer { get { return m_SaveBuffer; } }
public BufferWriter SaveBuffer => m_SaveBuffer;
private static uint m_NextID = 1;
@ -83,23 +84,9 @@ namespace Server.Guilds
return g;
}
public static BaseGuild FindByName(string name)
{
foreach (BaseGuild g in List.Values)
if (g.Name == name)
return g;
public static BaseGuild FindByName(string name) => List.Values.FirstOrDefault(g => g.Name == name);
return null;
}
public static BaseGuild FindByAbbrev(string abbr)
{
foreach (BaseGuild g in List.Values)
if (g.Abbreviation == abbr)
return g;
return null;
}
public static BaseGuild FindByAbbrev(string abbr) => List.Values.FirstOrDefault(g => g.Abbreviation == abbr);
public static List<BaseGuild> Search(string find)
{
@ -108,16 +95,9 @@ namespace Server.Guilds
foreach (BaseGuild g in List.Values)
{
bool match = true;
string name = g.Name.ToLower();
for (int i = 0; i < words.Length; i++)
if (name.IndexOf(words[i]) == -1)
{
match = false;
break;
}
if (match)
if (words.All(t => name.IndexOf(t) != -1))
results.Add(g);
}

View file

@ -347,7 +347,18 @@ namespace Server
public Packet RemovePacket => StaticPacketHandlers.GetRemoveEntityPacket(this);
public OPLInfo OPLPacket => StaticPacketHandlers.GetOPLInfoPacket(this);
public ObjectPropertyList PropertyList => StaticPacketHandlers.GetOPLPacket(this);
private ObjectPropertyList m_PropertyList;
public ObjectPropertyList PropertyList => m_PropertyList ??= NewObjectPropertyList();
public void ReleaseOPLPacket()
{
if (m_PropertyList == null)
return;
Packet.Release(m_PropertyList);
m_PropertyList = null;
}
// World packets need to be invalidated when any of the following changes:
// - ItemID
@ -960,17 +971,16 @@ namespace Server
{
NetState ns = rootParent.NetState;
if (ns != null)
if (rootParent.CanSee(this) && rootParent.InRange(worldLoc, GetUpdateRange(rootParent)))
{
if (ns.ContainerGridLines)
ns.Send(new ContainerContentUpdate6017(this));
else
ns.Send(new ContainerContentUpdate(this));
if (ns != null && rootParent.CanSee(this) && rootParent.InRange(worldLoc, GetUpdateRange(rootParent)))
{
if (ns.ContainerGridLines)
ns.Send(new ContainerContentUpdate6017(this));
else
ns.Send(new ContainerContentUpdate(this));
if (ObjectPropertyList.Enabled)
ns.Send(OPLPacket);
}
if (ObjectPropertyList.Enabled)
ns.Send(OPLPacket);
}
}
SecureTrade st = GetSecureTradeCont()?.Trade;
@ -1013,9 +1023,7 @@ namespace Server
int range = GetUpdateRange(mob);
if (mob.Map != map || !mob.InRange(worldLoc, range))
{
openers.RemoveAt(i--);
}
else
{
if (mob == rootParent || mob == tradeRecip)
@ -1051,44 +1059,43 @@ namespace Server
{
Mobile m = state.Mobile;
if (m.CanSee(this) && m.InRange(worldLoc, GetUpdateRange(m)))
if (!m.CanSee(this) || !m.InRange(worldLoc, GetUpdateRange(m))) continue;
if (update)
{
if (update)
if (m_Parent == null)
SendInfoTo(state, ObjectPropertyList.Enabled);
else
{
if (m_Parent == null)
SendInfoTo(state, ObjectPropertyList.Enabled);
else
if (p != null)
state.Send(p);
else if (m_Parent is Item)
{
if (p != null)
state.Send(p);
else if (m_Parent is Item)
{
if (state.ContainerGridLines)
state.Send(new ContainerContentUpdate6017(this));
else
state.Send(new ContainerContentUpdate(this));
}
else if (m_Parent is Mobile)
{
p = new EquipUpdate(this);
p.Acquire();
state.Send(p);
}
if (ObjectPropertyList.Enabled)
state.Send(OPLPacket);
if (state.ContainerGridLines)
state.Send(new ContainerContentUpdate6017(this));
else
state.Send(new ContainerContentUpdate(this));
}
else if (m_Parent is Mobile)
{
p = new EquipUpdate(this);
p.Acquire();
state.Send(p);
}
}
else if ((flags & ItemDelta.EquipOnly) != 0 && m_Parent is Mobile)
{
state.Send(p ?? (p = Packet.Acquire(new EquipUpdate(this))));
if (ObjectPropertyList.Enabled)
state.Send(OPLPacket);
} else if (ObjectPropertyList.Enabled && (flags & ItemDelta.Properties) != 0)
state.Send(OPLPacket);
}
}
else if ((flags & ItemDelta.EquipOnly) != 0 && m_Parent is Mobile)
{
state.Send(p ??= Packet.Acquire(new EquipUpdate(this)));
if (ObjectPropertyList.Enabled)
state.Send(OPLPacket);
} else if (ObjectPropertyList.Enabled && (flags & ItemDelta.Properties) != 0)
state.Send(OPLPacket);
}
Packet.Release(p);
@ -1273,7 +1280,7 @@ namespace Server
writer.Write((byte)m_Direction);
if (GetSaveFlag(flags, SaveFlag.Bounce))
BounceInfo.Serialize(info.m_Bounce, writer);
BounceInfo.Serialize(info?.m_Bounce, writer);
if (GetSaveFlag(flags, SaveFlag.LootType))
writer.Write((byte)m_LootType);
@ -1414,7 +1421,7 @@ namespace Server
private CompactInfo LookupCompactInfo() => m_CompactInfo;
private CompactInfo AcquireCompactInfo() => m_CompactInfo ?? (m_CompactInfo = new CompactInfo());
private CompactInfo AcquireCompactInfo() => m_CompactInfo ??= new CompactInfo();
private void ReleaseCompactInfo()
{
@ -1531,17 +1538,17 @@ namespace Server
/// <item>
/// <term>True</term>
/// <description>
/// There is a confliction. The elemental resistance bonuses of this Item should not be applied to the
/// There is a conflict. 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>
/// <description>There is no conflict. The bonuses should be applied.</description>
/// </item>
/// </list>
/// </returns>
public virtual bool CheckPropertyConfliction(Mobile m) => false;
public virtual bool CheckPropertyConflict(Mobile m) => false;
/// <summary>
/// Overridable. Sends the <see cref="PropertyList">object property list</see> to <paramref name="from" />.
@ -2008,9 +2015,21 @@ namespace Server
mobile.GetChildNameProperties(list, this);
}
public ObjectPropertyList NewObjectPropertyList()
{
ObjectPropertyList list = new ObjectPropertyList(this);
GetProperties(list);
AppendChildProperties(list);
list.Terminate();
list.SetStatic();
return list;
}
public void ClearProperties()
{
StaticPacketHandlers.FreeOPLPacket(this);
ReleaseOPLPacket();
StaticPacketHandlers.FreeOPLInfoPacket(this);
}
@ -2021,9 +2040,10 @@ namespace Server
if (m_Map != null && m_Map != Map.Internal && !World.Loading)
{
ObjectPropertyList oldList = StaticPacketHandlers.FreeOPLPacket(this);
ObjectPropertyList oldList = m_PropertyList;
m_PropertyList = null;
if (oldList?.Hash != PropertyList.Hash)
if (oldList != null && oldList.Hash != PropertyList.Hash)
{
StaticPacketHandlers.FreeOPLInfoPacket(this);
Delta(ItemDelta.Properties);
@ -2398,8 +2418,8 @@ namespace Server
{
List<Item> items = reader.ReadStrongItemList();
if (this is Container)
(this as Container).m_Items = items;
if (this is Container cont)
cont.m_Items = items;
else
AcquireCompactInfo().m_Items = items;
}
@ -2500,8 +2520,8 @@ namespace Server
items.Add(item);
}
if (this is Container)
(this as Container).m_Items = items;
if (this is Container cont)
cont.m_Items = items;
else
AcquireCompactInfo().m_Items = items;
}
@ -2765,7 +2785,7 @@ namespace Server
ReleaseWorldPackets();
StaticPacketHandlers.FreeRemoveItemPacket(this);
StaticPacketHandlers.FreeOPLInfoPacket(this);
StaticPacketHandlers.FreeOPLPacket(this);
ReleaseOPLPacket();
}
public void PublicOverheadMessage(MessageType type, int hue, bool ascii, string text)

View file

@ -111,19 +111,9 @@ namespace Server.Items
&& mcl.Tiles[x][y].Length > 0;
}
public bool Contains(Mobile m)
{
if (m.Map == Map)
return Contains(m.X, m.Y);
return false;
}
public bool Contains(Mobile m) => m.Map == Map && Contains(m.X, m.Y);
public bool Contains(Item item)
{
if (item.Map == Map)
return Contains(item.X, item.Y);
return false;
}
public bool Contains(Item item) => item.Map == Map && Contains(item.X, item.Y);
public override void Serialize(IGenericWriter writer)
{

View file

@ -21,6 +21,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Server.Network;
namespace Server.Items
@ -1322,10 +1323,7 @@ namespace Server.Items
for (int j = 0; j < groups.Count; ++j)
{
Item[] items = groups[j].ToArray();
int total = 0;
for (int k = 0; k < items.Length; ++k)
total += items[k].Amount;
int total = items.Sum(t => t.Amount);
if (total >= best)
best = total;
@ -1387,29 +1385,9 @@ namespace Server.Items
return best;
}
public int GetAmount(Type type, bool recurse = true)
{
Item[] items = FindItemsByType(type, recurse);
public int GetAmount(Type type, bool recurse = true) => FindItemsByType(type, recurse).Sum(t => t.Amount);
int amount = 0;
for (int i = 0; i < items.Length; ++i)
amount += items[i].Amount;
return amount;
}
public int GetAmount(Type[] types, bool recurse = true)
{
Item[] items = FindItemsByType(types, recurse);
int amount = 0;
for (int i = 0; i < items.Length; ++i)
amount += items[i].Amount;
return amount;
}
public int GetAmount(Type[] types, bool recurse = true) => FindItemsByType(types, recurse).Sum(t => t.Amount);
#endregion

View file

@ -106,10 +106,7 @@ namespace Server
public HairEquipUpdate(Mobile parent)
: base(0x2E, 15)
{
int hue = parent.HairHue;
if (parent.SolidHueOverride >= 0)
hue = parent.SolidHueOverride;
int hue = parent.SolidHueOverride >= 0 ? parent.SolidHueOverride : parent.HairHue;
m_Stream.Write(HairInfo.FakeSerial(parent));
m_Stream.Write((short)parent.HairItemID);
@ -125,10 +122,7 @@ namespace Server
public FacialHairEquipUpdate(Mobile parent)
: base(0x2E, 15)
{
int hue = parent.FacialHairHue;
if (parent.SolidHueOverride >= 0)
hue = parent.SolidHueOverride;
int hue = parent.SolidHueOverride >= 0 ? parent.SolidHueOverride : parent.FacialHairHue;
m_Stream.Write(FacialHairInfo.FakeSerial(parent));
m_Stream.Write((short)parent.FacialHairItemID);
@ -156,4 +150,4 @@ namespace Server
m_Stream.Write(FacialHairInfo.FakeSerial(parent));
}
}
}
}

View file

@ -1,3 +1,23 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: Layer.cs - Created: 2019/03/15 - Updated: 2020/01/19 *
* *
* 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
{
/// <summary>

View file

@ -1,3 +1,23 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: LightType.cs - Created: 2019/03/15 - Updated: 2020/01/19 *
* *
* 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 enum LightType

View file

@ -1759,7 +1759,17 @@ namespace Server
public Packet RemovePacket => StaticPacketHandlers.GetRemoveEntityPacket(this);
public OPLInfo OPLPacket => StaticPacketHandlers.GetOPLInfoPacket(this);
public ObjectPropertyList PropertyList => StaticPacketHandlers.GetOPLPacket(this);
private ObjectPropertyList m_PropertyList;
public ObjectPropertyList PropertyList => m_PropertyList ??= NewObjectPropertyList();
public void ReleaseOPLPacket()
{
if (m_PropertyList == null)
return;
Packet.Release(m_PropertyList);
m_PropertyList = null;
}
[CommandProperty(AccessLevel.GameMaster)]
public int SolidHueOverride
@ -2902,7 +2912,7 @@ namespace Server
{
Item item = Items[i];
if (item.CheckPropertyConfliction(this))
if (item.CheckPropertyConflict(this))
continue;
Resistances[0] += item.PhysicalResistance;
@ -6525,12 +6535,23 @@ namespace Server
{
StaticPacketHandlers.FreeRemoveItemPacket(this);
StaticPacketHandlers.FreeOPLInfoPacket(this);
StaticPacketHandlers.FreeOPLPacket(this);
ReleaseOPLPacket();
}
public ObjectPropertyList NewObjectPropertyList()
{
ObjectPropertyList list = new ObjectPropertyList(this);
GetProperties(list);
list.Terminate();
list.SetStatic();
return list;
}
public void ClearProperties()
{
StaticPacketHandlers.FreeOPLPacket(this);
ReleaseOPLPacket();
StaticPacketHandlers.FreeOPLInfoPacket(this);
}
@ -6541,9 +6562,10 @@ namespace Server
if (m_Map != null && m_Map != Map.Internal && !World.Loading)
{
ObjectPropertyList oldList = StaticPacketHandlers.FreeOPLPacket(this);
ObjectPropertyList oldList = m_PropertyList;
m_PropertyList = null;
if (oldList?.Hash != PropertyList.Hash)
if (oldList != null && oldList.Hash != PropertyList.Hash)
{
StaticPacketHandlers.FreeOPLInfoPacket(this);
Delta(MobileDelta.Properties);

View file

@ -567,7 +567,8 @@ namespace Server.Network
}
int count = pvSrc.ReadUInt16();
if (count < 100 && pvSrc.Length == 1 + 2 + 4 + 2 + count * 6)
if (count < 100 && pvSrc.Length == 4 + 2 + count * 6)
{
List<SellItemResponse> sellList = new List<SellItemResponse>(count);
@ -662,7 +663,7 @@ namespace Server.Network
huePicker.OnResponse(hue);
break;
}
}
}
public static void SystemInfo(NetState state, PacketReader pvSrc)
@ -1490,7 +1491,7 @@ namespace Server.Network
{
if (state.Mobile == null)
Console.WriteLine(
"Client: {0}: Sent ingame packet (0xBFx{1:X2}) before having been attached to a mobile", state,
"Client: {0}: Sent in-game packet (0xBFx{1:X2}) before having been attached to a mobile", state,
packetID);
state.Dispose();
}
@ -1556,7 +1557,7 @@ namespace Server.Network
Mobile from = state.Mobile;
long length = pvSrc.Length - 3;
long length = pvSrc.Length;
if (length < 0 || length % 4 != 0)
return;
@ -2122,7 +2123,7 @@ namespace Server.Network
name, female, hue,
str, dex, intl,
info[cityIndex],
new SkillNameValue[]
new[]
{
new SkillNameValue((SkillName)is1, vs1),
new SkillNameValue((SkillName)is2, vs2),
@ -2239,7 +2240,7 @@ namespace Server.Network
name, female, hue,
str, dex, intl,
info[cityIndex],
new SkillNameValue[]
new[]
{
new SkillNameValue((SkillName)is1, vs1),
new SkillNameValue((SkillName)is2, vs2),

View file

@ -19,6 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
using System.Collections.Concurrent;
namespace Server.Network
@ -26,7 +27,6 @@ namespace Server.Network
public static class StaticPacketHandlers
{
private static ConcurrentDictionary<IPropertyListObject,OPLInfo> OPLInfoPackets = new ConcurrentDictionary<IPropertyListObject,OPLInfo>();
private static ConcurrentDictionary<IPropertyListObject,ObjectPropertyList> ObjectPropertyListPackets = new ConcurrentDictionary<IPropertyListObject,ObjectPropertyList>();
private static ConcurrentDictionary<IEntity,RemoveEntity> RemoveEntityPackets = new ConcurrentDictionary<IEntity,RemoveEntity>();
private static ConcurrentDictionary<Item,WorldItem> WorldItemPackets = new ConcurrentDictionary<Item,WorldItem>();
@ -37,7 +37,7 @@ namespace Server.Network
{
return OPLInfoPackets.GetOrAdd(obj, value =>
{
OPLInfo packet = new OPLInfo(value.PropertyList);
OPLInfo packet = new OPLInfo(value.PropertyList.Entity.Serial, value.PropertyList.Hash);
packet.SetStatic();
return packet;
});
@ -51,30 +51,6 @@ namespace Server.Network
return p;
}
public static ObjectPropertyList GetOPLPacket(IPropertyListObject obj)
{
return ObjectPropertyListPackets.GetOrAdd(obj, value =>
{
ObjectPropertyList list = new ObjectPropertyList(value);
value.GetProperties(list);
if (value is Item item)
item.AppendChildProperties(list);
list.Terminate();
list.SetStatic();
return list;
});
}
public static ObjectPropertyList FreeOPLPacket(IPropertyListObject obj)
{
if (ObjectPropertyListPackets.TryRemove(obj, out ObjectPropertyList list))
Packet.Release(list);
return list;
}
public static RemoveEntity GetRemoveEntityPacket(IEntity entity)
{
return RemoveEntityPackets.GetOrAdd(entity, value =>

View file

@ -46,14 +46,8 @@ namespace Server
0x035
};
public static int GetHue(int noto)
{
if (noto < 0 || noto >= Hues.Length)
return 0;
return Hues[noto];
}
public static int GetHue(int noto) => noto < 0 || noto >= Hues.Length ? 0 : Hues[noto];
public static int Compute(Mobile source, Mobile target) => Handler?.Invoke(source, target) ?? CanBeAttacked;
}
}
}

View file

@ -26,8 +26,8 @@ namespace Server
{
public interface IPropertyListObject : IEntity
{
ObjectPropertyList PropertyList{ get; }
OPLInfo OPLPacket{ get; }
ObjectPropertyList PropertyList { get; }
OPLInfo OPLPacket { get; }
void GetProperties(ObjectPropertyList list);
}
@ -189,10 +189,10 @@ namespace Server
m_Stream.Write( (int) list.Hash );
}*/
public OPLInfo(ObjectPropertyList list) : base(0xDC, 9)
public OPLInfo(Serial serial, int hash) : base(0xDC, 9)
{
m_Stream.Write(list.Entity.Serial);
m_Stream.Write(list.Hash);
m_Stream.Write(serial);
m_Stream.Write(hash);
}
}
}

0
Publish-OSX.sh Normal file → Executable file
View file