Exemplo n.º 1
0
        /// <summary>
        ///     Closes all.
        /// </summary>
        internal void CloseAll()
        {
            YupiWriterManager.WriteLine("Saving Inventary Content....", "Yupi.Boot", ConsoleColor.DarkCyan);

            foreach (GameClient current2 in Clients.Values.Where(current2 => current2.GetHabbo() != null))
            {
                current2.GetHabbo().GetInventoryComponent().RunDbUpdate();

                current2.GetHabbo().RunDbUpdate();
            }

            YupiWriterManager.WriteLine("Inventary Content Saved!", "Yupi.Boot", ConsoleColor.DarkCyan);

            try
            {
                YupiWriterManager.WriteLine("Closing Connection YupiDatabaseManager...", "Yupi.Boot", ConsoleColor.DarkMagenta);

                foreach (GameClient current3 in Clients.Values.Where(current3 => current3.GetConnection() != null))
                {
                    current3.GetConnection().Dispose();

                    Console.ForegroundColor = ConsoleColor.DarkMagenta;

                    YupiWriterManager.WriteLine("Connection YupiDatabaseManager Closed!", "Yupi.Boot", ConsoleColor.DarkMagenta);
                }
            }
            catch (Exception ex)
            {
                YupiLogManager.LogCriticalException(ex, "Failed Closing Connection YupiDatabaseManager.");
            }

            Clients.Clear();

            YupiWriterManager.WriteLine("Connections closed", "Yupi.Conn", ConsoleColor.DarkYellow);
        }
Exemplo n.º 2
0
        private static string GetRsaStringEncrypted(string message)
        {
            try
            {
                byte[] m = Encoding.Default.GetBytes(message);
                byte[] c = Rsa.Sign(m);

                return(Converter.BytesToHexString(c));
            }
            catch (Exception e)
            {
                YupiLogManager.LogCriticalException(e, "Encryption System Crashed.", "Yupi.Users");

                return(null);
            }
        }
Exemplo n.º 3
0
        public static BigInteger CalculateDiffieHellmanSharedKey(string publicKey)
        {
            try
            {
                byte[] bytes     = BigInteger.Parse('0' + publicKey, NumberStyles.HexNumber).ToByteArray();
                byte[] keyBytes  = Rsa.Verify(bytes);
                string keyString = Encoding.Default.GetString(keyBytes);

                return(DiffieHellman.CalculateSharedKey(BigInteger.Parse(keyString)));
            }
            catch (Exception e)
            {
                YupiLogManager.LogCriticalException(e, "Encryption System Crashed.", "Yupi.Users");

                return(0);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Mains the game loop.
        /// </summary>
        private void MainGameLoop()
        {
            while (GameLoopActiveExt)
            {
                try
                {
                    ServerCpuLowPriorityWorker.Process();

                    RoomManagerCycleEnded   = false;
                    ClientManagerCycleEnded = false;

                    GetRoomManager().OnCycle();
                    GetClientManager().OnCycle();
                }
                catch (Exception ex)
                {
                    YupiLogManager.LogCriticalException(ex, "Registered HabboHotel Loop Exception.", "Yupi.Users");
                }

                Thread.Sleep(GameLoopSleepTimeExt);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="RoomModel" /> class.
        /// </summary>
        /// <param name="doorX">The door x.</param>
        /// <param name="doorY">The door y.</param>
        /// <param name="doorZ">The door z.</param>
        /// <param name="doorOrientation">The door orientation.</param>
        /// <param name="heightmap">The heightmap.</param>
        /// <param name="staticFurniMap">The static furni map.</param>
        /// <param name="clubOnly">if set to <c>true</c> [club only].</param>
        /// <param name="poolmap">The poolmap.</param>
        internal RoomModel(int doorX, int doorY, double doorZ, int doorOrientation, string heightmap,
                           string staticFurniMap, bool clubOnly, string poolmap)
        {
            try
            {
                DoorX           = doorX;
                DoorY           = doorY;
                DoorZ           = doorZ;
                DoorOrientation = doorOrientation;
                Heightmap       = heightmap.ToLower();
                StaticFurniMap  = staticFurniMap;

                GotPublicPool = !string.IsNullOrEmpty(poolmap);

                heightmap = heightmap.Replace($"{Convert.ToChar(10)}", string.Empty);

                string[] array = heightmap.Split(Convert.ToChar(13));

                MapSizeX = array[0].Length;
                MapSizeY = array.Length;
                ClubOnly = clubOnly;

                SqState = new SquareState[MapSizeX][];

                for (int i = 0; i < MapSizeX; i++)
                {
                    SqState[i] = new SquareState[MapSizeY];
                }

                SqFloorHeight = new short[MapSizeX][];

                for (int i = 0; i < MapSizeX; i++)
                {
                    SqFloorHeight[i] = new short[MapSizeY];
                }

                SqSeatRot = new byte[MapSizeX][];

                for (int i = 0; i < MapSizeX; i++)
                {
                    SqSeatRot[i] = new byte[MapSizeY];
                }

                SqChar = new char[MapSizeX][];

                for (int i = 0; i < MapSizeX; i++)
                {
                    SqChar[i] = new char[MapSizeY];
                }

                if (GotPublicPool)
                {
                    MRoomModelfx = new byte[MapSizeX][];

                    for (int i = 0; i < MapSizeX; i++)
                    {
                        MRoomModelfx[i] = new byte[MapSizeY];
                    }
                }

                for (int y = 0; y < MapSizeY; y++)
                {
                    string text2 = array[y].Replace($"{Convert.ToChar(13)}", string.Empty)
                                   .Replace($"{Convert.ToChar(10)}", string.Empty);

                    for (int x = 0; x < MapSizeX; x++)
                    {
                        char c = 'x';

                        if (x < text2.Length)
                        {
                            c = text2[x];
                        }

                        if (x == doorX && y == doorY)
                        {
                            SqFloorHeight[x][y] = (short)DoorZ;
                            SqState[x][y]       = SquareState.Open;

                            if (SqFloorHeight[x][y] > 9)
                            {
                                SqChar[x][y] = Letters[SqFloorHeight[x][y] - 10];
                            }
                            else
                            {
                                SqChar[x][y] = char.Parse(DoorZ.ToString(CultureInfo.InvariantCulture));
                            }
                        }
                        else
                        {
                            if (c.Equals('x'))
                            {
                                SqFloorHeight[x][y] = -1;
                                SqState[x][y]       = SquareState.Blocked;
                                SqChar[x][y]        = c;
                            }
                            else if (char.IsLetterOrDigit(c))
                            {
                                SqFloorHeight[x][y] = char.IsDigit(c)
                                    ? short.Parse(c.ToString())
                                    : Convert.ToInt16(Letters.IndexOf(char.ToLower(c)) + 10);
                                SqState[x][y] = SquareState.Open;
                                SqChar[x][y]  = c;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                YupiLogManager.LogCriticalException(e, "Registered Room Serialization Exception.");
            }
        }