public override void HandleRequest(Session.Receive request) { var req = request.Read <int[]>(); var chunkPos = new Int3(req[1], req[2], req[3]); var world = ChunkService.Worlds.Get((uint)req[0]); ChunkService.TaskDispatcher.Add( new World.World.ResetChunkTask(RequestExtractChunkContent(request, chunkPos, world)) ); }
private static Chunk RequestExtractChunkContent(Session.Receive request, Int3 chunkPos, World.World world) { var cow = request.ReadUInt32(); if (cow != uint.MaxValue) { return(new Chunk(chunkPos, world, cow)); } var data = GetCache(); request.Read(data, 0, data.Length); return(DeserializeChunk(chunkPos, world, data)); }
public override void HandleRequest(Session.Receive stream) { var request = stream.Read <int[]>(); var chunk = GetChunk((uint)request[0], new Int3(request[1], request[2], request[3])); using (var message = stream.Session.CreateMessage(Id)) { message.WriteObject(request); var cow = chunk.CopyOnWrite; message.Write(cow); if (cow == uint.MaxValue) { var chunkData = Get(chunk); message.Write(chunkData, 0, chunkData.Length); } } }