Esempio n. 1
0
        internal static void Init(IQueryAdapter dbClient)
        {
            dbClient.setQuery("SELECT userpeak FROM server_status");
            UserPeak = dbClient.getInteger();

            _runFrequency = int.Parse(FirewindEnvironment.GetConfig().GetEntry("backgroundworker.interval", "10000")); // leon is crazy, 300!?! (THIS IS MADNESS!!)
        }
Esempio n. 2
0
        internal void InitStream()
        {
            int StreamCount = 0;

            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT * FROM friend_stream ORDER BY id DESC LIMIT 15");
                DataTable dTable = dbClient.getTable();
                foreach (DataRow dRow in dTable.Rows)
                {
                    StreamCount = StreamCount + 1;
                }
                GetResponse().Init(3394);
                GetResponse().AppendInt32(StreamCount);
                foreach (DataRow dRow in dTable.Rows)
                {
                    dbClient.setQuery("SELECT id,username,look,gender,rank FROM users WHERE username='******' ORDER BY id DESC LIMIT 1");
                    DataTable mTable = dbClient.getTable();
                    foreach (DataRow xRow in mTable.Rows)
                    {
                        int    time     = TimeHelper.ago((string)dRow[5]);
                        string username = (string)dRow[1];
                        string Message  = (string)dRow[2];
                        GetResponse().AppendInt32((int)dRow[0]); // Message ID
                        if ((int)dRow[3] == 4)
                        {
                            GetResponse().AppendInt32(4);                          // User Sent
                            GetResponse().AppendString(Convert.ToString(dRow[0])); // String ID
                            GetResponse().AppendString((string)xRow[1]);
                            GetResponse().AppendString((string)xRow[3]);
                            GetResponse().AppendString(String.Format(FirewindEnvironment.GetConfig().GetEntry("game.friendstream.imagerurl", "http://yourhotel.com/stream-imager/{0}.gif"), (string)xRow[2])); // User-Image/Badge
                            GetResponse().AppendInt32(time);                                                                                                                                                   // Time
                            GetResponse().AppendInt32(3);
                            GetResponse().AppendInt32((int)dRow[4]);                                                                                                                                           // Likes
                            GetResponse().AppendBoolean(true);
                            GetResponse().AppendBoolean(true);
                            GetResponse().AppendBoolean(false);
                            Message = Message.Replace("{Official}", "");
                            GetResponse().AppendString(Message);     // Message
                        }
                        else if ((int)dRow[3] == 5)
                        {
                            GetResponse().AppendInt32(5);                          // User Sent
                            GetResponse().AppendString(Convert.ToString(dRow[0])); // String ID
                            GetResponse().AppendString((string)xRow[1]);
                            GetResponse().AppendString((string)xRow[3]);
                            GetResponse().AppendString(String.Format(FirewindEnvironment.GetConfig().GetEntry("game.friendstream.imagerurl", "http://yourhotel.com/stream-imager/{0}.gif"), (string)xRow[2])); // User-Image/Badge
                            GetResponse().AppendInt32(time);                                                                                                                                                   // Time
                            GetResponse().AppendInt32(0);
                            GetResponse().AppendInt32((int)dRow[4]);                                                                                                                                           // Likes
                            GetResponse().AppendBoolean(true);
                            GetResponse().AppendBoolean(true);
                            GetResponse().AppendBoolean(false);
                            GetResponse().AppendString(Message); // Message
                        }
                    }
                }
                SendResponse();
            }
        }
Esempio n. 3
0
        internal GameClientManager()
        {
            clients                 = new Dictionary <uint, GameClient>();
            clientsAddQueue         = new Queue();
            clientsToRemove         = new Queue();
            creditQueuee            = new Queue();
            pixelQueuee             = new Queue();
            badgeQueue              = new Queue();
            broadcastQueue          = new Queue();
            authorizedPacketSending = new Queue();
            timedOutConnections     = new Queue();
            usernameRegister        = new Hashtable();
            userIDRegister          = new Hashtable();

            usernameIdRegister = new Hashtable();
            idUsernameRegister = new Hashtable();

            Thread timeOutThread = new Thread(new ThreadStart(HandleTimeouts));

            timeOutThread.Start();

            pingInterval = int.Parse(FirewindEnvironment.GetConfig().data["client.ping.interval"]);

            if (FirewindEnvironment.GetConfig().data.ContainsKey("game.pixel.enabled"))
            {
                cyclePixelsEnabled = (FirewindEnvironment.GetConfig().data["game.pixel.enabled"] == "true");
                cyclePixelsAmount  = int.Parse(FirewindEnvironment.GetConfig().data["game.pixel.amount"]);
                cyclePixelsTime    = int.Parse(FirewindEnvironment.GetConfig().data["game.pixel.time"]) * 1000;
                pixelsOnLogin      = int.Parse(FirewindEnvironment.GetConfig().data["game.login.pixel.receiveamount"]);
            }
            else
            {
                cyclePixelsEnabled = false;
                cyclePixelsAmount  = 0;
                cyclePixelsTime    = 0;
                pixelsOnLogin      = 0;
            }

            if (FirewindEnvironment.GetConfig().data.ContainsKey("game.credits.enabled"))
            {
                cycleCreditsEnabled = (FirewindEnvironment.GetConfig().data["game.credits.enabled"] == "true");
                cycleCreditsAmount  = int.Parse(FirewindEnvironment.GetConfig().data["game.credits.amount"]);
                cycleCreditsTime    = int.Parse(FirewindEnvironment.GetConfig().data["game.credits.time"]) * 1000;
                creditsOnLogin      = int.Parse(FirewindEnvironment.GetConfig().data["game.login.credits.receiveamount"]);
            }
            else
            {
                cycleCreditsEnabled = false;
                cycleCreditsAmount  = 0;
                cycleCreditsTime    = 0;
                creditsOnLogin      = 0;
            }
        }
