public RoomSettingsDataComposer(Room Room)
            : base(ServerPacketHeader.RoomSettingsDataMessageComposer)
        {
            base.WriteInteger(Room.RoomId);
            base.WriteString(Room.Name);
            base.WriteString(Room.Description);
            base.WriteInteger(RoomAccessUtility.GetRoomAccessPacketNum(Room.Access));
            base.WriteInteger(Room.Category);
            base.WriteInteger(Room.UsersMax);
            //base.WriteInteger(((Room.RoomData.Model.MapSizeX * Room.RoomData.Model.MapSizeY) > 100) ? 50 : 25);
            base.WriteInteger(75);

            base.WriteInteger(Room.Tags.Count);
            foreach (string Tag in Room.Tags.ToArray())
            {
                base.WriteString(Tag);
            }

            base.WriteInteger(Room.TradeSettings);   //Trade
            base.WriteInteger(Room.AllowPets);       // allows pets in room - pet system lacking, so always off
            base.WriteInteger(Room.AllowPetsEating); // allows pets to eat your food - pet system lacking, so always off
            base.WriteInteger(Room.RoomBlockingEnabled);
            base.WriteInteger(Room.Hidewall);
            base.WriteInteger(Room.WallThickness);
            base.WriteInteger(Room.FloorThickness);

            base.WriteInteger(Room.chatMode);     //Chat mode
            base.WriteInteger(Room.chatSize);     //Chat size
            base.WriteInteger(Room.chatSpeed);    //Chat speed
            base.WriteInteger(Room.chatDistance); //Hearing Distance
            base.WriteInteger(Room.extraFlood);   //Additional Flood

            base.WriteBoolean(true);

            base.WriteInteger(Room.WhoCanMute); // who can mute
            base.WriteInteger(Room.WhoCanKick); // who can kick
            base.WriteInteger(Room.WhoCanBan);  // who can ban
        }
