Пример #1
0
        public void GetSecondairResponse(Client Client)
        {
            Response PasteLink = new Response(166);
            PasteLink.AppendStringWithBreak("/client/private/" + Id + "/id");
            Client.SendResponse(PasteLink);

            Response ModelParams = new Response(69);
            ModelParams.AppendStringWithBreak(ModelParam.ToLower());
            ModelParams.AppendInt32(Id);
            Client.SendResponse(ModelParams);

            Response Environment = new Response();

            if (!Wallpaper.Equals("0.0"))
            {
                Environment.Initialize(46);
                Environment.AppendStringWithBreak("wallpaper");
                Environment.AppendStringWithBreak(Wallpaper);
            }

            if (!Floor.Equals("0.0"))
            {
                Environment.Initialize(46);
                Environment.AppendStringWithBreak("floor");
                Environment.AppendStringWithBreak(Floor);
            }

            Environment.Initialize(46);
            Environment.AppendStringWithBreak("landscape");
            Environment.AppendStringWithBreak(Landscape);

            Environment.Initialize(345);

            if (GetRoomEngine().HasRights(Client.GetUser().HabboId, RightsType.Founder) || Client.GetUser().VotedRooms.Contains(Id))
            {
                Environment.AppendInt32(Rating);
            }
            else
            {
                Environment.AppendInt32(-1);
            }

            Environment.Initialize(370);

            if (Event != null)
            {
                Event.GetResponse(Environment);
            }
            else
            {
                Environment.AppendRawInt32(-1);
                Environment.AppendChar(2);
            }

            Client.SendResponse(Environment);
        }
