Compare commits

..

2 Commits

Author SHA1 Message Date
edmand46 5aa159ed2f fixed: custom property wrong size 2023-11-05 21:53:57 +03:00
edmand46 892558ab16 chore: update version 2023-10-22 21:10:31 +03:00
7 changed files with 22 additions and 14 deletions
+2 -2
View File
@@ -106,7 +106,7 @@ namespace Ragon.Client
{ {
Serialize(_propertyBuffer); Serialize(_propertyBuffer);
buffer.FromBuffer(_propertyBuffer, _size); buffer.CopyFrom(_propertyBuffer, _size);
return; return;
} }
@@ -114,7 +114,7 @@ namespace Ragon.Client
var propertySize = (ushort) _propertyBuffer.WriteOffset; var propertySize = (ushort) _propertyBuffer.WriteOffset;
buffer.WriteUShort(propertySize);; buffer.WriteUShort(propertySize);;
buffer.FromBuffer(_propertyBuffer, propertySize); buffer.CopyFrom(_propertyBuffer, propertySize);
} }
internal void Read(RagonBuffer buffer) internal void Read(RagonBuffer buffer)
+2 -5
View File
@@ -236,9 +236,6 @@ namespace Ragon.Protocol
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Write(uint value, int numBits = 16) public void Write(uint value, int numBits = 16)
{ {
Debug.Assert(!(numBits < 0));
Debug.Assert(!(numBits > 32));
var currentBucketIndex = _write >> 5; var currentBucketIndex = _write >> 5;
var used = _write & 0x0000001F; var used = _write & 0x0000001F;
var mask = (1UL << used) - 1; var mask = (1UL << used) - 1;
@@ -357,7 +354,7 @@ namespace Ragon.Protocol
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void FromBuffer(RagonBuffer buffer, int size) public void CopyFrom(RagonBuffer buffer, int size)
{ {
WriteArray(buffer._buckets, size); WriteArray(buffer._buckets, size);
} }
@@ -434,7 +431,7 @@ namespace Ragon.Protocol
public void ToArray(byte[] outData) public void ToArray(byte[] outData)
{ {
Debug.Assert(outData.Length >= Length); Write(1, 1);
var bucketsCount = (_write >> 5) + 1; var bucketsCount = (_write >> 5) + 1;
var length = Length; var length = Length;
@@ -14,7 +14,6 @@
* limitations under the License. * limitations under the License.
*/ */
using Ragon.Protocol; using Ragon.Protocol;
namespace Ragon.Server.Entity; namespace Ragon.Server.Entity;
+1 -1
View File
@@ -28,7 +28,7 @@ public class RagonPayload
public void Read(RagonBuffer buffer) public void Read(RagonBuffer buffer)
{ {
_size = buffer.Capacity; _size = buffer.Capacity - 1;
buffer.ReadArray(_data, _size); buffer.ReadArray(_data, _size);
} }
@@ -54,6 +54,13 @@ public class RagonProperty : RagonPayload
public void Write(RagonBuffer buffer) public void Write(RagonBuffer buffer)
{ {
if (IsFixed)
{
buffer.WriteArray(_data, Size);
return;
}
buffer.Write((ushort) Size);
buffer.WriteArray(_data, Size); buffer.WriteArray(_data, Size);
} }
+6 -1
View File
@@ -99,6 +99,11 @@ public class RagonServer : IRagonServer, INetworkListener
_timer.Start(); _timer.Start();
while (true) while (true)
{ {
if (_timer.ElapsedMilliseconds > _tickRate * 2)
{
_logger.Warn($"Slow perfomance: {_timer.ElapsedMilliseconds}");
}
if (_timer.ElapsedMilliseconds > _tickRate) if (_timer.ElapsedMilliseconds > _tickRate)
{ {
_timer.Restart(); _timer.Restart();
@@ -197,7 +202,7 @@ public class RagonServer : IRagonServer, INetworkListener
_reader.FromArray(data); _reader.FromArray(data);
var operation = _reader.ReadByte(); var operation = _reader.ReadByte();
_handlers[operation].Handle(context, channel); _handlers[operation]?.Handle(context, channel);
} }
} }
catch (Exception ex) catch (Exception ex)
@@ -42,7 +42,7 @@ public struct RagonServerConfiguration
public Dictionary<string, string> WebHooks; public Dictionary<string, string> WebHooks;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private static readonly string ServerVersion = "1.3.1"; private static readonly string ServerVersion = "1.3.2";
private static Dictionary<string, ServerType> _serverTypes = new Dictionary<string, ServerType>() private static Dictionary<string, ServerType> _serverTypes = new Dictionary<string, ServerType>()
{ {
{"enet", Server.ServerType.ENET}, {"enet", Server.ServerType.ENET},