Пример #2
0
        public override void Compose(ServerPacket packet)
        {
            packet.WriteInteger(Room.RoomId);
            packet.WriteString(Room.Name);
            packet.WriteString(Room.Description);
            packet.WriteInteger(RoomAccessUtility.GetRoomAccessPacketNum(Room.Access));
            packet.WriteInteger(Room.Category);
            packet.WriteInteger(Room.UsersMax);
            packet.WriteInteger(((Room.Model.MapSizeX * Room.Model.MapSizeY) > 100) ? 50 : 25);

            packet.WriteInteger(Room.Tags.Count);
            foreach (string Tag in Room.Tags.ToArray())
            {
                packet.WriteString(Tag);
            }

            packet.WriteInteger(Room.TradeSettings);   //Trade
            packet.WriteInteger(Room.AllowPets);       // allows pets in room - pet system lacking, so always off
            packet.WriteInteger(Room.AllowPetsEating); // allows pets to eat your food - pet system lacking, so always off
            packet.WriteInteger(Room.RoomBlockingEnabled);
            packet.WriteInteger(Room.Hidewall);
            packet.WriteInteger(Room.WallThickness);
            packet.WriteInteger(Room.FloorThickness);

            packet.WriteInteger(Room.ChatMode);     //Chat mode
            packet.WriteInteger(Room.ChatSize);     //Chat size
            packet.WriteInteger(Room.ChatSpeed);    //Chat speed
            packet.WriteInteger(Room.ChatDistance); //Hearing Distance
            packet.WriteInteger(Room.ExtraFlood);   //Additional Flood

            packet.WriteBoolean(true);

            packet.WriteInteger(Room.WhoCanMute); // who can mute
            packet.WriteInteger(Room.WhoCanKick); // who can kick
            packet.WriteInteger(Room.WhoCanBan);  // who can ban
        }
        public GetGuestRoomResultComposer(GameClient session, RoomData data, bool isLoading, bool checkEntry)
            : base(ServerPacketHeader.GetGuestRoomResultMessageComposer)
        {
            WriteBoolean(isLoading);
            WriteInteger(data.Id);
            WriteString(data.Name);
            WriteInteger(data.OwnerId);
            WriteString(data.OwnerName);
            WriteInteger(RoomAccessUtility.GetRoomAccessPacketNum(data.Access));
            WriteInteger(data.UsersNow);
            WriteInteger(data.UsersMax);
            WriteString(data.Description);
            WriteInteger(data.TradeSettings);
            WriteInteger(data.Score);
            WriteInteger(0);//Top rated room rank.
            WriteInteger(data.Category);

            WriteInteger(data.Tags.Count);
            foreach (string tag in data.Tags)
            {
                WriteString(tag);
            }

            if (data.Group != null && data.Promotion != null)
            {
                WriteInteger(62);

                WriteInteger(data.Group == null ? 0 : data.Group.Id);
                WriteString(data.Group == null ? "" : data.Group.Name);
                WriteString(data.Group == null ? "" : data.Group.Badge);

                WriteString(data.Promotion != null ? data.Promotion.Name : "");
                WriteString(data.Promotion != null ? data.Promotion.Description : "");
                WriteInteger(data.Promotion != null ? data.Promotion.MinutesLeft : 0);
            }
            else if (data.Group != null && data.Promotion == null)
            {
                WriteInteger(58);
                WriteInteger(data.Group == null ? 0 : data.Group.Id);
                WriteString(data.Group == null ? "" : data.Group.Name);
                WriteString(data.Group == null ? "" : data.Group.Badge);
            }
            else if (data.Group == null && data.Promotion != null)
            {
                WriteInteger(60);
                WriteString(data.Promotion != null ? data.Promotion.Name : "");
                WriteString(data.Promotion != null ? data.Promotion.Description : "");
                WriteInteger(data.Promotion != null ? data.Promotion.MinutesLeft : 0);
            }
            else
            {
                WriteInteger(56);
            }


            WriteBoolean(checkEntry);
            WriteBoolean(false);
            WriteBoolean(false);
            WriteBoolean(false);

            WriteInteger(data.WhoCanMute);
            WriteInteger(data.WhoCanKick);
            WriteInteger(data.WhoCanBan);

            WriteBoolean(session.Habbo.GetPermissions().HasRight("mod_tool") || data.OwnerName == session.Habbo.Username);
            WriteInteger(data.ChatMode);
            WriteInteger(data.ChatSize);
            WriteInteger(data.ChatSpeed);
            WriteInteger(data.ExtraFlood);
            WriteInteger(data.ChatDistance);
        }
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null)
            {
                return;
            }

            Room Room = RocketEmulador.GetGame().GetRoomManager().LoadRoom(Packet.PopInt());

            if (Room == null || !Room.CheckRights(Session, true))
            {
                return;
            }

            string     Name        = RocketEmulador.GetGame().GetChatManager().GetFilter().CheckMessage(Packet.PopString());
            string     Description = RocketEmulador.GetGame().GetChatManager().GetFilter().CheckMessage(Packet.PopString());
            RoomAccess Access      = RoomAccessUtility.ToRoomAccess(Packet.PopInt());
            string     Password    = Packet.PopString();
            int        MaxUsers    = Packet.PopInt();
            int        CategoryId  = Packet.PopInt();
            int        TagCount    = Packet.PopInt();

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

            for (int i = 0; i < TagCount; i++)
            {
                if (i > 0)
                {
                    formattedTags.Append(",");
                }

                string tag = Packet.PopString().ToLower();

                Tags.Add(tag);
                formattedTags.Append(tag);
            }

            int TradeSettings       = Packet.PopInt();//2 = All can trade, 1 = owner only, 0 = no trading.
            int AllowPets           = Convert.ToInt32(RocketEmulador.BoolToEnum(Packet.PopBoolean()));
            int AllowPetsEat        = Convert.ToInt32(RocketEmulador.BoolToEnum(Packet.PopBoolean()));
            int RoomBlockingEnabled = Convert.ToInt32(RocketEmulador.BoolToEnum(Packet.PopBoolean()));
            int Hidewall            = Convert.ToInt32(RocketEmulador.BoolToEnum(Packet.PopBoolean()));
            int WallThickness       = Packet.PopInt();
            int FloorThickness      = Packet.PopInt();
            int WhoMute             = Packet.PopInt(); // mute
            int WhoKick             = Packet.PopInt(); // kick
            int WhoBan = Packet.PopInt();              // ban

            int chatMode     = Packet.PopInt();
            int chatSize     = Packet.PopInt();
            int chatSpeed    = Packet.PopInt();
            int chatDistance = Packet.PopInt();
            int extraFlood   = Packet.PopInt();

            if (chatMode < 0 || chatMode > 1)
            {
                chatMode = 0;
            }

            if (chatSize < 0 || chatSize > 2)
            {
                chatSize = 0;
            }

            if (chatSpeed < 0 || chatSpeed > 2)
            {
                chatSpeed = 0;
            }

            if (chatDistance < 0)
            {
                chatDistance = 1;
            }

            if (chatDistance > 99)
            {
                chatDistance = 100;
            }

            if (extraFlood < 0 || extraFlood > 2)
            {
                extraFlood = 0;
            }

            if (TradeSettings < 0 || TradeSettings > 2)
            {
                TradeSettings = 0;
            }

            if (WhoMute < 0 || WhoMute > 1)
            {
                WhoMute = 0;
            }

            if (WhoKick < 0 || WhoKick > 1)
            {
                WhoKick = 0;
            }

            if (WhoBan < 0 || WhoBan > 1)
            {
                WhoBan = 0;
            }

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

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

            if (Name.Length < 1)
            {
                return;
            }

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

            if (Access == RoomAccess.PASSWORD && Password.Length == 0)
            {
                Access = RoomAccess.OPEN;
            }

            if (MaxUsers < 0)
            {
                MaxUsers = 10;
            }

            if (MaxUsers > 50)
            {
                MaxUsers = 50;
            }

            SearchResultList SearchResultList = null;

            if (!RocketEmulador.GetGame().GetNavigator().TryGetSearchResultList(CategoryId, out SearchResultList))
            {
                CategoryId = 36;
            }

            if (SearchResultList.CategoryType != NavigatorCategoryType.CATEGORY || SearchResultList.RequiredRank > Session.GetHabbo().Rank || (Session.GetHabbo().Id != Room.OwnerId && Session.GetHabbo().Rank >= SearchResultList.RequiredRank))
            {
                CategoryId = 36;
            }

            if (TagCount > 2)
            {
                return;
            }

            Room.AllowPets           = AllowPets;
            Room.AllowPetsEating     = AllowPetsEat;
            Room.RoomBlockingEnabled = RoomBlockingEnabled;
            Room.Hidewall            = Hidewall;

            Room.RoomData.AllowPets           = AllowPets;
            Room.RoomData.AllowPetsEating     = AllowPetsEat;
            Room.RoomData.RoomBlockingEnabled = RoomBlockingEnabled;
            Room.RoomData.Hidewall            = Hidewall;

            Room.Name        = Name;
            Room.Access      = Access;
            Room.Description = Description;
            Room.Category    = CategoryId;
            Room.Password    = Password;

            Room.RoomData.Name        = Name;
            Room.RoomData.Access      = Access;
            Room.RoomData.Description = Description;
            Room.RoomData.Category    = CategoryId;
            Room.RoomData.Password    = Password;

            Room.WhoCanBan           = WhoBan;
            Room.WhoCanKick          = WhoKick;
            Room.WhoCanMute          = WhoMute;
            Room.RoomData.WhoCanBan  = WhoBan;
            Room.RoomData.WhoCanKick = WhoKick;
            Room.RoomData.WhoCanMute = WhoMute;

            Room.ClearTags();
            Room.AddTagRange(Tags);
            Room.UsersMax = MaxUsers;

            Room.RoomData.Tags.Clear();
            Room.RoomData.Tags.AddRange(Tags);
            Room.RoomData.UsersMax = MaxUsers;

            Room.WallThickness           = WallThickness;
            Room.FloorThickness          = FloorThickness;
            Room.RoomData.WallThickness  = WallThickness;
            Room.RoomData.FloorThickness = FloorThickness;

            Room.chatMode     = chatMode;
            Room.chatSize     = chatSize;
            Room.chatSpeed    = chatSpeed;
            Room.chatDistance = chatDistance;
            Room.extraFlood   = extraFlood;

            Room.TradeSettings = TradeSettings;

            Room.RoomData.chatMode     = chatMode;
            Room.RoomData.chatSize     = chatSize;
            Room.RoomData.chatSpeed    = chatSpeed;
            Room.RoomData.chatDistance = chatDistance;
            Room.RoomData.extraFlood   = extraFlood;

            Room.RoomData.TradeSettings = TradeSettings;

            string AccessStr = Password.Length > 0 ? "password" : "open";

            switch (Access)
            {
            default:
            case RoomAccess.OPEN:
                AccessStr = "open";
                break;

            case RoomAccess.PASSWORD:
                AccessStr = "password";
                break;

            case RoomAccess.DOORBELL:
                AccessStr = "locked";
                break;

            case RoomAccess.INVISIBLE:
                AccessStr = "invisible";
                break;
            }

            using (IQueryAdapter dbClient = RocketEmulador.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE rooms SET caption = @caption, description = @description, password = @password, category = " +
                                  CategoryId + ", state = '" + AccessStr + "', tags = @tags, users_max = " + MaxUsers +
                                  ", allow_pets = '" + AllowPets + "', allow_pets_eat = '" + AllowPetsEat + "', room_blocking_disabled = '" +
                                  RoomBlockingEnabled + "', allow_hidewall = '" + Room.Hidewall + "', floorthick = " +
                                  Room.FloorThickness + ", wallthick = " + Room.WallThickness + ", mute_settings='" + Room.WhoCanMute +
                                  "', kick_settings='" + Room.WhoCanKick + "',ban_settings='" + Room.WhoCanBan + "', `chat_mode` = '" + Room.chatMode + "', `chat_size` = '" + Room.chatSize + "', `chat_speed` = '" + Room.chatSpeed + "', `chat_extra_flood` = '" + Room.extraFlood + "', `chat_hearing_distance` = '" + Room.chatDistance + "', `trade_settings` = '" + Room.TradeSettings + "' WHERE `id` = '" + Room.RoomId + "' LIMIT 1");
                dbClient.AddParameter("caption", Room.Name);
                dbClient.AddParameter("description", Room.Description);
                dbClient.AddParameter("password", Room.Password);
                dbClient.AddParameter("tags", formattedTags.ToString());
                dbClient.RunQuery();
            }

            Room.GetGameMap().GenerateMaps();

            if (Session.GetHabbo().CurrentRoom == null)
            {
                Session.SendMessage(new RoomSettingsSavedComposer(Room.RoomId));
                Session.SendMessage(new RoomInfoUpdatedComposer(Room.RoomId));
                Session.SendMessage(new RoomVisualizationSettingsComposer(Room.WallThickness, Room.FloorThickness, RocketEmulador.EnumToBool(Room.Hidewall.ToString())));
            }
            else
            {
                Room.SendMessage(new RoomSettingsSavedComposer(Room.RoomId));
                Room.SendMessage(new RoomInfoUpdatedComposer(Room.RoomId));
                Room.SendMessage(new RoomVisualizationSettingsComposer(Room.WallThickness, Room.FloorThickness, RocketEmulador.EnumToBool(Room.Hidewall.ToString())));
            }

            RocketEmulador.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModDoorModeSeen", 1);
            RocketEmulador.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModWalkthroughSeen", 1);
            RocketEmulador.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModChatScrollSpeedSeen", 1);
            RocketEmulador.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModChatFloodFilterSeen", 1);
            RocketEmulador.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_SelfModChatHearRangeSeen", 1);
        }
        public GetGuestRoomResultComposer(GameClient Session, RoomData Data, Boolean isLoading, Boolean checkEntry)
            : base(ServerPacketHeader.GetGuestRoomResultMessageComposer)
        {
            WriteBoolean(isLoading);
            WriteInteger(Data.Id);
            WriteString(Data.Name);
            WriteInteger(Data.OwnerId);
            WriteString(Data.OwnerName);
            WriteInteger(RoomAccessUtility.GetRoomAccessPacketNum(Data.Access));
            WriteInteger(Data.UsersNow);
            WriteInteger(Data.UsersMax);
            WriteString(Data.Description);
            WriteInteger(Data.TradeSettings);
            WriteInteger(Data.Score);
            WriteInteger(0);            //Top rated room rank.
            WriteInteger(Data.Category);

            WriteInteger(Data.Tags.Count);
            foreach (string Tag in Data.Tags)
            {
                WriteString(Tag);
            }

            if (Data.Group != null && Data.Promotion != null)
            {
                WriteInteger(62);                //What?

                WriteInteger(Data.Group == null ? 0 : Data.Group.Id);
                WriteString(Data.Group == null ? "" : Data.Group.Name);
                WriteString(Data.Group == null ? "" : Data.Group.Badge);

                WriteString(Data.Promotion != null ? Data.Promotion.Name : "");
                WriteString(Data.Promotion != null ? Data.Promotion.Description : "");
                WriteInteger(Data.Promotion != null ? Data.Promotion.MinutesLeft : 0);
            }
            else if (Data.Group != null && Data.Promotion == null)
            {
                WriteInteger(58);                //What?
                WriteInteger(Data.Group == null ? 0 : Data.Group.Id);
                WriteString(Data.Group == null ? "" : Data.Group.Name);
                WriteString(Data.Group == null ? "" : Data.Group.Badge);
            }
            else if (Data.Group == null && Data.Promotion != null)
            {
                WriteInteger(60);                //What?
                WriteString(Data.Promotion != null ? Data.Promotion.Name : "");
                WriteString(Data.Promotion != null ? Data.Promotion.Description : "");
                WriteInteger(Data.Promotion != null ? Data.Promotion.MinutesLeft : 0);
            }
            else
            {
                WriteInteger(56);                //What?
            }


            WriteBoolean(checkEntry);
            StaffPick staffPick = null;

            if (!CloudServer.GetGame().GetNavigator().TryGetStaffPickedRoom(Data.Id, out staffPick))
            {
                WriteBoolean(false);
            }
            else
            {
                WriteBoolean(true);
            }
            WriteBoolean(false);
            WriteBoolean(false);

            WriteInteger(Data.WhoCanMute);
            WriteInteger(Data.WhoCanKick);
            WriteInteger(Data.WhoCanBan);

            WriteBoolean(Session.GetHabbo().GetPermissions().HasRight("mod_tool") || Data.OwnerName == Session.GetHabbo().Username);            //Room muting.
            WriteInteger(Data.chatMode);
            WriteInteger(Data.chatSize);
            WriteInteger(Data.chatSpeed);
            WriteInteger(Data.extraFlood);            //Hearing distance
            WriteInteger(Data.chatDistance);          //Flood!!
        }