Пример #2
0
        private void EndEditRoom(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                return;
            }

            int RoomId = Request.PopWiredInt32();

            VirtualRoom Room = BrickEngine.GetRoomReactor().GetVirtualRoom(RoomId, RoomRunningState.Alive);

            if (Room == null)
            {
                return;
            }

            if (!Room.GetRoomEngine().HasRights(Client.GetUser().HabboId, Rooms.RightsType.Founder))
            {
                return;
            }

            string Name = BrickEngine.CleanString(Request.PopFixedString());
            string Description = BrickEngine.CleanString(Request.PopFixedString());
            int DoorState = Request.PopWiredInt32();
            string Password = BrickEngine.CleanString(Request.PopFixedString());
            int LimitUsers = Request.PopWiredInt32();

            int CategoryId = Request.PopWiredInt32();

            PrivateCategory Category = BrickEngine.GetNavigatorManager().GetPrivateCategory(CategoryId);

            if (Category == null)
            {
                CategoryId = 0;
            }

            if (Client.GetUser().Rank < Category.RankAllowed)
            {
                Client.Notif("You're not allowed to use this category.", false);
                CategoryId = 0;
            }

            int TagAmount = Request.PopWiredInt32();

            List<string> Tags = new List<string>();

            for (int i = 0; i < TagAmount; i++)
            {
                string Tag = BrickEngine.CleanString(Request.PopFixedString()).Trim().ToLower();

                if (Tag.Length > 32)
                {
                    Tag = Tag.Substring(0, 32);
                }

                if (Tag.Length > 0 && !Tags.Contains(Tag))
                {
                    Tags.Add(Tag);
                }
            }

            Boolean AllowPets = (Request.PlainReadBytes(1)[0].ToString() == "65");
            Request.AdvancePointer(1);

            Boolean AllowPetsEat = (Request.PlainReadBytes(1)[0].ToString() == "65");
            Request.AdvancePointer(1);

            Boolean AllowWalkthough = (Request.PlainReadBytes(1)[0].ToString() == "65");
            Request.AdvancePointer(1);

            Boolean AllowHideWall = (Request.PlainReadBytes(1)[0].ToString() == "65");
            Request.AdvancePointer(1);

            int WallThick = Request.PopWiredInt32();

            if (WallThick < -2 || WallThick > 1)
            {
                WallThick = 0;
            }

            int FloorThick = Request.PopWiredInt32();

            if (FloorThick < -2 || FloorThick > 1)
            {
                FloorThick = 0;
            }

            if (Name.Length > 60)
            {
                Name = Name.Substring(0, 60);
            }

            if (Description.Length > 128)
            {
                Description = Description.Substring(0, 128);
            }

            if (Password.Length > 64)
            {
                Password = Password.Substring(0, 64);
            }

            if (LimitUsers > Client.GetUser().GetRoom().GetRoomModel().LimitUsers)
            {
                LimitUsers = Client.GetUser().GetRoom().GetRoomModel().LimitUsers;
            }

            if (DoorState == 2 && Password.Length <= 0)
            {
                DoorState = 0;
            }

            Dictionary<string, Object> Params = new Dictionary<string, object>();

            List<string> Commands = new List<string>();

            if (!Room.Name.Equals(Name))
            {
                Commands.Add("name = @name");
                Params.Add("name", Name);
                Room.Name = Name;
            }

            if (!Room.Description.Equals(Description))
            {
                Commands.Add("description = @desc");
                Params.Add("desc", Description);
                Room.Description = Description;
            }

            if (!Room.DoorState.Equals(DoorState))
            {
                Commands.Add("door_state = @door");
                Params.Add("door", DoorState);
                Room.DoorState = DoorState;
            }

            if (!Room.Password.Equals(Password))
            {
                Commands.Add("password = @pw");
                Params.Add("pw", Password);
                Room.Password = Password;
            }

            if (!Room.LimitUsers.Equals(LimitUsers))
            {
                Commands.Add("limit_users = @limit");
                Params.Add("limit", LimitUsers);
                Room.LimitUsers = LimitUsers;
            }

            if (!Room.CategoryId.Equals(CategoryId))
            {
                Commands.Add("category_id = @catid");
                Params.Add("catid", CategoryId);
                Room.CategoryId = CategoryId;
            }

            if (!Room.Tags.Equals(Tags))
            {
                string SplittedTags = string.Empty;

                int x = 0;

                foreach (string Tag in Tags)
                {
                    if (x > 0)
                    {
                        SplittedTags += ',';
                    }

                    SplittedTags += Tag.ToLower();

                    x++;
                }

                Commands.Add("tags = @tags");
                Params.Add("tags", SplittedTags.ToString());
                Room.Tags = Tags;
            }

            if (!Room.AllowPets.Equals(AllowPets))
            {
                Commands.Add("allow_pets = @allow_pets");
                Params.Add("allow_pets", AllowPets ? 1 : 0);
                Room.AllowPets = AllowPets;
            }

            if (!Room.AllowPetsEat.Equals(AllowPetsEat))
            {
                Commands.Add("allow_pets_eat = @allow_pets_eat");
                Params.Add("allow_pets_eat", AllowPetsEat ? 1 : 0);
                Room.AllowPetsEat = AllowPetsEat;
            }

            if (!Room.AllowWalkthough.Equals(AllowWalkthough))
            {
                Commands.Add("allow_walkthough = @allow_walkthough");
                Params.Add("allow_walkthough", AllowWalkthough ? 1 : 0);
                Room.AllowWalkthough = AllowWalkthough;
            }

            if (!Room.AllowHideWall.Equals(AllowHideWall))
            {
                Commands.Add("allow_hidewall = @allow_hidewall");
                Params.Add("allow_hidewall", AllowHideWall ? 1 : 0);
                Room.AllowHideWall = AllowHideWall;
            }

            if (!Room.WallThick.Equals(WallThick))
            {
                Commands.Add("walls_thick = @walls_thick");
                Params.Add("walls_thick", WallThick);
                Room.WallThick = WallThick;
            }

            if (!Room.FloorThick.Equals(FloorThick))
            {
                Commands.Add("floors_thick = @floors_thick");
                Params.Add("floors_thick", FloorThick);
                Room.FloorThick = FloorThick;
            }

            Response Data = new Response(454);
            Data.AppendBoolean(true);
            Room.GetNavigatorResponse(Data, false);
            Client.SendRoomResponse(Data);

            Response Response = new Response();
            Response.Initialize(467);
            Response.AppendInt32(Client.GetUser().RoomId);
            Response.Initialize(456);
            Response.AppendInt32(Client.GetUser().RoomId);
            Client.SendResponse(Response);

            Response RoomStruct = new Response(472);
            RoomStruct.AppendBoolean(AllowHideWall);
            RoomStruct.AppendInt32(WallThick);
            RoomStruct.AppendInt32(FloorThick);
            Client.SendRoomResponse(RoomStruct);

            if (Commands.Count > 0)
            {
                using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
                {
                    StringBuilder Builder = new StringBuilder();
                    Builder.Append("UPDATE private_rooms SET ");

                    int i = 0;

                    foreach (string Command in Commands)
                    {
                        i++;
                        Builder.Append(Command);

                        if (i < Commands.Count)
                        {
                            Builder.Append(", ");
                        }
                    }

                    Builder.Append(" WHERE id = @roomid LIMIT 1");

                    Reactor.SetQuery(Builder.ToString());

                    foreach (KeyValuePair<string, Object> kvp in Params)
                    {
                        Reactor.AddParam(kvp.Key, kvp.Value);
                    }

                    Reactor.AddParam("roomid", Room.Id);

                    Reactor.ExcuteQuery();
                }
            }
        }
