Example #1
0
    void LoadAndSendChunk(int x, int y, int z)
    {
        ClientSimple c   = server.clients[clientId];
        int          pos = MapUtilCi.Index2d(x, y, server.MapSizeX / ServerSimple.ChunkSize);

        if (c.chunksseen[pos] == null)
        {
            c.chunksseen[pos] = new bool[server.MapSizeZ / ServerSimple.ChunkSize];
        }
        c.chunksseen[pos][z] = true;

        int[] chunk = new int[32 * 32 * 32];

        for (int i = 0; i < server.modsCount; i++)
        {
            server.mods[i].GenerateChunk(x, y, z, chunk);
        }

        byte[] chunkBytes       = MiscCi.UshortArrayToByteArray(chunk, 32 * 32 * 32);
        IntRef compressedLength = new IntRef();

        byte[] chunkCompressed = server.platform.GzipCompress(chunkBytes, 32 * 32 * 32 * 2, compressedLength);

        server.QueueMainThreadAction(SendPacketAction.Create(server, clientId, ServerPackets.ChunkPart(chunkCompressed)));
        server.QueueMainThreadAction(SendPacketAction.Create(server, clientId, ServerPackets.Chunk_(x * ServerSimple.ChunkSize, y * ServerSimple.ChunkSize, z * ServerSimple.ChunkSize, ServerSimple.ChunkSize)));
    }
Example #2
0
    public static SendPacketAction Create(ServerSimple server_, int client_, Packet_Server packet_)
    {
        SendPacketAction a = new SendPacketAction();

        a.server = server_;
        a.client = client_;
        a.packet = packet_;
        return(a);
    }
 public static SendPacketAction Create(ServerSimple server_, int client_, Packet_Server packet_)
 {
     SendPacketAction a = new SendPacketAction();
     a.server = server_;
     a.client = client_;
     a.packet = packet_;
     return a;
 }