Пример #6
0
        public void Parse(HabboHotel.GameClients.GameClient session, ClientPacket packet)
        {
            if (session == null || session.GetHabbo() == null)
            {
                return;
            }

            int roomId = packet.PopInt();

            if (!PlusEnvironment.GetGame().GetRoomManager().TryLoadRoom(roomId, out Room room))
            {
                return;
            }

            string     Name        = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(packet.PopString());
            string     Description = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(packet.PopString());
            RoomAccess Access      = RoomAccessUtility.ToRoomAccess(packet.PopInt());
            string     Password    = packet.PopString();
            int        MaxUsers    = packet.PopInt();
            int        CategoryId  = packet.PopInt();
            int        TagCount    = packet.PopInt();

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

            for (int i = 0; i < TagCount; i++)
            {
                if (i > 0)
                {
                    formattedTags.Append(",");
                }

                string tag = packet.PopString().ToLower();

                Tags.Add(tag);
                formattedTags.Append(tag);
            }

            int TradeSettings       = packet.PopInt();//2 = All can trade, 1 = owner only, 0 = no trading.
            int AllowPets           = Convert.ToInt32(PlusEnvironment.BoolToEnum(packet.PopBoolean()));
            int AllowPetsEat        = Convert.ToInt32(PlusEnvironment.BoolToEnum(packet.PopBoolean()));
            int RoomBlockingEnabled = Convert.ToInt32(PlusEnvironment.BoolToEnum(packet.PopBoolean()));
            int Hidewall            = Convert.ToInt32(PlusEnvironment.BoolToEnum(packet.PopBoolean()));
            int WallThickness       = packet.PopInt();
            int FloorThickness      = packet.PopInt();
            int WhoMute             = packet.PopInt(); // mute
            int WhoKick             = packet.PopInt(); // kick
            int WhoBan = packet.PopInt();              // ban

            int chatMode     = packet.PopInt();
            int chatSize     = packet.PopInt();
            int chatSpeed    = packet.PopInt();
            int chatDistance = packet.PopInt();
            int extraFlood   = packet.PopInt();

            if (chatMode < 0 || chatMode > 1)
            {
                chatMode = 0;
            }

            if (chatSize < 0 || chatSize > 2)
            {
                chatSize = 0;
            }

            if (chatSpeed < 0 || chatSpeed > 2)
            {
                chatSpeed = 0;
            }

            if (chatDistance < 0)
            {
                chatDistance = 1;
            }

            if (chatDistance > 99)
            {
                chatDistance = 100;
            }

            if (extraFlood < 0 || extraFlood > 2)
            {
                extraFlood = 0;
            }

            if (TradeSettings < 0 || TradeSettings > 2)
            {
                TradeSettings = 0;
            }

            if (WhoMute < 0 || WhoMute > 1)
            {
                WhoMute = 0;
            }

            if (WhoKick < 0 || WhoKick > 1)
            {
                WhoKick = 0;
            }

            if (WhoBan < 0 || WhoBan > 1)
            {
                WhoBan = 0;
            }

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

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

            if (Name.Length < 1)
            {
                return;
            }

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

            if (Access == RoomAccess.Password && Password.Length == 0)
            {
                Access = RoomAccess.Open;
            }

            if (MaxUsers < 0)
            {
                MaxUsers = 10;
            }

            if (MaxUsers > 50)
            {
                MaxUsers = 50;
            }

            SearchResultList SearchResultList = null;

            if (!PlusEnvironment.GetGame().GetNavigator().TryGetSearchResultList(CategoryId, out SearchResultList))
            {
                CategoryId = 36;
            }

            if (SearchResultList.CategoryType != NavigatorCategoryType.Category || SearchResultList.RequiredRank > session.GetHabbo().Rank || (session.GetHabbo().Id != room.OwnerId && session.GetHabbo().Rank >= SearchResultList.RequiredRank))
            {
                CategoryId = 36;
            }

            if (TagCount > 2)
            {
                return;
            }

            room.AllowPets           = AllowPets;
            room.AllowPetsEating     = AllowPetsEat;
            room.RoomBlockingEnabled = RoomBlockingEnabled;
            room.Hidewall            = Hidewall;

            room.Name        = Name;
            room.Access      = Access;
            room.Description = Description;
            room.Category    = CategoryId;
            room.Password    = Password;

            room.WhoCanBan  = WhoBan;
            room.WhoCanKick = WhoKick;
            room.WhoCanMute = WhoMute;

            room.ClearTags();
            room.AddTagRange(Tags);
            room.UsersMax = MaxUsers;

            room.WallThickness  = WallThickness;
            room.FloorThickness = FloorThickness;

            room.ChatMode     = chatMode;
            room.ChatSize     = chatSize;
            room.ChatSpeed    = chatSpeed;
            room.ChatDistance = chatDistance;
            room.ExtraFlood   = extraFlood;

            room.TradeSettings = TradeSettings;

            string AccessStr = Password.Length > 0 ? "password" : "open";

            switch (Access)
            {
            default:
            case RoomAccess.Open:
                AccessStr = "open";
                break;

            case RoomAccess.Password:
                AccessStr = "password";
                break;

            case RoomAccess.Doorbell:
                AccessStr = "locked";
                break;

            case RoomAccess.Invisible:
                AccessStr = "invisible";
                break;
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("UPDATE `rooms` SET `caption` = @caption, `description` = @description, `password` = @password, `category` = @categoryId, `state` = @state, `tags` = @tags, `users_max` = @maxUsers, `allow_pets` = @allowPets, `allow_pets_eat` = @allowPetsEat, `room_blocking_disabled` = @roomBlockingDisabled, `allow_hidewall` = @allowHidewall, `floorthick` = @floorThick, `wallthick` = @wallThick, `mute_settings` = @muteSettings, `kick_settings` = @kickSettings, `ban_settings` = @banSettings, `chat_mode` = @chatMode, `chat_size` = @chatSize, `chat_speed` = @chatSpeed, `chat_extra_flood` = @extraFlood, `chat_hearing_distance` = @chatDistance, `trade_settings` = @tradeSettings WHERE `id` = @roomId LIMIT 1");
                dbClient.AddParameter("categoryId", CategoryId);
                dbClient.AddParameter("maxUsers", MaxUsers);
                dbClient.AddParameter("allowPets", AllowPets);
                dbClient.AddParameter("allowPetsEat", AllowPetsEat);
                dbClient.AddParameter("roomBlockingDisabled", RoomBlockingEnabled);
                dbClient.AddParameter("allowHidewall", room.Hidewall);
                dbClient.AddParameter("floorThick", room.FloorThickness);
                dbClient.AddParameter("wallThick", room.WallThickness);
                dbClient.AddParameter("muteSettings", room.WhoCanMute);
                dbClient.AddParameter("kickSettings", room.WhoCanKick);
                dbClient.AddParameter("banSettings", room.WhoCanBan);
                dbClient.AddParameter("chatMode", room.ChatMode);
                dbClient.AddParameter("chatSize", room.ChatSize);
                dbClient.AddParameter("chatSpeed", room.ChatSpeed);
                dbClient.AddParameter("extraFlood", room.ExtraFlood);
                dbClient.AddParameter("chatDistance", room.ChatDistance);
                dbClient.AddParameter("tradeSettings", room.TradeSettings);
                dbClient.AddParameter("roomId", room.Id);
                dbClient.AddParameter("caption", room.Name);
                dbClient.AddParameter("description", room.Description);
                dbClient.AddParameter("password", room.Password);
                dbClient.AddParameter("state", AccessStr);
                dbClient.AddParameter("tags", formattedTags.ToString());
                dbClient.RunQuery();
            }

            room.GetGameMap().GenerateMaps();

            if (session.GetHabbo().CurrentRoom == null)
            {
                session.SendPacket(new RoomSettingsSavedComposer(room.RoomId));
                session.SendPacket(new RoomInfoUpdatedComposer(room.RoomId));
                session.SendPacket(new RoomVisualizationSettingsComposer(room.WallThickness, room.FloorThickness, PlusEnvironment.EnumToBool(room.Hidewall.ToString())));
            }
            else
            {
                room.SendPacket(new RoomSettingsSavedComposer(room.RoomId));
                room.SendPacket(new RoomInfoUpdatedComposer(room.RoomId));
                room.SendPacket(new RoomVisualizationSettingsComposer(room.WallThickness, room.FloorThickness, PlusEnvironment.EnumToBool(room.Hidewall.ToString())));
            }

            PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_SelfModDoorModeSeen", 1);
            PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_SelfModWalkthroughSeen", 1);
            PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_SelfModChatScrollSpeedSeen", 1);
            PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_SelfModChatFloodFilterSeen", 1);
            PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_SelfModChatHearRangeSeen", 1);
        }
