示例#1
0
        /// <summary>
        ///     Adds the subscription.
        /// </summary>
        /// <param name="dayLength">Length of the day.</param>
        internal void AddSubscription(double dayLength)
        {
            int num = (int)Math.Round(dayLength);

            GameClient clientByUserId = Yupi.GetGame().GetClientManager().GetClientByUserId(_userId);
            DateTime   target;
            int        num2;
            int        num3;

            if (_subscription != null)
            {
                target = Yupi.UnixToDateTime(_subscription.ExpireTime).AddDays(num);
                num2   = _subscription.ActivateTime;
                num3   = _subscription.LastGiftTime;
            }
            else
            {
                target = DateTime.Now.AddDays(num);
                num2   = Yupi.GetUnixTimeStamp();
                num3   = Yupi.GetUnixTimeStamp();
            }

            int num4 = Yupi.DateTimeToUnix(target);

            _subscription = new Subscription(2, num2, num4, num3);

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                queryReactor.RunFastQuery(string.Concat("REPLACE INTO users_subscriptions VALUES (", _userId, ", 2, ",
                                                        num2, ", ", num4, ", ", num3, ");"));

            clientByUserId.GetHabbo().SerializeClub();
            Yupi.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(clientByUserId);
        }
示例#2
0
        /// <summary>
        ///     Generates the pet from row.
        /// </summary>
        /// <param name="row">The row.</param>
        /// <param name="mRow">The m row.</param>
        /// <returns>Pet.</returns>
        internal static Pet GeneratePetFromRow(DataRow row, DataRow mRow)
        {
            MoplaBreed moplaBreed = null;

            if (Convert.ToUInt32(mRow["type"]) == 16u)
            {
                using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                {
                    queryReactor.SetQuery($"SELECT * FROM pets_plants WHERE pet_id = {Convert.ToUInt32(row["id"])}");

                    DataRow sRow = queryReactor.GetRow();

                    moplaBreed = new MoplaBreed(sRow);
                }
            }

            return(new Pet(Convert.ToUInt32(row["id"]), Convert.ToUInt32(row["user_id"]),
                           Convert.ToUInt32(row["room_id"]), (string)row["name"], Convert.ToUInt32(mRow["type"]),
                           (string)mRow["race"], (string)mRow["color"], (int)mRow["experience"], (int)mRow["energy"],
                           (int)mRow["nutrition"], (int)mRow["respect"], Convert.ToDouble(mRow["createstamp"]), (int)row["x"],
                           (int)row["y"], Convert.ToDouble(row["z"]), (int)mRow["have_saddle"] == 1, (int)mRow["anyone_ride"],
                           (int)mRow["hairdye"], (int)mRow["pethair"], (int)mRow["rarity"],
                           Yupi.UnixToDateTime((int)mRow["lasthealth_stamp"]),
                           Yupi.UnixToDateTime((int)mRow["untilgrown_stamp"]), moplaBreed));
        }
示例#3
0
        /// <summary>
        /// Determines whether this instance can talk the specified session.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="message">The message.</param>
        /// <returns><c>true</c> if this instance can talk the specified session; otherwise, <c>false</c>.</returns>
        internal static bool CanTalk(GameClient session, string message)
        {
            if (CheckForBannedPhrases(message) && session.GetHabbo().Rank < 4)
            {
                if (!Yupi.MutedUsersByFilter.ContainsKey(session.GetHabbo().Id))
                {
                    session.GetHabbo().BobbaFiltered++;
                }

                if (session.GetHabbo().BobbaFiltered < 3)
                {
                    session.SendNotif("Your language is inappropriate. If you do not change this , measures are being taken by the automated system of Habbo.");
                }
                else if (session.GetHabbo().BobbaFiltered >= 3)
                {
                    if (session.GetHabbo().BobbaFiltered == 3)
                    {
                        session.GetHabbo().BobbaFiltered = 4;
                        Yupi.MutedUsersByFilter.Add(session.GetHabbo().Id, uint.Parse((Yupi.GetUnixTimeStamp() + 300 * 60).ToString()));

                        return(false);
                    }

                    if (session.GetHabbo().BobbaFiltered == 4)
                    {
                        session.SendNotif("Now you can not talk for 5 minutes . This is because your exhibits inappropriate language in Habbo Hotel.");
                    }
                    else if (session.GetHabbo().BobbaFiltered == 5)
                    {
                        session.SendNotif("You risk a ban if you continue to scold it . This is your last warning");
                    }
                    else if (session.GetHabbo().BobbaFiltered >= 7)
                    {
                        session.GetHabbo().BobbaFiltered = 0;

                        Yupi.GetGame().GetBanManager().BanUser(session, "Auto-system-ban", 3600, "ban.", false, false);
                    }
                }
            }

            if (Yupi.MutedUsersByFilter.ContainsKey(session.GetHabbo().Id))
            {
                if (Yupi.MutedUsersByFilter[session.GetHabbo().Id] < Yupi.GetUnixTimeStamp())
                {
                    Yupi.MutedUsersByFilter.Remove(session.GetHabbo().Id);
                }
                else
                {
                    DateTime now             = DateTime.Now;
                    TimeSpan timeStillBanned = now - Yupi.UnixToDateTime(Yupi.MutedUsersByFilter[session.GetHabbo().Id]);

                    session.SendNotif("Damn! you can't talk for " + timeStillBanned.Minutes.ToString().Replace("-", "") + " minutes and " + timeStillBanned.Seconds.ToString().Replace("-", "") + " seconds.");
                    return(false);
                }
            }

            return(true);
        }