Пример #3
0
        public Boolean BeginEnterRoom(Client Client, string Password)
        {
            RoomEnterMessage EnterMessage = TryEnterRoom(Client,Password);

            if (!EnterMessage.Equals(RoomEnterMessage.Accepted))
            {
                Response ErrorResponse = new Response();

                if (EnterMessage.Equals(RoomEnterMessage.Banned))
                {
                    ErrorResponse.Initialize(224);
                    ErrorResponse.AppendInt32(4);
                    ErrorResponse.Initialize(18);
                    Client.SendResponse(ErrorResponse);
                    return false;
                }
                else if (EnterMessage.Equals(RoomEnterMessage.LimitUsers))
                {
                    ErrorResponse.Initialize(224);
                    ErrorResponse.AppendInt32(1);
                    ErrorResponse.Initialize(18);
                    Client.SendResponse(ErrorResponse);
                    return false;
                }
                else if (EnterMessage.Equals(RoomEnterMessage.NoAnswer))
                {
                    Client.SendResponse(new Response(131));
                    return false;
                }
                else if (EnterMessage.Equals(RoomEnterMessage.WrongPassword))
                {
                    ErrorResponse.Initialize(33);
                    ErrorResponse.AppendInt32(-100002);
                    ErrorResponse.Initialize(18);
                    Client.SendResponse(ErrorResponse);
                    return false;
                }
            }
            else
            {
                Client.SendResponse(new Response(19));
                return true;
            }

            return false;
        }
Пример #4
0
        public void GetResponse(Client Client, Response Response)
        {
            var Effects = GetEffectsForUser(Client.GetUser().HabboId);

            Response.Initialize(460);
            Response.AppendInt32(Effects.Count);

            foreach (Effect Effect in Effects)
            {
                Effect.GetResponse(Response);
            }
        }