Пример #7
0
        public GetGuestRoomResultComposer(GameClient Session, RoomData Data, Boolean isLoading, Boolean checkEntry)
            : base(ServerPacketHeader.GetGuestRoomResultMessageComposer)
        {
            base.WriteBoolean(isLoading);
            base.WriteInteger(Data.Id);
            base.WriteString(Data.Name);
            base.WriteInteger(Data.OwnerId);
            base.WriteString(Data.OwnerName);
            base.WriteInteger(RoomAccessUtility.GetRoomAccessPacketNum(Data.Access));
            base.WriteInteger(Data.UsersNow);
            base.WriteInteger(Data.UsersMax);
            base.WriteString(Data.Description);
            base.WriteInteger(Data.TradeSettings);
            base.WriteInteger(Data.Score);
            base.WriteInteger(0);//Top rated room rank.
            base.WriteInteger(Data.Category);

            base.WriteInteger(Data.Tags.Count);
            foreach (string Tag in Data.Tags)
            {
                base.WriteString(Tag);
            }

            if (Data.Group != null && Data.Promotion != null)
            {
                base.WriteInteger(62);//What?

                base.WriteInteger(Data.Group == null ? 0 : Data.Group.Id);
                base.WriteString(Data.Group == null ? "" : Data.Group.Name);
                base.WriteString(Data.Group == null ? "" : Data.Group.Badge);

                base.WriteString(Data.Promotion != null ? Data.Promotion.Name : "");
                base.WriteString(Data.Promotion != null ? Data.Promotion.Description : "");
                base.WriteInteger(Data.Promotion != null ? Data.Promotion.MinutesLeft : 0);
            }
            else if (Data.Group != null && Data.Promotion == null)
            {
                base.WriteInteger(58);//What?
                base.WriteInteger(Data.Group == null ? 0 : Data.Group.Id);
                base.WriteString(Data.Group == null ? "" : Data.Group.Name);
                base.WriteString(Data.Group == null ? "" : Data.Group.Badge);
            }
            else if (Data.Group == null && Data.Promotion != null)
            {
                base.WriteInteger(60);//What?
                base.WriteString(Data.Promotion != null ? Data.Promotion.Name : "");
                base.WriteString(Data.Promotion != null ? Data.Promotion.Description : "");
                base.WriteInteger(Data.Promotion != null ? Data.Promotion.MinutesLeft : 0);
            }
            else
            {
                base.WriteInteger(56);//What?
            }


            base.WriteBoolean(checkEntry);
            base.WriteBoolean(false);
            base.WriteBoolean(false);
            base.WriteBoolean(false);

            base.WriteInteger(Data.WhoCanMute);
            base.WriteInteger(Data.WhoCanKick);
            base.WriteInteger(Data.WhoCanBan);

            bool HasRights = false;

            if (Session != null && Session.GetHabbo() != null && Session.GetHabbo().GetPermissions() != null)
            {
                if (Session.GetHabbo().GetPermissions().HasRight("mod_tool"))
                {
                    HasRights = true;
                }

                if (Data.OwnerId == Session.GetHabbo().Id)
                {
                    HasRights = true;
                }
            }

            base.WriteBoolean(HasRights);
            base.WriteInteger(Data.chatMode);
            base.WriteInteger(Data.chatSize);
            base.WriteInteger(Data.chatSpeed);
            base.WriteInteger(Data.extraFlood);   //Flood!!
            base.WriteInteger(Data.chatDistance); //Hearing distance
        }
