diff --git a/Ragon/Sources/Entity/Entity.cs b/Ragon/Sources/Entity/Entity.cs index b260c58..891c7cd 100644 --- a/Ragon/Sources/Entity/Entity.cs +++ b/Ragon/Sources/Entity/Entity.cs @@ -8,12 +8,12 @@ public class Entity public ushort EntityId { get; private set; } public ushort StaticId { get; private set; } public ushort EntityType { get; private set; } - public uint OwnerId { get; private set; } + public ushort OwnerId { get; private set; } public RagonAuthority Authority { get; private set; } public EntityProperty[] Properties { get; private set; } public byte[] Payload { get; set; } - public Entity(uint ownerId, ushort entityType, ushort staticId, RagonAuthority stateAuthority, RagonAuthority eventAuthority, int props) + public Entity(ushort ownerId, ushort entityType, ushort staticId, RagonAuthority stateAuthority, RagonAuthority eventAuthority, int props) { OwnerId = ownerId; StaticId = staticId; diff --git a/Ragon/Sources/Game/GameRoom.cs b/Ragon/Sources/Game/GameRoom.cs index 91922ac..c3dbd99 100755 --- a/Ragon/Sources/Game/GameRoom.cs +++ b/Ragon/Sources/Game/GameRoom.cs @@ -120,11 +120,11 @@ namespace Ragon.Core } } - public void ProcessEvent(uint peerId, RagonOperation operation, ReadOnlySpan payloadRawData) + public void ProcessEvent(ushort peerId, RagonOperation operation, ReadOnlySpan payloadRawData) { _serializer.Clear(); _serializer.FromSpan(ref payloadRawData); - + switch (operation) { case RagonOperation.REPLICATE_ENTITY_STATE: @@ -137,7 +137,7 @@ namespace Ragon.Core _logger.Warn($"Not owner can't change properties of object {entityId}"); return; } - + var mask = _serializer.ReadLong(); for (var i = 0; i < ent.Properties.Length; i++) { @@ -145,9 +145,9 @@ namespace Ragon.Core { var propertyPayload = _serializer.ReadData(ent.Properties[i].Size); ent.Properties[i].Write(ref propertyPayload); - } + } } - + if (_entitiesDirtySet.Add(ent)) _entitiesDirty.Add(ent); } @@ -260,7 +260,7 @@ namespace Ragon.Core foreach (var playerPeerId in _readyPlayers) if (playerPeerId != _owner) _peersCache.Add(playerPeerId); - + Broadcast(_peersCache.ToArray(), sendData, DeliveryType.Reliable); break; } @@ -270,6 +270,7 @@ namespace Ragon.Core break; } } + break; } case RagonOperation.CREATE_STATIC_ENTITY: @@ -282,7 +283,6 @@ namespace Ragon.Core { var propertySize = _serializer.ReadUShort(); entity.Properties[i] = new EntityProperty(propertySize); - _logger.Trace($"Static Property: {i} {propertySize}"); } { @@ -326,11 +326,8 @@ namespace Ragon.Core { var propertySize = _serializer.ReadUShort(); entity.Properties[i] = new EntityProperty(propertySize); - _logger.Trace($"Property: {i} {propertySize}"); } - _logger.Trace($"Created object with type: {entityType} {propertiesCount}"); - { var entityPayload = _serializer.ReadData(_serializer.Size); entity.Payload = entityPayload.ToArray(); @@ -425,9 +422,9 @@ namespace Ragon.Core ReadOnlySpan payload = entity.Payload.AsSpan(); _serializer.WriteUShort(entity.EntityType); - _serializer.WriteInt(entity.EntityId); - _serializer.WriteUShort((ushort) entity.StaticId); - _serializer.WriteUShort((ushort) entity.OwnerId); + _serializer.WriteUShort(entity.EntityId); + _serializer.WriteUShort(entity.StaticId); + _serializer.WriteUShort(entity.OwnerId); _serializer.WriteUShort((ushort) payload.Length); _serializer.WriteData(ref payload); } diff --git a/Ragon/Sources/Game/GameThread.cs b/Ragon/Sources/Game/GameThread.cs index e718a6f..1a5c3fb 100755 --- a/Ragon/Sources/Game/GameThread.cs +++ b/Ragon/Sources/Game/GameThread.cs @@ -104,7 +104,7 @@ namespace Ragon.Core { try { - var peerId = evnt.Peer.ID; + var peerId = (ushort) evnt.Peer.ID; var dataRaw = new byte[evnt.Packet.Length]; evnt.Packet.CopyTo(dataRaw); diff --git a/Ragon/Sources/Lobby/Lobby.cs b/Ragon/Sources/Lobby/Lobby.cs index b067bc7..d9d8d84 100644 --- a/Ragon/Sources/Lobby/Lobby.cs +++ b/Ragon/Sources/Lobby/Lobby.cs @@ -23,7 +23,7 @@ public class Lobby : ILobby _authorizationManager = new AuthorizationManager(provider, gameThread, this, _serializer); } - public void ProcessEvent(uint peerId, RagonOperation op, ReadOnlySpan payload) + public void ProcessEvent(ushort peerId, RagonOperation op, ReadOnlySpan payload) { _serializer.Clear(); _serializer.FromSpan(ref payload);