From 06ff76fe0bc16326c85074b827bcc42cf2eb4faa Mon Sep 17 00:00:00 2001 From: Edmand46 Date: Thu, 1 Dec 2022 22:24:03 +0400 Subject: [PATCH] fixed: second migration --- Ragon/Sources/Application.cs | 4 ++-- Ragon/Sources/Configuration.cs | 2 +- Ragon/Sources/GameRoom.cs | 16 +++++++++------- Ragon/Sources/RoomManager.cs | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Ragon/Sources/Application.cs b/Ragon/Sources/Application.cs index 68233c8..5cf9f5c 100755 --- a/Ragon/Sources/Application.cs +++ b/Ragon/Sources/Application.cs @@ -99,12 +99,12 @@ namespace Ragon.Core public void OnConnected(ushort peerId) { - _logger.Trace("Connected " + peerId); + // _logger.Trace("Connected " + peerId); } public void OnDisconnected(ushort peerId) { - _logger.Trace("Disconnected " + peerId); + // _logger.Trace("Disconnected " + peerId); var player = _lobby.AuthorizationManager.GetPlayer(peerId); if (player != null) diff --git a/Ragon/Sources/Configuration.cs b/Ragon/Sources/Configuration.cs index 1c78e02..08e8087 100755 --- a/Ragon/Sources/Configuration.cs +++ b/Ragon/Sources/Configuration.cs @@ -21,7 +21,7 @@ namespace Ragon.Core public int MaxRooms; private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); - private static readonly string _serverVersion = "1.0.25-rc"; + private static readonly string _serverVersion = "1.0.26-rc"; private static void CopyrightInfo() { diff --git a/Ragon/Sources/GameRoom.cs b/Ragon/Sources/GameRoom.cs index 13bee36..e583563 100755 --- a/Ragon/Sources/GameRoom.cs +++ b/Ragon/Sources/GameRoom.cs @@ -128,7 +128,6 @@ namespace Ragon.Core var propertySize = reader.ReadUShort(); entity.AddProperty(new EntityProperty(propertySize, propertyType)); } - player.AttachEntity(entity); AttachEntity(player, entity); } @@ -217,9 +216,7 @@ namespace Ragon.Core var entityType = reader.ReadUShort(); var eventAuthority = (RagonAuthority) reader.ReadByte(); var propertiesCount = reader.ReadUShort(); - - _logger.Trace($"[{peerId}] Create Entity {entityType}"); - + var player = _players[peerId]; var entity = new Entity(this, player.PeerId, entityType, 0, eventAuthority); for (var i = 0; i < propertiesCount; i++) @@ -309,9 +306,13 @@ namespace Ragon.Core foreach (var entity in entitiesToUpdate) { _writer.WriteUShort(entity.EntityId); - entity.SetOwner((ushort) next.PeerId); + entity.SetOwner(next.PeerId); + + next.Entities.Add(entity); } + next.EntitiesIds = next.Entities.Select(e => e.EntityId).ToList(); + BroadcastToReady(_writer, DeliveryType.Reliable); } @@ -345,6 +346,7 @@ namespace Ragon.Core void BroadcastSnapshot(ushort[] peersIds) { + _logger.Trace("Snapshot"); _writer.Clear(); _writer.WriteOperation(RagonOperation.SNAPSHOT); _writer.WriteUShort((ushort) _readyPlayers.Length); @@ -367,7 +369,7 @@ namespace Ragon.Core _writer.WriteUShort(entity.OwnerId); _writer.WriteUShort((ushort) payload.Length); _writer.WriteData(ref payload); - + entity.WriteSnapshot(_writer); } @@ -384,7 +386,7 @@ namespace Ragon.Core _writer.WriteUShort(entity.OwnerId); _writer.WriteUShort((ushort) payload.Length); _writer.WriteData(ref payload); - + entity.WriteSnapshot(_writer); } diff --git a/Ragon/Sources/RoomManager.cs b/Ragon/Sources/RoomManager.cs index f181162..d360aba 100644 --- a/Ragon/Sources/RoomManager.cs +++ b/Ragon/Sources/RoomManager.cs @@ -74,7 +74,7 @@ public class RoomManager { if (existRoom.Map == map && existRoom.PlayersCount < existRoom.PlayersMax) { - _logger.Trace($"Player ({player.PlayerName}|{player.Id}) joined to room with Id {roomId}"); + _logger.Trace($"Player ({player.PlayerName}|{player.Id}) joined to room with Id {existRoom.Id}"); existRoom.AddPlayer(player, payload); _roomsBySocket.Add(player.PeerId, existRoom);