Пример #8
0
        public override void Compose(ServerPacket packet)
        {
            packet.WriteBoolean(IsLoading);
            packet.WriteInteger(Data.Id);
            packet.WriteString(Data.Name);
            packet.WriteInteger(Data.OwnerId);
            packet.WriteString(Data.OwnerName);
            packet.WriteInteger(RoomAccessUtility.GetRoomAccessPacketNum(Data.Access));
            packet.WriteInteger(Data.UsersNow);
            packet.WriteInteger(Data.UsersMax);
            packet.WriteString(Data.Description);
            packet.WriteInteger(Data.TradeSettings);
            packet.WriteInteger(Data.Score);
            packet.WriteInteger(0);//Top rated room rank.
            packet.WriteInteger(Data.Category);

            packet.WriteInteger(Data.Tags.Count);
            foreach (string tag in Data.Tags)
            {
                packet.WriteString(tag);
            }

            if (Data.Group != null && Data.Promotion != null)
            {
                packet.WriteInteger(62);

                packet.WriteInteger(Data.Group == null ? 0 : Data.Group.Id);
                packet.WriteString(Data.Group == null ? "" : Data.Group.Name);
                packet.WriteString(Data.Group == null ? "" : Data.Group.Badge);

                packet.WriteString(Data.Promotion != null ? Data.Promotion.Name : "");
                packet.WriteString(Data.Promotion != null ? Data.Promotion.Description : "");
                packet.WriteInteger(Data.Promotion != null ? Data.Promotion.MinutesLeft : 0);
            }
            else if (Data.Group != null && Data.Promotion == null)
            {
                packet.WriteInteger(58);
                packet.WriteInteger(Data.Group == null ? 0 : Data.Group.Id);
                packet.WriteString(Data.Group == null ? "" : Data.Group.Name);
                packet.WriteString(Data.Group == null ? "" : Data.Group.Badge);
            }
            else if (Data.Group == null && Data.Promotion != null)
            {
                packet.WriteInteger(60);
                packet.WriteString(Data.Promotion != null ? Data.Promotion.Name : "");
                packet.WriteString(Data.Promotion != null ? Data.Promotion.Description : "");
                packet.WriteInteger(Data.Promotion != null ? Data.Promotion.MinutesLeft : 0);
            }
            else
            {
                packet.WriteInteger(56);
            }


            packet.WriteBoolean(CheckEntry);
            packet.WriteBoolean(false);
            packet.WriteBoolean(false);
            packet.WriteBoolean(false);

            packet.WriteInteger(Data.WhoCanMute);
            packet.WriteInteger(Data.WhoCanKick);
            packet.WriteInteger(Data.WhoCanBan);

            packet.WriteBoolean(Habbo.GetPermissions().HasRight("mod_tool") || Data.OwnerName == Habbo.Username);
            packet.WriteInteger(Data.ChatMode);
            packet.WriteInteger(Data.ChatSize);
            packet.WriteInteger(Data.ChatSpeed);
            packet.WriteInteger(Data.ExtraFlood);
            packet.WriteInteger(Data.ChatDistance);
        }