Esempio n. 4
0
        internal void SendToStream()
        {
            string MessageX = Request.ReadString();

            //int time = (TimeHelper.ago(DateTime.Now));
            DateTime timex = DateTime.Now;

            if (MessageX.StartsWith("{Official}"))
            {
                using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    //dbClient.runFastQuery("INSERT INTO friend_stream (user, text, type, likes, time) VALUES ('" + Session.GetHabbo().Username + "', '" + MessageX + "', '4', '0', '" + timex + "')");
                    dbClient.setQuery("INSERT INTO friend_stream (user, text, type, likes, time) VALUES (@username, @message, '4', '0', @time)");
                    dbClient.addParameter("username", Session.GetHabbo().Username);
                    dbClient.addParameter("message", MessageX);
                    dbClient.addParameter("time", timex);

                    dbClient.runQuery();
                }
            }
            else
            {
                using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("INSERT INTO friend_stream (user, text, type, likes, time) VALUES (@username, @message, '5', '0', @time)");
                    dbClient.addParameter("username", Session.GetHabbo().Username);
                    dbClient.addParameter("message", MessageX);
                    dbClient.addParameter("time", timex);

                    dbClient.runQuery();
                }
            }


            #region Reload Stream

            int StreamCount = 0;
            using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("SELECT * FROM friend_stream ORDER BY id DESC LIMIT 15");
                DataTable dTable = dbClient.getTable();
                foreach (DataRow dRow in dTable.Rows)
                {
                    StreamCount = StreamCount + 1;
                }
                GetResponse().Init(3394);
                GetResponse().AppendInt32(StreamCount);
                foreach (DataRow dRow in dTable.Rows)
                {
                    dbClient.setQuery("SELECT id,username,look,gender,rank FROM users WHERE username='******' ORDER BY id DESC LIMIT 1");
                    DataTable mTable = dbClient.getTable();
                    foreach (DataRow xRow in mTable.Rows)
                    {
                        int    time     = TimeHelper.ago((string)dRow[5]);
                        string username = (string)dRow[1];
                        string Message  = (string)dRow[2];
                        GetResponse().AppendInt32((int)dRow[0]); // Message ID
                        if ((int)dRow[3] == 4)
                        {
                            GetResponse().AppendInt32(4);                          // User Sent
                            GetResponse().AppendString(Convert.ToString(dRow[0])); // String ID
                            GetResponse().AppendString((string)xRow[1]);
                            GetResponse().AppendString((string)xRow[3]);
                            GetResponse().AppendString(String.Format(FirewindEnvironment.GetConfig().GetEntry("game.friendstream.imagerurl", "http://yourhotel.com/stream-imager/{0}.gif"), (string)xRow[2])); // User-Image/Badge
                            GetResponse().AppendInt32(time);                                                                                                                                                   // Time
                            GetResponse().AppendInt32(3);
                            GetResponse().AppendInt32((int)dRow[4]);                                                                                                                                           // Likes
                            GetResponse().AppendBoolean(true);
                            GetResponse().AppendBoolean(true);
                            GetResponse().AppendBoolean(false);
                            Message = Message.Replace("{Official}", "");
                            GetResponse().AppendString(Message); // Message
                        }
                        else if ((int)dRow[3] == 5)
                        {
                            GetResponse().AppendInt32(5);                          // User Sent
                            GetResponse().AppendString(Convert.ToString(dRow[0])); // String ID
                            GetResponse().AppendString((string)xRow[1]);
                            GetResponse().AppendString((string)xRow[3]);
                            GetResponse().AppendString(String.Format(FirewindEnvironment.GetConfig().GetEntry("game.friendstream.imagerurl", "http://yourhotel.com/stream-imager/{0}.gif"), (string)xRow[2])); // User-Image/Badge
                            GetResponse().AppendInt32(time);                                                                                                                                                   // Time
                            GetResponse().AppendInt32(0);
                            GetResponse().AppendInt32((int)dRow[4]);                                                                                                                                           // Likes
                            GetResponse().AppendBoolean(true);
                            GetResponse().AppendBoolean(true);
                            GetResponse().AppendBoolean(false);
                            GetResponse().AppendString(Message); // Message
                        }
                    }
                }
                SendResponse();
            }
            #endregion
        }