Block when sending initial chunks
This commit is contained in:
parent
444a3f47ed
commit
c5c0e5ddf4
@ -30,16 +30,9 @@ namespace TrueCraft.Core.TerrainGen
|
||||
bool EnableCaves;
|
||||
private const int GroundLevel = 50;
|
||||
|
||||
public StandardGenerator(TrueCraft.Core.World.World world) : this()
|
||||
public StandardGenerator(IWorld world)
|
||||
{
|
||||
// TODO: Do we want to do anything with that world?
|
||||
}
|
||||
|
||||
public StandardGenerator(bool singleBiome = false, bool enableCaves = true, byte generateBiome = (byte)Biome.Plains)
|
||||
{
|
||||
SingleBiome = singleBiome;
|
||||
GenerationBiome = generateBiome;
|
||||
EnableCaves = enableCaves;
|
||||
EnableCaves = true;
|
||||
|
||||
CaveNoise.Octaves = 3;
|
||||
CaveNoise.Amplitude = 0.05;
|
||||
|
@ -59,8 +59,7 @@ namespace TrueCraft.Handlers
|
||||
|
||||
// Send setup packets
|
||||
remoteClient.QueuePacket(new LoginResponsePacket(client.Entity.EntityID, 0, Dimension.Overworld));
|
||||
server.Scheduler.ScheduleEvent("client.update-chunks", remoteClient,
|
||||
TimeSpan.Zero, s => remoteClient.UpdateChunks());
|
||||
remoteClient.UpdateChunks(block: true);
|
||||
remoteClient.QueuePacket(new WindowItemsPacket(0, remoteClient.Inventory.GetSlots()));
|
||||
remoteClient.QueuePacket(new UpdateHealthPacket((remoteClient.Entity as PlayerEntity).Health));
|
||||
remoteClient.QueuePacket(new SpawnPositionPacket((int)remoteClient.Entity.Position.X,
|
||||
|
@ -413,7 +413,7 @@ namespace TrueCraft
|
||||
server.Scheduler.ScheduleEvent("remote.keepalive", this, TimeSpan.FromSeconds(10), SendKeepAlive);
|
||||
}
|
||||
|
||||
internal void UpdateChunks()
|
||||
internal void UpdateChunks(bool block = false)
|
||||
{
|
||||
var newChunks = new HashSet<Coordinates2D>();
|
||||
var toLoad = new List<Tuple<Coordinates2D, IChunk>>();
|
||||
@ -428,11 +428,11 @@ namespace TrueCraft
|
||||
newChunks.Add(coords);
|
||||
if (!LoadedChunks.Contains(coords))
|
||||
toLoad.Add(new Tuple<Coordinates2D, IChunk>(
|
||||
coords, World.GetChunk(coords, generate: false)));
|
||||
coords, World.GetChunk(coords, generate: block)));
|
||||
}
|
||||
}
|
||||
Profiler.Done();
|
||||
Task.Factory.StartNew(() =>
|
||||
var encode = new Action(() =>
|
||||
{
|
||||
Profiler.Start("client.encode-chunks");
|
||||
foreach (var tup in toLoad)
|
||||
@ -446,6 +446,10 @@ namespace TrueCraft
|
||||
}
|
||||
Profiler.Done();
|
||||
});
|
||||
if (block)
|
||||
encode();
|
||||
else
|
||||
Task.Factory.StartNew(encode);
|
||||
Profiler.Start("client.old-chunks");
|
||||
LoadedChunks.IntersectWith(newChunks);
|
||||
Profiler.Done();
|
||||
|
Loading…
x
Reference in New Issue
Block a user