예제 #1
0
        static void PrintWorlds()
        {
            int count = 0;

            foreach (uint id in DataBase.GetWorldIDs())
            {
                World world = DataBase.GetWorld(id) ?? new World();

                Console.WriteLine($"World {++count}:");
                Console.WriteLine($"  ID:         {world.ID.ToID().ToUpper()}");
                Console.WriteLine($"  Uploader:   {world.Uploader.ToID().ToUpper()}");
                Console.WriteLine($"  UploadTime: {world.UploadTime}");
                Console.WriteLine($"  Levels:     {world.Levels.Count}");
                Console.WriteLine($"  Title:      {world.Title}");
            }
        }
예제 #2
0
        static void GetIDs(Client client, Packet msg)
        {
            try
            {
                int count = BitConverter.ToInt32(msg.Bytes, 0);

                // Get random IDs
                List <uint> ids = DataBase.GetWorldIDs().OrderBy(x => random.Next()).Take(count).ToList();

                List <byte> bytes = new List <byte>();
                bytes.AddRange(BitConverter.GetBytes(ids.Count));

                foreach (uint id in ids)
                {
                    bytes.AddRange(BitConverter.GetBytes(id));
                }

                client.Send(new Packet(PacketCode.GetIDs, PacketInfo.Success, bytes.ToArray()));
            }
            catch (Exception)
            {
                client.Send(new Packet(PacketCode.GetIDs, PacketInfo.Error));
            }
        }