Пример #5
0
        private void UpdateRoomIcon(Client Client, Request Request)
        {
            if (!Client.GetUser().IsInRoom)
            {
                return;
            }

            int Q = Request.PopWiredInt32();

            if (!Client.GetUser().GetRoom().GetRoomEngine().HasRights(Client.GetUser().HabboId, Rooms.RightsType.Founder))
            {
                return;
            }

            var Icons = new Dictionary<int, int>();

            int BackgroundIcon = Request.PopWiredInt32();

            if (BackgroundIcon < 1 || BackgroundIcon > 24)
            {
                BackgroundIcon = 1;
            }

            int ForegroundIcon = Request.PopWiredInt32();

            if (ForegroundIcon < 0 || ForegroundIcon > 11)
            {
                ForegroundIcon = 0;
            }

            int IconsAmount = Request.PopWiredInt32();

            for (int i = 0; i < IconsAmount; i++)
            {
                int SlotId = Request.PopWiredInt32();
                int Icon = Request.PopWiredInt32();

                if (SlotId < 0 || SlotId > 10 || Icon < 1 || Icon > 27)
                {
                    continue;
                }

                if (!Icons.ContainsKey(SlotId))
                {
                    Icons.Add(SlotId, Icon);
                }
            }

            int x = 0;

            StringBuilder Query = new StringBuilder();

            foreach (KeyValuePair<int, int> kvp in Icons)
            {
                if (x < Icons.Count)
                {
                    Query.Append(',');
                }

                Query.Append(kvp.Key);
                Query.Append('.');
                Query.Append(kvp.Value);

                x++;
            }

            Client.GetUser().GetRoom().Icon = new RoomIcon(Client.GetUser().GetRoom().Id, BackgroundIcon, ForegroundIcon, Query.ToString());

            Response Response = new Response();
            Response.Initialize(457);
            Response.AppendInt32(Client.GetUser().RoomId);
            Response.AppendBoolean(true);
            Response.Initialize(456);
            Response.AppendInt32(Client.GetUser().RoomId);
            Client.SendResponse(Response);

            Response Data = new Response(454);
            Data.AppendBoolean(false);
            Client.GetUser().GetRoom().GetNavigatorResponse(Data, false);
            Client.SendRoomResponse(Data);

            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("UPDATE private_rooms SET nav_icon_bg = @bg, nav_icon_fg = @fg, nav_icons = @icons WHERE id = @roomid LIMIT 1");
                Reactor.AddParam("bg", BackgroundIcon);
                Reactor.AddParam("fg", ForegroundIcon);
                Reactor.AddParam("icons", Query.ToString());
                Reactor.AddParam("roomid", Client.GetUser().RoomId);
                Reactor.ExcuteQuery();
            }
        }
Пример #6
0
        public Response GetLoginResponse()
        {
            LoadAchievements();
            LoadFavoriteRooms();
            LoadIgnores();
            LoadQuests();
            LoadTags();

            BrickEngine.GetAchievementReactor().UpdateUsersAchievement(GetClient(), 1);

            Response Builder = new Response();
            BrickEngine.GetEffectsHandler().GetResponse(GetClient(), Builder);

            var FloorItems = BrickEngine.GetItemReactor().GetUnseenItems(HabboId, 1);
            var WallItems = BrickEngine.GetItemReactor().GetUnseenItems(HabboId, 2);
            var PetItems = BrickEngine.GetItemReactor().GetUnseenItems(HabboId, 3);
            var BadgeItems = BrickEngine.GetItemReactor().GetUnseenItems(HabboId, 4);

            Builder.Initialize(832);
            Builder.AppendInt32(FloorItems.Count + WallItems.Count + PetItems.Count + BadgeItems.Count);

            if (FloorItems.Count > 0)
            {
                Builder.AppendInt32(1);
                Builder.AppendInt32(FloorItems.Count);

                foreach (int ItemId in FloorItems)
                {
                    Builder.AppendInt32(ItemId);
                }
            }

            if (WallItems.Count > 0)
            {
                Builder.AppendInt32(2);
                Builder.AppendInt32(WallItems.Count);

                foreach (int ItemId in WallItems)
                {
                    Builder.AppendInt32(ItemId);
                }
            }

            if (PetItems.Count > 0)
            {
                Builder.AppendInt32(3);
                Builder.AppendInt32(PetItems.Count);

                foreach (int PetId in PetItems)
                {
                    Builder.AppendInt32(PetId);
                }
            }

            if (BadgeItems.Count > 0)
            {
                Builder.AppendInt32(4);
                Builder.AppendInt32(BadgeItems.Count);

                foreach (int BadgeId in BadgeItems)
                {
                    Builder.AppendInt32(BadgeId);
                }
            }

            AtLogin();

            Builder.Initialize(455);
            Builder.AppendInt32(HomeRoomId);

            Builder.Initialize(458);
            Builder.AppendInt32(30);
            Builder.AppendInt32(FavoriteRoomIds.Count);
            FavoriteRoomIds.ToList().ForEach(Builder.AppendInt32);

            Builder.Initialize(2);

            if (GetMembership() != null)
            {
                Builder.AppendInt32(GetMembership().MemberScale + 1);
            }
            else
            {
                Builder.AppendInt32(0);
            }

            Builder.Initialize(290);
            Builder.AppendBoolean(true);
            Builder.AppendBoolean(false);

            Builder.Initialize(517);
            Builder.AppendBoolean(true);

            Builder.Initialize(628);
            Builder.AppendBoolean(true);
            Builder.AppendBoolean(false);
            Builder.AppendInt32(Pixels);

            return Builder;
        }
