Fix bug with ghost players spawning
This occurred because of some weird Mono bug with reused sockets, and with the client's pending updates not occuring. Dunno.
This commit is contained in:
parent
3fcdf2062e
commit
4d5509b734
@ -39,7 +39,7 @@ namespace TrueCraft.Core.TerrainGen.Decorators
|
||||
if (Noise.Value2D(BlockX, BlockZ) > 0.3)
|
||||
{
|
||||
Coordinates3D location = new Coordinates3D(X, Height, Z);
|
||||
if (chunk.GetBlockID(location).Equals(GrassBlock.BlockID))
|
||||
if (chunk.GetBlockID(location) == GrassBlock.BlockID || chunk.GetBlockID(location) == SnowfallBlock.BlockID)
|
||||
{
|
||||
var Chance = ChanceNoise.Value2D(BlockX, BlockZ);
|
||||
var OakNoise = ChanceNoise.Value2D(BlockX * 0.6, BlockZ * 0.6);
|
||||
|
@ -166,7 +166,7 @@ namespace TrueCraft
|
||||
|
||||
private IEntity[] GetEntitiesInRange(IEntity entity, int maxChunks)
|
||||
{
|
||||
return Entities.Where(e => e != entity && IsInRange(e.Position, entity.Position, maxChunks)).ToArray();
|
||||
return Entities.Where(e => e.EntityID != entity.EntityID && !e.Despawned && IsInRange(e.Position, entity.Position, maxChunks)).ToArray();
|
||||
}
|
||||
|
||||
private void SendEntityToClient(RemoteClient client, IEntity entity)
|
||||
@ -213,7 +213,7 @@ namespace TrueCraft
|
||||
|
||||
public IList<IEntity> EntitiesInRange(Vector3 center, float radius)
|
||||
{
|
||||
return Entities.Where(e => e.Position.DistanceTo(center) < radius).ToList();
|
||||
return Entities.Where(e => !e.Despawned && e.Position.DistanceTo(center) < radius).ToList();
|
||||
}
|
||||
|
||||
public IList<IRemoteClient> ClientsForEntity(IEntity entity)
|
||||
@ -247,8 +247,8 @@ namespace TrueCraft
|
||||
|
||||
public void DespawnEntity(IEntity entity)
|
||||
{
|
||||
PendingDespawns.Add(entity);
|
||||
entity.Despawned = true;
|
||||
PendingDespawns.Add(entity);
|
||||
}
|
||||
|
||||
public void FlushDespawns()
|
||||
@ -274,9 +274,7 @@ namespace TrueCraft
|
||||
}
|
||||
}
|
||||
lock (EntityLock)
|
||||
{
|
||||
Entities.Remove(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,8 @@ namespace TrueCraft
|
||||
}
|
||||
if (client.Disconnected)
|
||||
{
|
||||
Clients.RemoveAt(i);
|
||||
lock (ClientLock)
|
||||
Clients.RemoveAt(i);
|
||||
break;
|
||||
}
|
||||
const long maxTicks = 100000 * 200; // 200ms
|
||||
|
@ -152,6 +152,8 @@ namespace TrueCraft
|
||||
|
||||
internal void ExpandChunkRadius(IMultiplayerServer server)
|
||||
{
|
||||
if (this.Disconnected)
|
||||
return;
|
||||
if (ChunkRadius < 16) // TODO: Allow customization of this number
|
||||
{
|
||||
ChunkRadius++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user