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

@ -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 =>