示例#4
0
        /// <summary>
        ///     Serializes the user information.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <returns>ServerMessage.</returns>
        /// <exception cref="System.NullReferenceException">User not found in database.</exception>
        internal static ServerMessage SerializeUserInfo(uint userId)
        {
            ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ModerationToolUserToolMessageComposer"));

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                if (queryReactor != null)
                {
                    queryReactor.SetQuery(
                        "SELECT id, username, mail, look, trade_lock, trade_lock_expire, rank, ip_last, " +
                        "IFNULL(cfhs, 0) cfhs, IFNULL(cfhs_abusive, 0) cfhs_abusive, IFNULL(cautions, 0) cautions, IFNULL(bans, 0) bans, " +
                        "IFNULL(reg_timestamp, 0) reg_timestamp, IFNULL(login_timestamp, 0) login_timestamp " +
                        $"FROM users left join users_info on (users.id = users_info.user_id) WHERE id = '{userId}' LIMIT 1"
                        );

                    DataRow row = queryReactor.GetRow();

                    uint id = Convert.ToUInt32(row["id"]);
                    serverMessage.AppendInteger(id);
                    serverMessage.AppendString(row["username"].ToString());
                    serverMessage.AppendString(row["look"].ToString());
                    double regTimestamp   = (double)row["reg_timestamp"];
                    double loginTimestamp = (double)row["login_timestamp"];
                    int    unixTimestamp  = Yupi.GetUnixTimeStamp();
                    serverMessage.AppendInteger(
                        (int)(regTimestamp > 0 ? Math.Ceiling((unixTimestamp - regTimestamp) / 60.0) : regTimestamp));
                    serverMessage.AppendInteger(
                        (int)
                        (loginTimestamp > 0 ? Math.Ceiling((unixTimestamp - loginTimestamp) / 60.0) : loginTimestamp));
                    serverMessage.AppendBool(true);
                    serverMessage.AppendInteger(Convert.ToInt32(row["cfhs"]));
                    serverMessage.AppendInteger(Convert.ToInt32(row["cfhs_abusive"]));
                    serverMessage.AppendInteger(Convert.ToInt32(row["cautions"]));
                    serverMessage.AppendInteger(Convert.ToInt32(row["bans"]));

                    serverMessage.AppendInteger(0);
                    uint rank = (uint)row["rank"];
                    serverMessage.AppendString(row["trade_lock"].ToString() == "1"
                        ? Yupi.UnixToDateTime(int.Parse(row["trade_lock_expire"].ToString())).ToLongDateString()
                        : "Not trade-locked");
                    serverMessage.AppendString(rank < 6 ? row["ip_last"].ToString() : "127.0.0.1");
                    serverMessage.AppendInteger(id);
                    serverMessage.AppendInteger(0);

                    serverMessage.AppendString($"E-Mail:         {row["mail"]}");
                    serverMessage.AppendString($"Rank ID:        {rank}");
                }
            }
            return(serverMessage);
        }
