Exemplo n.º 1
0
        static void UploadWorld(Client client, Packet msg)
        {
            try
            {
                if (!client.LoggedIn)
                {
                    client.Send(new Packet(PacketCode.UploadWorld, PacketInfo.NotLoggedIn));
                    return;
                }

                uint id;
                do
                {
                    id = (uint)random.Next(int.MinValue, int.MaxValue);
                }while (DataBase.ExistsWorld(id));

                World world = msg.World;
                world.AllCompleted = false;
                world.AllPerfect   = false;
                world.ID           = id;
                world.Uploader     = client.UserID;
                world.UploadTime   = DateTime.Now;

                DataBase.AddWorld(id, world);

                client.Send(new Packet(PacketCode.UploadWorld, PacketInfo.Success, BitConverter.GetBytes(id)));
            }
            catch (Exception)
            {
                client.Send(new Packet(PacketCode.UploadWorld, PacketInfo.Error));
            }
        }