Пример #7
0
        private void ChangeName(Client Client, Request Request)
        {
            string Username = BrickEngine.CleanString(Request.PopFixedString());

            Boolean UpdatedName = false;

            if (!Client.GetUser().Username.ToLower().Equals(Username.ToLower()))
            {
                foreach (VirtualRoom Room in BrickEngine.GetRoomReactor().GetMe(Client.GetUser().HabboId))
                {
                    if (Room.InternalState.Equals(RoomRunningState.Alive))
                    {
                        Boolean IsMatch = false;

                        if (Regex.IsMatch(Room.Name.ToLower(), Client.GetUser().Username.ToLower()))
                        {
                            Room.Name = Room.Name.Replace(Client.GetUser().Username, Username);
                            IsMatch = true;
                        }

                        if (Regex.IsMatch(Room.Description.ToLower(), Client.GetUser().Username.ToLower()))
                        {
                            Room.Description = Room.Description.Replace(Client.GetUser().Username, Username);
                            IsMatch = true;
                        }

                        if (IsMatch)
                        {
                            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
                            {
                                Reactor.SetQuery("UPDATE private_rooms SET name = @name, description = @desc WHERE id = @roomid LIMIT 1");
                                Reactor.AddParam("name", Room.Name);
                                Reactor.AddParam("desc", Room.Description);
                                Reactor.AddParam("roomid", Room.Id);
                                Reactor.ExcuteQuery();
                            }

                            Response Data = new Response(454);
                            Data.AppendBoolean(true);
                            Room.GetNavigatorResponse(Data, false);
                            Client.SendRoomResponse(Data);
                        }
                    }
                }

                Client.GetUser().Username = Username;
                Client.GetUser().RefreshUser();

                Client.Notif("Successfully changed name, reload your room to see changes.", false);

                if (Client.GetUser().EnableShowOnline)
                {
                    lock (Client.GetUser().MessengerLocker)
                    {
                        BrickEngine.GetMessengerHandler().AlertStatusFriends(Client.GetUser(), true);
                    }
                }

                UpdatedName = true;
            }

            Client.GetUser().ProgressedNewbie = true;

            Response Response = new Response();
            Response.Initialize(571);
            Response.AppendBoolean(false);
            Response.AppendStringWithBreak(Username);
            Response.AppendBoolean(false);
            Response.Initialize(570);
            Response.AppendBoolean(false);
            Response.AppendStringWithBreak(Username);
            Response.AppendBoolean(false);
            Client.SendResponse(Response);

            BrickEngine.GetAchievementReactor().UpdateUsersAchievement(Client, 4);

            using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
            {
                Reactor.SetQuery("UPDATE users SET changed_name = '1' WHERE id = @habboid");
                Reactor.AddParam("habboid", Client.GetUser().HabboId);
                Reactor.ExcuteQuery();
            }

            if (UpdatedName)
            {
                using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
                {
                    Reactor.SetQuery("UPDATE users SET username = @username WHERE id = @habboid");
                    Reactor.AddParam("habboid", Client.GetUser().HabboId);
                    Reactor.AddParam("username", Username);
                    Reactor.ExcuteQuery();
                }
            }
        }
Пример #8
0
        public Response GetTriggerResponse()
        {
            Response Response = new Response();

            if (GetBaseItem().InternalType.ToLower().Equals("s"))
            {
                Response.Initialize(88);
                Response.AppendRawInt32(Id);
                Response.AppendChar(2);
                Response.AppendStringWithBreak(ExtraData);
            }
            else
            {
                Response.Initialize(85);
                GetRoomResponse(Response);
            }

            return Response;
        }
