コード例 #1
0
ファイル: Messenger.cs プロジェクト: nightwolf93/Bfly
        internal void SendInstantInvite()
        {
            int count = Request.PopWiredInt32();

            List <UInt32> UserIds = new List <uint>();

            for (int i = 0; i < count; i++)
            {
                UserIds.Add(Request.PopWiredUInt());
            }

            string message = ButterflyEnvironment.FilterInjectionChars(Request.PopFixedString(), true);

            ServerMessage Message = new ServerMessage(135);

            Message.AppendUInt(Session.GetHabbo().Id);
            Message.AppendStringWithBreak(message);

            foreach (UInt32 Id in UserIds)
            {
                if (!Session.GetHabbo().GetMessenger().FriendshipExists(Id))
                {
                    continue;
                }

                GameClient Client = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(Id);

                if (Client == null)
                {
                    return;
                }

                Client.SendMessage(Message);
            }
        }
コード例 #2
0
        internal void PurchaseGift()
        {
            int    PageId      = Request.PopWiredInt32();
            uint   ItemId      = Request.PopWiredUInt();
            string ExtraData   = Request.PopFixedString();
            string GiftUser    = ButterflyEnvironment.FilterInjectionChars(Request.PopFixedString());
            string GiftMessage = ButterflyEnvironment.FilterInjectionChars(Request.PopFixedString());

            ButterflyEnvironment.GetGame().GetCatalog().HandlePurchase(Session, PageId, ItemId, ExtraData, true, GiftUser, GiftMessage);
        }
コード例 #3
0
ファイル: Users.cs プロジェクト: nightwolf93/Bfly
        internal void ChangeMotto()
        {
            string Motto = ButterflyEnvironment.FilterInjectionChars(Request.PopFixedString());

            if (Motto == Session.GetHabbo().Motto) // Prevents spam?
            {
                return;
            }

            //if (Motto.Length < 0)
            //{
            //    return; // trying to fk the client :D
            //} Congratulations. The string length can not hold calue < 0. Stupid -_-"

            Session.GetHabbo().Motto = Motto;


            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("UPDATE users SET motto = @motto WHERE id = '" + Session.GetHabbo().Id + "'");
                dbClient.addParameter("motto", Motto);
                dbClient.runQuery();
            }

            ButterflyEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, HabboHotel.Quests.QuestType.PROFILE_CHANGE_MOTTO);

            if (Session.GetHabbo().InRoom)
            {
                Room Room = Session.GetHabbo().CurrentRoom;

                if (Room == null)
                {
                    return;
                }

                RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

                if (User == null)
                {
                    return;
                }

                ServerMessage RoomUpdate = new ServerMessage(266);
                RoomUpdate.AppendInt32(User.VirtualId);
                RoomUpdate.AppendStringWithBreak(Session.GetHabbo().Look);
                RoomUpdate.AppendStringWithBreak(Session.GetHabbo().Gender.ToLower());
                RoomUpdate.AppendStringWithBreak(Session.GetHabbo().Motto);
                RoomUpdate.AppendInt32(Session.GetHabbo().AchievementPoints);
                Room.SendMessage(RoomUpdate);
            }

            ButterflyEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(Session, "ACH_Motto", 1);
        }
