🐛 prediction spawning for wrong connection, payload capacity
This commit is contained in:
@@ -70,7 +70,7 @@ internal class SnapshotHandler : IHandler
|
||||
var player = _playerCache.GetPlayerByPeer(ownerPeerId);
|
||||
if (player == null)
|
||||
{
|
||||
RagonLog.Error($"Player not found with peerId: ${ownerPeerId}");
|
||||
RagonLog.Error($"Player not found with peerId: {ownerPeerId}");
|
||||
|
||||
_playerCache.Dump();
|
||||
return;
|
||||
@@ -106,7 +106,7 @@ internal class SnapshotHandler : IHandler
|
||||
var player = _playerCache.GetPlayerByPeer(ownerPeerId);
|
||||
if (player == null)
|
||||
{
|
||||
RagonLog.Error($"Player not found with peerId: ${ownerPeerId}");
|
||||
RagonLog.Error($"Player not found with peerId: {ownerPeerId}");
|
||||
|
||||
_playerCache.Dump();
|
||||
return;
|
||||
|
||||
@@ -88,9 +88,9 @@ public sealed class RagonEntityCache
|
||||
RagonLog.Warn("Can't destroy object");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
entity.SetReplication(false);
|
||||
|
||||
|
||||
var buffer = _client.Buffer;
|
||||
|
||||
buffer.Clear();
|
||||
@@ -168,7 +168,7 @@ public sealed class RagonEntityCache
|
||||
_entityMap.Clear();
|
||||
_entityList.Clear();
|
||||
}
|
||||
|
||||
|
||||
internal RagonEntity TryGetEntity(ushort attachId, ushort entityType, ushort sceneId, ushort entityId, bool hasAuthority, out bool hasCreated)
|
||||
{
|
||||
if (sceneId > 0)
|
||||
@@ -179,36 +179,33 @@ public sealed class RagonEntityCache
|
||||
|
||||
if (hasAuthority)
|
||||
_entityList.Add(sceneEntity);
|
||||
|
||||
|
||||
hasCreated = false;
|
||||
|
||||
|
||||
return sceneEntity;
|
||||
}
|
||||
}
|
||||
|
||||
if (_pendingEntities.TryGetValue(attachId, out var pendingEntity))
|
||||
if (_pendingEntities.TryGetValue(attachId, out var pendingEntity) && hasAuthority)
|
||||
{
|
||||
_pendingEntities.Remove(attachId);
|
||||
_entityMap.Add(entityId, pendingEntity);
|
||||
|
||||
if (hasAuthority)
|
||||
_entityList.Add(pendingEntity);
|
||||
_entityList.Add(pendingEntity);
|
||||
|
||||
hasCreated = false;
|
||||
|
||||
return pendingEntity;
|
||||
}
|
||||
|
||||
|
||||
var entity = new RagonEntity(entityType, sceneId);
|
||||
|
||||
|
||||
_entityMap.Add(entityId, entity);
|
||||
|
||||
|
||||
if (hasAuthority)
|
||||
_entityList.Add(entity);
|
||||
|
||||
hasCreated = true;
|
||||
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -217,7 +214,6 @@ public sealed class RagonEntityCache
|
||||
{
|
||||
if (_entityMap.TryGetValue(entityId, out var entity))
|
||||
{
|
||||
|
||||
_entityMap.Remove(entityId);
|
||||
_entityList.Remove(entity);
|
||||
|
||||
|
||||
@@ -51,9 +51,9 @@ namespace Ragon.Client
|
||||
Create(null, new RagonRoomParameters() {Scene = sceneName, Min = minPlayers, Max = maxPlayers});
|
||||
}
|
||||
|
||||
public void Create(string roomId, string sceneNa, int minPlayers, int maxPlayers)
|
||||
public void Create(string roomId, string sceneName, int minPlayers, int maxPlayers)
|
||||
{
|
||||
Create(roomId, new RagonRoomParameters() {Scene = sceneNa, Min = minPlayers, Max = maxPlayers});
|
||||
Create(roomId, new RagonRoomParameters() {Scene = sceneName, Min = minPlayers, Max = maxPlayers});
|
||||
}
|
||||
|
||||
public void Create(string roomId, RagonRoomParameters parameters)
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Ragon.Protocol
|
||||
public int ReadOffset => _read;
|
||||
public int WriteOffset => _write;
|
||||
public int Length => ((_write - 1) >> 3) + 1;
|
||||
public int Capacity => _write - _read;
|
||||
public int Capacity => _write - _read - 1;
|
||||
|
||||
public RagonBuffer(int capacity = 128)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ public class RagonPayload
|
||||
|
||||
public void Read(RagonBuffer buffer)
|
||||
{
|
||||
_size = buffer.Capacity - 1;
|
||||
_size = buffer.Capacity;
|
||||
buffer.ReadArray(_data, _size);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class RagonEvent
|
||||
|
||||
public void Read(RagonBuffer buffer)
|
||||
{
|
||||
_size = buffer.Capacity - 1;
|
||||
_size = buffer.Capacity;
|
||||
buffer.ReadArray(_data, _size);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Ragon.Server.Logging;
|
||||
|
||||
public interface IRagonLogger
|
||||
{
|
||||
public void Warning(string tag, string message);
|
||||
public void Info(string tag, string message);
|
||||
public void Error(string tag, string message);
|
||||
public void Trace(string tag, string message);
|
||||
}
|
||||
Reference in New Issue
Block a user