Пример #9
0
        public void HandleIncomingItemPickUp(Item Item, VirtualRoomUser User)
        {
            // Handling Messages (FIRST, to avoid laggys)
            Response Response = new Response();

            if (Item.GetBaseItem().InternalType.ToLower().Equals("s"))
            {
                Response.Initialize(94);
            }
            else
            {
                Response.Initialize(84);
            }

            Response.AppendRawInt32(Item.Id);
            Response.AppendChar(2);
            Response.AppendBoolean(false);

            BroadcastResponse(Response);

            Item.GetTrigger().OnRemove(Item, User);

            if (Item.GetBaseItem().ExternalType.ToLower().Equals("default"))
            {
                Item.ExtraData = "0";

                // Update Info & MySQL
                using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
                {
                    Reactor.SetQuery("UPDATE items SET room_id = '0', extra_data = '0',point_wall = '' WHERE id = @itemid LIMIT 1");
                    Reactor.AddParam("itemid", Item.Id);
                    Reactor.ExcuteQuery();
                }
            }
            else
            {
                // Update Info & MySQL
                using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
                {
                    Reactor.SetQuery("UPDATE items SET room_id = '0', point_wall = '' WHERE id = @itemid LIMIT 1");
                    Reactor.AddParam("itemid", Item.Id);
                    Reactor.ExcuteQuery();
                }
            }
        }
Пример #10
0
        public void HandleIncomingItemPickUp(Item Item, iPoint OldPlace, iPoint NewPlace, int OldRotation, int Rotation, VirtualRoomUser User)
        {
            // Handling Messages (FIRST, to avoid laggys)
            Response Response = new Response();

            if (Item.GetBaseItem().InternalType.ToLower().Equals("s"))
            {
                Response.Initialize(94);
            }
            else
            {
                Response.Initialize(84);
            }

            Response.AppendRawInt32(Item.Id);
            Response.AppendChar(2);
            Response.AppendBoolean(false);

            BroadcastResponse(Response);

            GenerateMatrix();

            UpdateUsersOnPoint(OldPlace);

            foreach (iPoint Point in BrickEngine.GetItemReactor().GetAffectedPoints(OldPlace, Item.GetBaseItem().LengthY, Item.GetBaseItem().LengthX, OldRotation))
            {
                UpdateUsersOnPoint(Point);
            }

            Item.GetTrigger().OnRemove(Item, User);

            if (Item.GetBaseItem().ExternalType.ToLower().Equals("default"))
            {
                Item.ExtraData = "0";

                // Update Info & MySQL
                using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
                {
                    Reactor.SetQuery("UPDATE items SET room_id = '0', extra_data = '0', point_x = @x, point_y = @y, point_z = @z, rotation = @rot WHERE id = @itemid LIMIT 1");
                    Reactor.AddParam("itemid", Item.Id);
                    Reactor.AddParam("x", NewPlace.X);
                    Reactor.AddParam("y", NewPlace.Y);
                    Reactor.AddParam("z", NewPlace.Z.ToString().Replace(',', '.'));
                    Reactor.AddParam("rot", Rotation);
                    Reactor.ExcuteQuery();
                }
            }
            else
            {
                // Update Info & MySQL
                using (QueryReactor Reactor = BrickEngine.GetQueryReactor())
                {
                    Reactor.SetQuery("UPDATE items SET room_id = '0', point_x = @x, point_y = @y, point_z = @z, rotation = @rot WHERE id = @itemid LIMIT 1");
                    Reactor.AddParam("itemid", Item.Id);
                    Reactor.AddParam("x", NewPlace.X);
                    Reactor.AddParam("y", NewPlace.Y);
                    Reactor.AddParam("z", NewPlace.Z.ToString().Replace(',', '.'));
                    Reactor.AddParam("rot", Rotation);
                    Reactor.ExcuteQuery();
                }
            }
        }