コード例 #4
0
ファイル: RoomManager.cs プロジェクト: nightwolf93/Bfly
        internal RoomData CreateRoom(GameClient Session, string Name, string Model)
        {
            Name = ButterflyEnvironment.FilterInjectionChars(Name);

            if (!roomModels.ContainsKey(Model))
            {
                Session.SendNotif(LanguageLocale.GetValue("room.modelmissing"));
                return(null);
            }

            if (((RoomModel)roomModels[Model]).ClubOnly && !Session.GetHabbo().HasFuse("fuse_use_special_room_layouts"))
            {
                Session.SendNotif(LanguageLocale.GetValue("room.missingclub"));
                return(null);
            }

            if (Name.Length < 3)
            {
                Session.SendNotif(LanguageLocale.GetValue("room.namelengthshort"));
                return(null);
            }

            UInt32 RoomId = 0;

            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                if (dbClient.dbType == Database_Manager.Database.DatabaseType.MSSQL)//description,public_ccts,tags,password
                {
                    dbClient.setQuery("INSERT INTO rooms (roomtype,caption,owner,model_name,description,public_ccts,tags,password) OUTPUT INSERTED.* VALUES ('private',@caption,@username,@model,'','','','')");
                }
                else
                {
                    dbClient.setQuery("INSERT INTO rooms (roomtype,caption,owner,model_name) VALUES ('private',@caption,@username,@model)");
                }
                dbClient.addParameter("caption", Name);
                dbClient.addParameter("model", Model);
                dbClient.addParameter("username", Session.GetHabbo().Username);

                RoomId = (UInt32)dbClient.insertQuery();
            }

            RoomData newRoomData = GenerateRoomData(RoomId);

            Session.GetHabbo().UsersRooms.Add(newRoomData);

            return(newRoomData);
        }
コード例 #5
0
ファイル: Messenger.cs プロジェクト: nightwolf93/Bfly
        internal void SendInstantMessenger()
        {
            if (ButterflyEnvironment.SystemMute)
            {
                return;
            }
            //if the user we are sending an IM to is on IRC, get the IRC client / connection and send the data there instead of here. Then gtfo.
            uint   userId  = Request.PopWiredUInt();
            string message = ButterflyEnvironment.FilterInjectionChars(Request.PopFixedString());

            if (Session.GetHabbo().GetMessenger() == null)
            {
                return;
            }

            Session.GetHabbo().GetMessenger().SendInstantMessage(userId, message);
        }
コード例 #6
0
ファイル: Help.cs プロジェクト: nightwolf93/Bfly
        internal void SubmitHelpTicket()
        {
            Boolean errorOccured = false;

            if (ButterflyEnvironment.GetGame().GetModerationTool().UsersHasPendingTicket(Session.GetHabbo().Id))
            {
                errorOccured = true;
            }

            if (!errorOccured)
            {
                String Message = ButterflyEnvironment.FilterInjectionChars(Request.PopFixedString());

                int  Junk         = Request.PopWiredInt32();
                int  Type         = Request.PopWiredInt32();
                uint ReportedUser = Request.PopWiredUInt();

                ButterflyEnvironment.GetGame().GetModerationTool().SendNewTicket(Session, Type, ReportedUser, Message);
            }

            GetResponse().Init(321);
            GetResponse().AppendBoolean(errorOccured);
            SendResponse();
        }
コード例 #7
0
ファイル: Users.cs プロジェクト: nightwolf93/Bfly
        internal void ChangeLook()
        {
            if (Session.GetHabbo().MutantPenalty)
            {
                Session.SendNotif("Because of a penalty or restriction on your account, you are not allowed to change your look.");
                return;
            }

            string Gender = Request.PopFixedString().ToUpper();
            string Look   = ButterflyEnvironment.FilterInjectionChars(Request.PopFixedString());

            if (!AntiMutant.ValidateLook(Look, Gender))
            {
                return;
            }

            ButterflyEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, HabboHotel.Quests.QuestType.PROFILE_CHANGE_LOOK);

            Session.GetHabbo().Look   = ButterflyEnvironment.FilterFigure(Look);
            Session.GetHabbo().Gender = Gender.ToLower();

            using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("UPDATE users SET look = @look, gender = @gender WHERE id = " + Session.GetHabbo().Id);
                dbClient.addParameter("look", Look);
                dbClient.addParameter("gender", Gender);
                dbClient.runQuery();
            }

            ButterflyEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(Session, "ACH_AvatarLooks", 1);

            Session.GetMessageHandler().GetResponse().Init(266);
            Session.GetMessageHandler().GetResponse().AppendInt32(-1);
            Session.GetMessageHandler().GetResponse().AppendStringWithBreak(Session.GetHabbo().Look);
            Session.GetMessageHandler().GetResponse().AppendStringWithBreak(Session.GetHabbo().Gender.ToLower());
            Session.GetMessageHandler().GetResponse().AppendStringWithBreak(Session.GetHabbo().Motto);
            Session.GetMessageHandler().SendResponse();

            if (Session.GetHabbo().InRoom)
            {
                Room Room = Session.GetHabbo().CurrentRoom;

                if (Room == null)
                {
                    return;
                }

                RoomUser User = Room.GetRoomUserManager().GetRoomUserByHabbo(Session.GetHabbo().Id);

                if (User == null)
                {
                    return;
                }

                ServerMessage RoomUpdate = new ServerMessage(266);
                RoomUpdate.AppendInt32(User.VirtualId);
                RoomUpdate.AppendStringWithBreak(Session.GetHabbo().Look);
                RoomUpdate.AppendStringWithBreak(Session.GetHabbo().Gender.ToLower());
                RoomUpdate.AppendStringWithBreak(Session.GetHabbo().Motto);
                Room.SendMessage(RoomUpdate);
            }
        }