示例#5
0
        /// <summary>
        ///     Composes the club purchase page.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="windowId">The window identifier.</param>
        /// <returns>ServerMessage.</returns>
        internal static ServerMessage ComposeClubPurchasePage(GameClient session, int windowId)
        {
            ServerMessage      message        = new ServerMessage(LibraryParser.OutgoingRequest("CatalogueClubPageMessageComposer"));
            List <CatalogItem> habboClubItems = Yupi.GetGame().GetCatalogManager().HabboClubItems;

            message.AppendInteger(habboClubItems.Count);

            foreach (CatalogItem item in habboClubItems)
            {
                message.AppendInteger(item.Id);
                message.AppendString(item.Name);
                message.AppendBool(false);
                message.AppendInteger(item.CreditsCost);

                if (item.DiamondsCost > 0)
                {
                    message.AppendInteger(item.DiamondsCost);
                    message.AppendInteger(105);
                }
                else
                {
                    message.AppendInteger(item.DucketsCost);
                    message.AppendInteger(0);
                }

                message.AppendBool(true);
                string[] fuckingArray = item.Name.Split('_');
                double   dayTime      = 31;

                if (item.Name.Contains("DAY"))
                {
                    dayTime = int.Parse(fuckingArray[3]);
                }
                else if (item.Name.Contains("MONTH"))
                {
                    int monthTime = int.Parse(fuckingArray[3]);
                    dayTime = monthTime * 31;
                }
                else if (item.Name.Contains("YEAR"))
                {
                    int yearTimeOmg = int.Parse(fuckingArray[3]);
                    dayTime = yearTimeOmg * 31 * 12;
                }

                DateTime newExpiryDate = DateTime.Now.AddDays(dayTime);

                if (session.GetHabbo().GetSubscriptionManager().HasSubscription)
                {
                    newExpiryDate =
                        Yupi.UnixToDateTime(session.GetHabbo().GetSubscriptionManager().GetSubscription().ExpireTime)
                        .AddDays(dayTime);
                }

                message.AppendInteger((int)dayTime / 31);
                message.AppendInteger((int)dayTime);
                message.AppendBool(false);
                message.AppendInteger((int)dayTime);
                message.AppendInteger(newExpiryDate.Year);
                message.AppendInteger(newExpiryDate.Month);
                message.AppendInteger(newExpiryDate.Day);
            }

            message.AppendInteger(windowId);
            return(message);
        }
示例#6
0
        /// <summary>
        ///     Serializes the user chatlog.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <returns>ServerMessage.</returns>
        internal static ServerMessage SerializeUserChatlog(uint userId)
        {
            ServerMessage result;

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery(
                    $"SELECT DISTINCT room_id FROM users_chatlogs WHERE user_id = '{userId}' ORDER BY timestamp DESC LIMIT 4");
                DataTable     table         = queryReactor.GetTable();
                ServerMessage serverMessage =
                    new ServerMessage(LibraryParser.OutgoingRequest("ModerationToolUserChatlogMessageComposer"));
                serverMessage.AppendInteger(userId);
                serverMessage.AppendString(Yupi.GetGame().GetClientManager().GetNameById(userId));

                if (table != null)
                {
                    serverMessage.AppendInteger(table.Rows.Count);
                    IEnumerator enumerator = table.Rows.GetEnumerator();

                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            DataRow dataRow = (DataRow)enumerator.Current;

                            queryReactor.SetQuery(
                                $"SELECT user_id,timestamp,message FROM users_chatlogs WHERE room_id = {dataRow["room_id"]} AND user_id = {userId} ORDER BY timestamp DESC LIMIT 30");

                            DataTable table2   = queryReactor.GetTable();
                            RoomData  roomData = Yupi.GetGame().GetRoomManager().GenerateRoomData((uint)dataRow["room_id"]);

                            if (table2 != null)
                            {
                                serverMessage.AppendByte(1);
                                serverMessage.AppendShort(2);
                                serverMessage.AppendString("roomName");
                                serverMessage.AppendByte(2);
                                serverMessage.AppendString(roomData == null ? "This room was deleted" : roomData.Name);
                                serverMessage.AppendString("roomId");
                                serverMessage.AppendByte(1);
                                serverMessage.AppendInteger((uint)dataRow["room_id"]);
                                serverMessage.AppendShort(table2.Rows.Count);
                                IEnumerator enumerator2 = table2.Rows.GetEnumerator();
                                try
                                {
                                    while (enumerator2.MoveNext())
                                    {
                                        DataRow dataRow2 = (DataRow)enumerator2.Current;

                                        Habbo habboForId = Yupi.GetHabboById((uint)dataRow2["user_id"]);
                                        Yupi.UnixToDateTime((double)dataRow2["timestamp"]);

                                        if (habboForId == null)
                                        {
                                            return(null);
                                        }

                                        serverMessage.AppendInteger(
                                            (int)(Yupi.GetUnixTimeStamp() - (double)dataRow2["timestamp"]));

                                        serverMessage.AppendInteger(habboForId.Id);
                                        serverMessage.AppendString(habboForId.UserName);
                                        serverMessage.AppendString(dataRow2["message"].ToString());
                                        serverMessage.AppendBool(false);
                                    }
                                    continue;
                                }
                                finally
                                {
                                    IDisposable disposable = enumerator2 as IDisposable;

                                    disposable?.Dispose();
                                }
                            }

                            serverMessage.AppendByte(1);
                            serverMessage.AppendShort(0);
                            serverMessage.AppendShort(0);
                        }

                        result = serverMessage;
                        return(result);
                    }
                    finally
                    {
                        IDisposable disposable2 = enumerator as IDisposable;

                        disposable2?.Dispose();
                    }
                }

                serverMessage.AppendInteger(0);
                result = serverMessage;
            }
            return(result);
        }