Пример #9
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            if (session?.GetHabbo() == null)
            {
                return;
            }

            var room = PlusEnvironment.GetGame().GetRoomManager().LoadRoom(packet.PopInt());

            if (room == null || !room.CheckRights(session, true))
            {
                return;
            }

            var name        = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(packet.PopString());
            var description = PlusEnvironment.GetGame().GetChatManager().GetFilter().CheckMessage(packet.PopString());
            var access      = RoomAccessUtility.ToRoomAccess(packet.PopInt());
            var password    = packet.PopString();
            var maxUsers    = packet.PopInt();
            var categoryId  = packet.PopInt();
            var tagCount    = packet.PopInt();

            var tags          = new List <string>();
            var formattedTags = new StringBuilder();

            for (var i = 0; i < tagCount; i++)
            {
                if (i > 0)
                {
                    formattedTags.Append(",");
                }

                var tag = packet.PopString().ToLower();

                tags.Add(tag);
                formattedTags.Append(tag);
            }

            var tradeSettings       = packet.PopInt(); //2 = All can trade, 1 = owner only, 0 = no trading.
            var allowPets           = Convert.ToInt32(PlusEnvironment.BoolToEnum(packet.PopBoolean()));
            var allowPetsEat        = Convert.ToInt32(PlusEnvironment.BoolToEnum(packet.PopBoolean()));
            var roomBlockingEnabled = Convert.ToInt32(PlusEnvironment.BoolToEnum(packet.PopBoolean()));
            var hidewall            = Convert.ToInt32(PlusEnvironment.BoolToEnum(packet.PopBoolean()));
            var wallThickness       = packet.PopInt();
            var floorThickness      = packet.PopInt();
            var whoMute             = packet.PopInt(); // mute
            var whoKick             = packet.PopInt(); // kick
            var whoBan = packet.PopInt();              // ban

            var chatMode     = packet.PopInt();
            var chatSize     = packet.PopInt();
            var chatSpeed    = packet.PopInt();
            var chatDistance = packet.PopInt();
            var extraFlood   = packet.PopInt();

            if (chatMode < 0 || chatMode > 1)
            {
                chatMode = 0;
            }

            if (chatSize < 0 || chatSize > 2)
            {
                chatSize = 0;
            }

            if (chatSpeed < 0 || chatSpeed > 2)
            {
                chatSpeed = 0;
            }

            if (chatDistance < 0)
            {
                chatDistance = 1;
            }

            if (chatDistance > 99)
            {
                chatDistance = 100;
            }

            if (extraFlood < 0 || extraFlood > 2)
            {
                extraFlood = 0;
            }

            if (tradeSettings < 0 || tradeSettings > 2)
            {
                tradeSettings = 0;
            }

            if (whoMute < 0 || whoMute > 1)
            {
                whoMute = 0;
            }

            if (whoKick < 0 || whoKick > 1)
            {
                whoKick = 0;
            }

            if (whoBan < 0 || whoBan > 1)
            {
                whoBan = 0;
            }

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

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

            if (name.Length < 1)
            {
                return;
            }

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

            if (access == RoomAccess.PASSWORD && password.Length == 0)
            {
                access = RoomAccess.OPEN;
            }

            if (maxUsers < 0)
            {
                maxUsers = 10;
            }

            if (maxUsers > 50)
            {
                maxUsers = 50;
            }

            SearchResultList searchResultList = null;

            if (!PlusEnvironment.GetGame().GetNavigator().TryGetSearchResultList(categoryId, out searchResultList))
            {
                categoryId = 36;
            }

            if (searchResultList.CategoryType != NavigatorCategoryType.CATEGORY || searchResultList.RequiredRank > session.GetHabbo().Rank ||
                session.GetHabbo().Id != room.OwnerId && session.GetHabbo().Rank >= searchResultList.RequiredRank)
            {
                categoryId = 36;
            }

            if (tagCount > 2)
            {
                return;
            }

            room.AllowPets           = allowPets;
            room.AllowPetsEating     = allowPetsEat;
            room.RoomBlockingEnabled = roomBlockingEnabled;
            room.Hidewall            = hidewall;

            room.RoomData.AllowPets           = allowPets;
            room.RoomData.AllowPetsEating     = allowPetsEat;
            room.RoomData.RoomBlockingEnabled = roomBlockingEnabled;
            room.RoomData.Hidewall            = hidewall;

            room.Name        = name;
            room.Access      = access;
            room.Description = description;
            room.Category    = categoryId;
            room.Password    = password;

            room.RoomData.Name        = name;
            room.RoomData.Access      = access;
            room.RoomData.Description = description;
            room.RoomData.Category    = categoryId;
            room.RoomData.Password    = password;

            room.WhoCanBan           = whoBan;
            room.WhoCanKick          = whoKick;
            room.WhoCanMute          = whoMute;
            room.RoomData.WhoCanBan  = whoBan;
            room.RoomData.WhoCanKick = whoKick;
            room.RoomData.WhoCanMute = whoMute;

            room.ClearTags();
            room.AddTagRange(tags);
            room.UsersMax = maxUsers;

            room.RoomData.Tags.Clear();
            room.RoomData.Tags.AddRange(tags);
            room.RoomData.UsersMax = maxUsers;

            room.WallThickness           = wallThickness;
            room.FloorThickness          = floorThickness;
            room.RoomData.WallThickness  = wallThickness;
            room.RoomData.FloorThickness = floorThickness;

            room.chatMode     = chatMode;
            room.chatSize     = chatSize;
            room.chatSpeed    = chatSpeed;
            room.chatDistance = chatDistance;
            room.extraFlood   = extraFlood;

            room.TradeSettings = tradeSettings;

            room.RoomData.chatMode     = chatMode;
            room.RoomData.chatSize     = chatSize;
            room.RoomData.chatSpeed    = chatSpeed;
            room.RoomData.chatDistance = chatDistance;
            room.RoomData.extraFlood   = extraFlood;

            room.RoomData.TradeSettings = tradeSettings;

            var accessStr = password.Length > 0 ? "password" : "open";

            switch (access)
            {
            default:
            case RoomAccess.OPEN:
                accessStr = "open";
                break;

            case RoomAccess.PASSWORD:
                accessStr = "password";
                break;

            case RoomAccess.DOORBELL:
                accessStr = "locked";
                break;

            case RoomAccess.INVISIBLE:
                accessStr = "invisible";
                break;
            }

            using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery(
                    "UPDATE `rooms` SET `caption` = @caption, `description` = @description, `password` = @password, `category` = @categoryId, `state` = @state, `tags` = @tags, `users_max` = @maxUsers, `allow_pets` = @allowPets, `allow_pets_eat` = @allowPetsEat, `room_blocking_disabled` = @roomBlockingDisabled, `allow_hidewall` = @allowHidewall, `floorthick` = @floorThick, `wallthick` = @wallThick, `mute_settings` = @muteSettings, `kick_settings` = @kickSettings, `ban_settings` = @banSettings, `chat_mode` = @chatMode, `chat_size` = @chatSize, `chat_speed` = @chatSpeed, `chat_extra_flood` = @extraFlood, `chat_hearing_distance` = @chatDistance, `trade_settings` = @tradeSettings WHERE `id` = @roomId LIMIT 1");
                dbClient.AddParameter("categoryId", categoryId);
                dbClient.AddParameter("maxUsers", maxUsers);
                dbClient.AddParameter("allowPets", allowPets);
                dbClient.AddParameter("allowPetsEat", allowPetsEat);
                dbClient.AddParameter("roomBlockingDisabled", roomBlockingEnabled);
                dbClient.AddParameter("allowHidewall", room.Hidewall);
                dbClient.AddParameter("floorThick", room.FloorThickness);
                dbClient.AddParameter("wallThick", room.WallThickness);
                dbClient.AddParameter("muteSettings", room.WhoCanMute);
                dbClient.AddParameter("kickSettings", room.WhoCanKick);
                dbClient.AddParameter("banSettings", room.WhoCanBan);
                dbClient.AddParameter("chatMode", room.chatMode);
                dbClient.AddParameter("chatSize", room.chatSize);
                dbClient.AddParameter("chatSpeed", room.chatSpeed);
                dbClient.AddParameter("extraFlood", room.extraFlood);
                dbClient.AddParameter("chatDistance", room.chatDistance);
                dbClient.AddParameter("tradeSettings", room.TradeSettings);
                dbClient.AddParameter("roomId", room.Id);
                dbClient.AddParameter("caption", room.Name);
                dbClient.AddParameter("description", room.Description);
                dbClient.AddParameter("password", room.Password);
                dbClient.AddParameter("state", accessStr);
                dbClient.AddParameter("tags", formattedTags.ToString());
                dbClient.RunQuery();
            }

            room.GetGameMap().GenerateMaps();

            if (session.GetHabbo().CurrentRoom == null)
            {
                session.SendPacket(new RoomSettingsSavedComposer(room.RoomId));
                session.SendPacket(new RoomInfoUpdatedComposer(room.RoomId));
                session.SendPacket(new RoomVisualizationSettingsComposer(room.WallThickness, room.FloorThickness, PlusEnvironment.EnumToBool(room.Hidewall.ToString())));
            }
            else
            {
                room.SendPacket(new RoomSettingsSavedComposer(room.RoomId));
                room.SendPacket(new RoomInfoUpdatedComposer(room.RoomId));
                room.SendPacket(new RoomVisualizationSettingsComposer(room.WallThickness, room.FloorThickness, PlusEnvironment.EnumToBool(room.Hidewall.ToString())));
            }

            PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_SelfModDoorModeSeen", 1);
            PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_SelfModWalkthroughSeen", 1);
            PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_SelfModChatScrollSpeedSeen", 1);
            PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_SelfModChatFloodFilterSeen", 1);
            PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(session, "ACH_SelfModChatHearRangeSeen", 1);
        }