コード例 #8
0
ファイル: Catalog.cs プロジェクト: nightwolf93/Bfly
        internal void HandlePurchase(GameClient Session, int PageId, uint ItemId, string ExtraData, Boolean IsGift, string GiftUser, string GiftMessage)
        {
            CatalogPage Page;

            if (!Pages.TryGetValue(PageId, out Page))
            {
                return;
            }

            if (Page == null || Page.ComingSoon || !Page.Enabled || !Page.Visible || Session == null || Session.GetHabbo() == null)
            {
                return;
            }

            if (Page.ClubOnly && !Session.GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club"))
            {
                return;
            }
            if (Session.GetHabbo().Rank != Page.MinRank) // Workaround
            {
                if (Session.GetHabbo().Rank < Page.MinRank)
                {
                    return;
                }
            }
            CatalogItem Item = Page.GetItem(ItemId);

            if (Item == null)
            {
                return;
            }

            uint GiftUserId = 0;

            if (IsGift)
            {
                if (!Item.GetBaseItem().AllowGift)
                {
                    return;
                }

                DataRow dRow;
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT id FROM users WHERE username = @gift_user");
                    dbClient.addParameter("gift_user", GiftUser);


                    dRow = dbClient.getRow();
                }

                if (dRow == null)
                {
                    Session.GetMessageHandler().GetResponse().Init(76);
                    Session.GetMessageHandler().GetResponse().AppendBoolean(true);
                    Session.GetMessageHandler().GetResponse().AppendStringWithBreak(GiftUser);
                    Session.GetMessageHandler().SendResponse();

                    return;
                }

                GiftUserId = Convert.ToUInt32(dRow[0]);

                if (GiftUserId == 0)
                {
                    Session.GetMessageHandler().GetResponse().Init(76);
                    Session.GetMessageHandler().GetResponse().AppendBoolean(true);
                    Session.GetMessageHandler().GetResponse().AppendStringWithBreak(GiftUser);
                    Session.GetMessageHandler().SendResponse();

                    return;
                }
            }

            Boolean CreditsError = false;
            Boolean PixelError   = false;

            if (Session.GetHabbo().Credits < Item.CreditsCost)
            {
                CreditsError = true;
            }

            if (Session.GetHabbo().ActivityPoints < Item.PixelsCost)
            {
                PixelError = true;
            }

            if (CreditsError || PixelError)
            {
                Session.GetMessageHandler().GetResponse().Init(68);
                Session.GetMessageHandler().GetResponse().AppendBoolean(CreditsError);
                Session.GetMessageHandler().GetResponse().AppendBoolean(PixelError);
                Session.GetMessageHandler().SendResponse();

                return;
            }

            if (IsGift && Item.GetBaseItem().Type == 'e')
            {
                Session.SendNotif(LanguageLocale.GetValue("catalog.gift.send.error"));
                return;
            }


            if (Item.CrystalCost > 0)
            {
                int userCrystals = 0;
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT crystals FROM users WHERE id = " + Session.GetHabbo().Id);
                    userCrystals = dbClient.getInteger();
                }

                if (Item.CrystalCost > userCrystals)
                {
                    Session.SendNotif(LanguageLocale.GetValue("catalog.crystalerror") + Item.CrystalCost);
                    return;
                }

                userCrystals = userCrystals - Item.CrystalCost;
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.runFastQuery("UPDATE users SET crystals = " + userCrystals + " WHERE id = " + Session.GetHabbo().Id);
                }

                Session.SendNotif(LanguageLocale.GetValue("catalog.crystalsbought") + userCrystals);
            }


            if (Item.OudeCredits > 0)
            {
                int oudeCredits = 0;
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("SELECT belcredits FROM users WHERE id = " + Session.GetHabbo().Id);
                    oudeCredits = dbClient.getInteger();
                }

                if (Item.OudeCredits > oudeCredits)
                {
                    Session.SendNotif(LanguageLocale.GetValue("catalog.oudebelcreditserror") + Item.OudeCredits);
                    return;
                }

                oudeCredits = oudeCredits - Item.OudeCredits;
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.runFastQuery("UPDATE users SET belcredits = " + oudeCredits + " WHERE id = " + Session.GetHabbo().Id);
                }

                Session.SendNotif(LanguageLocale.GetValue("catalog.oudebelcreditsok") + oudeCredits);
            }

            //Console.WriteLine(Item.GetBaseItem().ItemId);
            //Console.WriteLine(Item.GetBaseItem().InteractionType.ToLower());
            // Extra Data is _NOT_ filtered at this point and MUST BE VERIFIED BELOW:
            switch (Item.GetBaseItem().InteractionType)
            {
            case InteractionType.none:
                ExtraData = "";
                break;

            case InteractionType.musicdisc:
                ExtraData = Item.songID.ToString();
                break;

                #region Pet handling
            case InteractionType.pet0:
            case InteractionType.pet1:
            case InteractionType.pet2:
            case InteractionType.pet3:
            case InteractionType.pet4:
            case InteractionType.pet5:
            case InteractionType.pet6:
            case InteractionType.pet7:
            case InteractionType.pet8:
            case InteractionType.pet9:
            case InteractionType.pet10:
            case InteractionType.pet11:
            case InteractionType.pet12:
            case InteractionType.pet14:
            case InteractionType.pet15:
                try
                {
                    //uint count = 0;
                    //using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                    //{
                    //    dbClient.setQuery("SELECT COUNT(*) FROM user_pets WHERE user_id = " + Session.GetHabbo().Id);
                    //    count = uint.Parse(dbClient.getString());
                    //}

                    //if (count > 5)
                    //{
                    //    Session.SendNotif(LanguageLocale.GetValue("catalog.pets.maxpets"));
                    //    return;
                    //}

                    string[] Bits    = ExtraData.Split('\n');
                    string   PetName = Bits[0];
                    string   Race    = Bits[1];
                    string   Color   = Bits[2];

                    int.Parse(Race);     // to trigger any possible errors

                    if (!CheckPetName(PetName))
                    {
                        return;
                    }

                    if (Race.Length != 1)
                    {
                        return;
                    }

                    if (Color.Length != 6)
                    {
                        return;
                    }
                }
                catch (Exception e) {
                    //Logging.WriteLine(e.ToString());
                    Logging.HandleException(e, "Catalog.HandlePurchase");
                    return;
                }

                break;

                #endregion

            case InteractionType.roomeffect:

                Double Number = 0;

                try
                {
                    if (string.IsNullOrEmpty(ExtraData))
                    {
                        Number = 0;
                    }
                    else
                    {
                        Number = Double.Parse(ExtraData, ButterflyEnvironment.cultureInfo);
                    }
                }
                catch (Exception e) { Logging.HandleException(e, "Catalog.HandlePurchase: " + ExtraData); }

                ExtraData = Number.ToString().Replace(',', '.');
                break;     // maintain extra data // todo: validate

            case InteractionType.postit:
                ExtraData = "FFFF33";
                break;

            case InteractionType.dimmer:
                ExtraData = "1,1,1,#000000,255";
                break;

            case InteractionType.trophy:
                ExtraData = Session.GetHabbo().Username + Convert.ToChar(9) + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + Convert.ToChar(9) + ButterflyEnvironment.FilterInjectionChars(ExtraData, true);
                break;

            default:
                ExtraData = "";
                break;
            }

            if (Item.CreditsCost > 0)
            {
                Session.GetHabbo().Credits -= Item.CreditsCost;
                Session.GetHabbo().UpdateCreditsBalance();
            }

            if (Item.PixelsCost > 0)
            {
                Session.GetHabbo().ActivityPoints -= Item.PixelsCost;
                Session.GetHabbo().UpdateActivityPointsBalance(true);
            }

            Session.GetMessageHandler().GetResponse().Init(101);
            Session.GetMessageHandler().SendResponse();

            Session.GetMessageHandler().GetResponse().Init(67);
            Session.GetMessageHandler().GetResponse().AppendUInt(Item.GetBaseItem().ItemId);
            Session.GetMessageHandler().GetResponse().AppendStringWithBreak(Item.GetBaseItem().Name);
            Session.GetMessageHandler().GetResponse().AppendInt32(Item.CreditsCost);
            Session.GetMessageHandler().GetResponse().AppendInt32(Item.PixelsCost);
            Session.GetMessageHandler().GetResponse().AppendInt32(0);
            Session.GetMessageHandler().GetResponse().AppendInt32(1);
            Session.GetMessageHandler().GetResponse().AppendStringWithBreak(Item.GetBaseItem().Type.ToString().ToLower());
            Session.GetMessageHandler().GetResponse().AppendInt32(Item.GetBaseItem().SpriteId);
            Session.GetMessageHandler().GetResponse().AppendStringWithBreak("");
            Session.GetMessageHandler().GetResponse().AppendInt32(1);
            Session.GetMessageHandler().GetResponse().AppendInt32(0);
            Session.GetMessageHandler().SendResponse();

            if (IsGift)
            {
                uint itemID;
                //uint GenId = GenerateItemId();
                Item Present = GeneratePresent();

                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    if (dbClient.dbType == Database_Manager.Database.DatabaseType.MSSQL)
                    {
                        dbClient.setQuery("INSERT INTO items (base_id) OUTPUT INSERTED.* VALUES (" + Present.ItemId + ")");
                    }
                    else
                    {
                        dbClient.setQuery("INSERT INTO items (base_id) VALUES (" + Present.ItemId + ")");
                    }
                    itemID = (uint)dbClient.insertQuery();

                    dbClient.runFastQuery("INSERT INTO items_users VALUES (" + itemID + "," + GiftUserId + ")");

                    if (!string.IsNullOrEmpty(GiftMessage))
                    {
                        dbClient.setQuery("INSERT INTO items_extradata VALUES (" + itemID + ",@data)");
                        dbClient.addParameter("data", GiftMessage);
                        dbClient.runQuery();
                    }

                    dbClient.setQuery("INSERT INTO user_presents (item_id,base_id,amount,extra_data) VALUES (" + itemID + "," + Item.GetBaseItem().ItemId + "," + Item.Amount + ",@extra_data)");
                    dbClient.addParameter("gift_message", "!" + GiftMessage);
                    dbClient.addParameter("extra_data", ExtraData);
                    dbClient.runQuery();
                }

                GameClient Receiver = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUserID(GiftUserId);

                if (Receiver != null)
                {
                    Receiver.SendNotif(LanguageLocale.GetValue("catalog.gift.received") + Session.GetHabbo().Username);
                    Receiver.GetHabbo().GetInventoryComponent().AddNewItem(itemID, Present.ItemId, ExtraData, false, false, 0);
                    Receiver.GetHabbo().GetInventoryComponent().SendFloorInventoryUpdate();

                    InventoryComponent targetInventory = Receiver.GetHabbo().GetInventoryComponent();
                    if (targetInventory != null)
                    {
                        targetInventory.RunDBUpdate();
                    }
                }

                Session.SendNotif(LanguageLocale.GetValue("catalog.gift.sent"));
            }
            else
            {
                DeliverItems(Session, Item.GetBaseItem(), Item.Amount, ExtraData, Item.songID);
            }
        }