示例#7
0
        /// <summary>
        ///     Fills the specified row.
        /// </summary>
        /// <param name="row">The row.</param>
        internal void Fill(DataRow row)
        {
            try
            {
                Id          = (uint)row["id"];
                Name        = (string)row["caption"];
                PassWord    = (string)row["password"];
                Description = (string)row["description"];
                Type        = (string)row["roomtype"];
                Owner       = string.Empty;
                OwnerId     = (uint)row["owner"];
                RoomChat    = new ConcurrentStack <Chatlog>();
                WordFilter  = new List <string>();

                using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                {
                    queryReactor.SetQuery("SELECT username FROM users WHERE id = @userId");
                    queryReactor.AddParameter("userId", OwnerId);

                    Owner = queryReactor.GetString();

                    queryReactor.SetQuery($"SELECT user_id, message, timestamp FROM users_chatlogs WHERE room_id = '{Id}' ORDER BY timestamp ASC LIMIT 150");
                    DataTable table = queryReactor.GetTable();

                    foreach (DataRow dataRow in table.Rows)
                    {
                        RoomChat.Push(new Chatlog((uint)dataRow[0], (string)dataRow[1], Yupi.UnixToDateTime(int.Parse(dataRow[2].ToString())), false));
                    }

                    queryReactor.SetQuery($"SELECT word FROM rooms_wordfilter WHERE room_id = '{Id}'");
                    DataTable tableFilter = queryReactor.GetTable();

                    foreach (DataRow dataRow in tableFilter.Rows)
                    {
                        WordFilter.Add(dataRow["word"].ToString());
                    }
                }

                string roomState = row["state"].ToString().ToLower();

                switch (roomState)
                {
                case "locked":
                    State = 1;
                    break;

                case "password":
                    State = 2;
                    break;

                default:
                    State = 0;
                    break;
                }

                ModelName = (string)row["model_name"];
                WallPaper = (string)row["wallpaper"];
                Floor     = (string)row["floor"];
                LandScape = (string)row["landscape"];
                CcTs      = (string)row["public_ccts"];

                int.TryParse(row["trade_state"].ToString(), out TradeState);
                int.TryParse(row["category"].ToString(), out Category);
                int.TryParse(row["walls_height"].ToString(), out WallHeight);
                int.TryParse(row["score"].ToString(), out Score);
                int.TryParse(row["floorthick"].ToString(), out FloorThickness);
                int.TryParse(row["wallthick"].ToString(), out WallThickness);
                int.TryParse(row["chat_type"].ToString(), out ChatType);
                int.TryParse(row["game_id"].ToString(), out GameId);
                int.TryParse(row["mute_settings"].ToString(), out WhoCanMute);
                int.TryParse(row["kick_settings"].ToString(), out WhoCanKick);
                int.TryParse(row["ban_settings"].ToString(), out WhoCanBan);

                uint.TryParse(row["users_now"].ToString(), out UsersNow);
                uint.TryParse(row["users_max"].ToString(), out UsersMax);
                uint.TryParse(row["group_id"].ToString(), out GroupId);
                uint.TryParse(row["chat_balloon"].ToString(), out ChatBalloon);
                uint.TryParse(row["chat_speed"].ToString(), out ChatSpeed);
                uint.TryParse(row["chat_max_distance"].ToString(), out ChatMaxDistance);
                uint.TryParse(row["chat_flood_protection"].ToString(), out ChatFloodProtection);

                AllowPets        = Yupi.EnumToBool(row["allow_pets"].ToString());
                AllowPetsEating  = Yupi.EnumToBool(row["allow_pets_eat"].ToString());
                AllowWalkThrough = Yupi.EnumToBool(row["allow_walkthrough"].ToString());
                HideWall         = Yupi.EnumToBool(row["hidewall"].ToString());

                AllowRightsOverride = false;

                Group             = Yupi.GetGame().GetGroupManager().GetGroup(GroupId);
                Event             = Yupi.GetGame().GetRoomEvents().GetEvent(Id);
                _model            = Yupi.GetGame().GetRoomManager().GetModel(ModelName, Id);
                CompetitionStatus = 0;

                Tags = new List <string>();

                if (row.IsNull("tags") || string.IsNullOrEmpty(row["tags"].ToString()))
                {
                    return;
                }

                foreach (string item in row["tags"].ToString().Split(','))
                {
                    Tags.Add(item);
                }
            }
            catch (Exception ex)
            {
                ServerLogManager.LogException("Exception on RoomData Loading (Fill Void): " + ex);
                ServerLogManager.HandleException(ex, "Yupi.HabboHotel.Rooms.RoomData");
            }
        }