diff --git a/Ragon/Sources/Entity/EntityProperty.cs b/Ragon/Sources/Entity/EntityProperty.cs index fe8017f..46e037c 100644 --- a/Ragon/Sources/Entity/EntityProperty.cs +++ b/Ragon/Sources/Entity/EntityProperty.cs @@ -6,17 +6,19 @@ namespace Ragon.Core; public class EntityProperty { public int Size { get; set; } + public int Capacity { get; set; } public bool IsDirty { get; private set; } public bool IsFixed { get; private set; } private byte[] _data; public EntityProperty(int size, bool isFixed) { - _data = new byte[512]; - + Capacity = 512; Size = size; IsFixed = isFixed; IsDirty = true; + + _data = new byte[Capacity]; } public ReadOnlySpan Read() diff --git a/Ragon/Sources/Game/GameRoom.cs b/Ragon/Sources/Game/GameRoom.cs index e430063..da487db 100755 --- a/Ragon/Sources/Game/GameRoom.cs +++ b/Ragon/Sources/Game/GameRoom.cs @@ -160,11 +160,19 @@ namespace Ragon.Core if (_serializer.ReadBool()) { var property = ent.Properties[i]; + var size = property.Size; if (!property.IsFixed) - property.Size = _serializer.ReadUShort(); + size = _serializer.ReadUShort(); - var propertyPayload = _serializer.ReadData(property.Size); + if (size > property.Capacity) + { + _logger.Warn($"Property {i} payload too large, size: {size}"); + continue; + } + + var propertyPayload = _serializer.ReadData(size); property.Write(ref propertyPayload); + property.Size = size; } }