示例#1
0
        private static void UpdateMoodlight(Session Session, ClientMessage Message)
        {
            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

            if (Instance == null || !Instance.CheckUserRights(Session, true))
            {
                return;
            }

            Item Item = Instance.MoodlightItem;

            if (Item == null)
            {
                return;
            }

            MoodlightData   Data     = MoodlightData.GenerateFromFlags(Item.Flags);
            int             PresetId = Message.PopWiredInt32();
            MoodlightPreset Preset   = null;

            if (Data.Presets.ContainsKey(PresetId))
            {
                Preset = Data.Presets[PresetId];
            }

            if (Preset == null)
            {
                return;
            }

            Preset.BackgroundOnly = !Message.PopWiredBoolean();
            Preset.ColorCode      = UserInputFilter.FilterString(Message.PopString().Trim());
            Preset.ColorIntensity = Message.PopWiredInt32();

            if (!MoodlightData.IsValidColor(Preset.ColorCode))
            {
                return;
            }

            Item.Flags        = Data.ToItemFlagData();
            Item.DisplayFlags = Data.ToDisplayData();

            using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
            {
                Item.SynchronizeDatabase(MySqlClient, true);
            }

            Item.BroadcastStateUpdate(Instance);
        }
        public MoodlightConfigComposer(MoodlightData MoodlightData)
            : base(ServerPacketHeader.MoodlightConfigMessageComposer)
        {
            base.WriteInteger(MoodlightData.Presets.Count);
            base.WriteInteger(MoodlightData.CurrentPreset);

            int i = 1;

            foreach (MoodlightPreset Preset in MoodlightData.Presets)
            {
                base.WriteInteger(i);
                base.WriteInteger(Preset.BackgroundOnly ? 2 : 1);
                base.WriteString(Preset.ColorCode);
                base.WriteInteger(Preset.ColorIntensity);
                i++;
            }
        }
示例#3
0
        public MoodlightConfigComposer(MoodlightData moodlightData)
            : base(ServerPacketHeader.MoodlightConfigMessageComposer)
        {
            WriteInteger(moodlightData.Presets.Count);
            WriteInteger(moodlightData.CurrentPreset);

            var i = 1;

            foreach (var preset in moodlightData.Presets)
            {
                WriteInteger(i);
                WriteInteger(preset.BackgroundOnly ? 2 : 1);
                WriteString(preset.ColorCode);
                WriteInteger(preset.ColorIntensity);
                i++;
            }
        }
示例#4
0
        public static ServerMessage Compose(MoodlightData Data)
        {
            ServerMessage Message = new ServerMessage(OpcodesOut.MOODLIGHT_DATA);

            Message.AppendInt32(Data.Presets.Count);
            Message.AppendInt32(Data.CurrentPreset);

            foreach (KeyValuePair <int, MoodlightPreset> Preset in Data.Presets)
            {
                Message.AppendInt32(Preset.Key);
                Message.AppendInt32(Preset.Value.BackgroundOnly ? 2 : 1);
                Message.AppendStringWithBreak(Preset.Value.ColorCode);
                Message.AppendInt32(Preset.Value.ColorIntensity);
            }

            return(Message);
        }
示例#5
0
        public override void Compose(Yupi.Protocol.ISender session, MoodlightData moodlight)
        {
            using (ServerMessage message = Pool.GetMessageBuffer(Id))
            {
                message.AppendInteger(moodlight.Presets.Count);
                message.AppendInteger(moodlight.CurrentPreset.Id);

                for (int i = 0; i < moodlight.Presets.Count; ++i)
                {
                    MoodlightPreset preset = moodlight.Presets[i];
                    message.AppendInteger(i);
                    message.AppendInteger(preset.BackgroundOnly ? 2 : 1);
                    message.AppendString(preset.ColorCode);
                    message.AppendInteger(preset.ColorIntensity);
                }
                session.Send(message);
            }
        }
示例#6
0
        private static void GetMoodlightInfo(Session Session, ClientMessage Message)
        {
            RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

            if (Instance == null || !Instance.CheckUserRights(Session, true))
            {
                return;
            }

            Item Item = Instance.MoodlightItem;

            if (Item == null)
            {
                return;
            }

            Session.SendData(MoodlightDataComposer.Compose(MoodlightData.GenerateFromFlags(Item.Flags)));
        }
示例#7
0
 public bool method_82(GameClient Session, RoomItem RoomItem_0, bool bool_13, string string_10)
 {
     if (bool_13)
     {
         RoomItem_0.Interactor.OnPlace(Session, RoomItem_0);
         string text = RoomItem_0.GetBaseItem().InteractionType.ToLower();
         if (text != null && text == "dimmer" && this.MoodlightData == null)
         {
             this.MoodlightData = new MoodlightData(RoomItem_0.uint_0);
             RoomItem_0.ExtraData = this.MoodlightData.GenerateExtraData();
         }
         if (!this.hashtable_3.ContainsKey(RoomItem_0.uint_0))
         {
             this.hashtable_3.Add(RoomItem_0.uint_0, RoomItem_0);
             if (RoomItem_0.Boolean_2)
             {
                 this.hashtable_0.Add(RoomItem_0.uint_0, RoomItem_0);
             }
             else
             {
                 if (!this.hashtable_4.Contains(RoomItem_0.uint_0))
                 {
                     this.hashtable_4.Add(RoomItem_0.uint_0, RoomItem_0);
                 }
             }
         }
         ServerMessage Message5_ = new ServerMessage(Outgoing.AddWallItemToRoom); // Updated
         RoomItem_0.Serialize(Message5_);
         Message5_.AppendString(this.Owner);
         this.SendMessage(Message5_, null);
     }
     else
     {
         if (!this.hashtable_2.Contains(RoomItem_0.uint_0))
         {
             this.hashtable_2.Add(RoomItem_0.uint_0, RoomItem_0);
         }
     }
     if (!bool_13)
     {
         RoomItem_0.string_7 = string_10;
         ServerMessage Message5_ = new ServerMessage(Outgoing.UpdateWallItemOnRoom);
         RoomItem_0.Serialize(Message5_);
         this.SendMessage(Message5_, null);
     }
     return true;
 }
示例#8
0
        private void method_66(bool bool_13)
        {
            if (!this.bool_12)
            {
                this.bool_12 = true;
                if (bool_13)
                {
                    this.bool_11 = false;
                    if (this.timer_0 != null)
                    {
                        this.bool_6 = true;
                        this.timer_0.Change(-1, -1);
                    }
                    this.bool_6 = true;
                    this.method_64();
                    using (DatabaseClient @class = Essential.GetDatabase().GetClient())
                    {
                        @class.ExecuteQuery(string.Concat(new object[]
						{
							"UPDATE user_pets SET room_id = 0 WHERE room_id = ",
							this.Id,
							" AND NOT user_id = ",
							Essential.GetGame().GetClientManager().GetIdByName(this.Owner)
						}));
                    }
                    //this.timer_0.Dispose();
                    this.timer_0 = null;
                    this.bool_9 = false;
                    if (this.Tags != null)
                    {
                        this.Tags.Clear();
                    }
                    this.Tags = null;
                    if (this.RoomUsers != null)
                    {
                        Array.Clear(this.RoomUsers, 0, this.RoomUsers.Length);
                    }
                    this.RoomUsers = null;
                    this.RoomIcon = null;
                    if (this.UsersWithRights != null)
                    {
                        this.UsersWithRights.Clear();
                    }
                    this.RoomIcon = null;
                    if (this.dictionary_0 != null)
                    {
                        this.dictionary_0.Clear();
                    }
                    this.dictionary_0 = null;
                    this.Wallpaper = null;
                    this.Floor = null;
                    this.Landscape = null;
                    if (this.hashtable_0 != null)
                    {
                        this.hashtable_0.Clear();
                    }
                    this.hashtable_0 = null;
                    if (this.hashtable_4 != null)
                    {
                        this.hashtable_4.Clear();
                    }
                    this.hashtable_4 = null;
                    this.MoodlightData = null;
                    if (this.list_2 != null)
                    {
                        this.list_2.Clear();
                    }
                    this.list_2 = null;
                    if (this.MusicController != null)
                    {
                        this.MusicController.UnLinkRoomOutputItem();
                    }
                    this.MusicController = null;
                    if (this.InfobusAnswers != null)
                    {
                        this.InfobusAnswers.Clear();
                    }
                    this.InfobusAnswers = null;
                }
            }
        }
示例#9
0
        public void method_25()
        {
            this.hashtable_0.Clear();
            this.hashtable_4.Clear();
            DataTable dataTable;
            using (DatabaseClient @class = Essential.GetDatabase().GetClient())
            {
                dataTable = @class.ReadDataTable("SELECT Id, base_item, x, y, z, rot, wall_pos, ltd_id, ltd_cnt, guild_data FROM items WHERE room_id = '" + this.Id + "' ORDER BY room_id DESC");
            }
            if (dataTable != null)
            {
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    DataRow DataRowExtraData;
                    string ExtraData;
                    using (DatabaseClient @class = Essential.GetDatabase().GetClient())
                    {
                        DataRowExtraData = @class.ReadDataRow("SELECT extra_data FROM items_extra_data WHERE item_id = '" + (uint)dataRow["Id"] + "'");
                        if (DataRowExtraData != null)
                        {
                            ExtraData = (string)DataRowExtraData["extra_data"];
                        }
                        else
                        {
                            ExtraData = "";
                        }
                    }
                    RoomItem class2 = new RoomItem((uint)dataRow["Id"], this.Id, (uint)dataRow["base_item"], ExtraData, (int)dataRow["x"], (int)dataRow["y"], (double)dataRow["z"], (int)dataRow["rot"], (string)dataRow["wall_pos"], this, (int)dataRow["ltd_id"], (int)dataRow["ltd_cnt"], (string)dataRow["guild_data"]);
                    if (class2.Boolean_0)
                    {
                        this.bool_11 = true;
                    }
                    if (class2.GetBaseItem().InteractionType.ToLower().Contains("wf_") || class2.GetBaseItem().InteractionType.ToLower().Contains("fbgate"))
                    {
                        DataRow dataRow2;
                        using (DatabaseClient @class = Essential.GetDatabase().GetClient())
                        {
                            dataRow2 = @class.ReadDataRow("SELECT extra1,extra2,extra3,extra4,extra5 FROM wired_items WHERE item_id = '" + class2.uint_0 + "'");
                        }
                        if (dataRow2 != null)
                        {
                            class2.string_2 = (string)dataRow2["extra1"];
                            class2.string_3 = (string)dataRow2["extra2"];
                            class2.string_4 = (string)dataRow2["extra3"];
                            class2.string_5 = (string)dataRow2["extra4"];
                            class2.string_6 = (string)dataRow2["extra5"];
                        }
                    }
                    if (class2.GetBaseItem().InteractionType.ToLower() == "firework")
                    {
                        DataRow dataRow2;
                        using (DatabaseClient @class = Essential.GetDatabase().GetClient())
                        {
                            dataRow2 = @class.ReadDataRow("SELECT fw_count FROM items_firework WHERE item_id = '" + class2.uint_0 + "'");

                            if (dataRow2 != null)
                            {
                                class2.FireWorkCount = (int)dataRow2["fw_count"];
                            }
                            else
                            {
                                @class.ExecuteQuery("INSERT INTO items_firework(item_id, fw_count) VALUES ( '" + class2.uint_0 + "', '0')");
                            }
                        }
                    }

                    string text = class2.GetBaseItem().InteractionType.ToLower();
                    switch (text)
                    {
                        case "dice":
                            if (class2.ExtraData == "-1")
                            {
                                class2.ExtraData = "0";
                            }
                            break;
                        case "fbgate":
                            if (class2.ExtraData != "" && class2.ExtraData.Contains(','))
                            {
                                class2.string_2 = class2.ExtraData.Split(new char[]
							{
								','
							})[0];
                                class2.string_3 = class2.ExtraData.Split(new char[]
							{
								','
							})[1];
                            }
                            break;
                        case "dimmer":
                            if (this.MoodlightData == null)
                            {
                                this.MoodlightData = new MoodlightData(class2.uint_0);
                            }
                            break;
                        case "bb_patch":
                            this.list_5.Add(class2);
                            if (class2.ExtraData == "5")
                            {
                                this.list_6.Add(class2);
                            }
                            else
                            {
                                if (class2.ExtraData == "8")
                                {
                                    this.list_7.Add(class2);
                                }
                                else
                                {
                                    if (class2.ExtraData == "11")
                                    {
                                        this.list_9.Add(class2);
                                    }
                                    else
                                    {
                                        if (class2.ExtraData == "14")
                                        {
                                            this.list_8.Add(class2);
                                        }
                                    }
                                }
                            }
                            break;
                        case "blue_score":
                            this.list_12.Add(class2);
                            break;
                        case "green_score":
                            this.list_13.Add(class2);
                            break;
                        case "red_score":
                            this.list_10.Add(class2);
                            break;
                        case "yellow_score":
                            this.list_11.Add(class2);
                            break;
                        case "stickiepole":
                            this.list_3.Add(class2);
                            break;
                        case "wf_trg_onsay":
                        case "wf_trg_enterroom":
                        case "wf_trg_furnistate":
                        case "wf_trg_onfurni":
                        case "wf_trg_offfurni":
                        case "wf_trg_gameend":
                        case "wf_trg_gamestart":
                        case "wf_trg_bot_reached_stf":
                            if (!this.list_14.Contains(class2))
                            {
                                this.list_14.Add(class2);
                            }
                            break;
                        case "wf_trg_attime":
                            if (class2.string_2.Length <= 0)
                            {
                                class2.string_2 = "10";
                            }
                            if (!this.list_14.Contains(class2))
                            {
                                this.list_14.Add(class2);
                            }
                            class2.bool_0 = true;
                            class2.ReqUpdate(1);
                            break;
                        case "wf_trg_atscore":
                            if (!this.list_14.Contains(class2))
                            {
                                this.list_14.Add(class2);
                            }
                            class2.WiredAtTimeNeedReset = false;
                            class2.ReqUpdate(1);
                            break;
                        case "wf_trg_timer":
                            if (class2.string_2.Length <= 0)
                            {
                                class2.string_2 = "10";
                            }
                            if (!this.list_14.Contains(class2))
                            {
                                this.list_14.Add(class2);
                            }
                            class2.bool_0 = true;
                            class2.ReqUpdate(1);
                            break;
                        case "wf_act_saymsg":
                        case "wf_act_kick_user":
                        case "wf_act_moveuser":
                        case "wf_act_togglefurni":
                        case "wf_act_givepoints":
                        case "wf_act_moverotate":
                        case "wf_act_matchfurni":
                        case "wf_act_give_phx":
                        case "wf_act_bot_follow_avatar":
                        case "wf_act_bot_give_handitem":
                        case "wf_act_bot_talk":
                        case "wf_act_bot_talk_to_avatar":
                        case "wf_act_bot_clothes":
                        case "wf_act_yt":
                        case "wf_act_img":
                            if (!this.list_15.Contains(class2))
                            {
                                this.list_15.Add(class2);
                            }
                            break;
                        case "wf_cnd_trggrer_on_frn":
                        case "wf_cnd_furnis_hv_avtrs":
                        case "wf_cnd_has_furni_on":
                        case "wf_cnd_match_snapshot":
                        case "wf_cnd_time_more_than":
                        case "wf_cnd_time_less_than":
                        case "wf_cnd_phx":
                        case "wf_cnd_user_count_in":
                        case "wf_cnd_not_user_count":
                        case "wf_cnd_actor_in_group":
                        case "wf_cnd_actor_in_team":
                        case "wf_cnd_has_handitem":
                        case "wf_cnd_not_furni_on":
                        case "wf_cnd_not_hv_avtrs":
                        case "wf_cnd_not_in_group":
                        case "wf_cnd_not_in_team":
                        case "wf_cnd_not_match_snap":
                        case "wf_cnd_has_purse":
                        case "wf_cnd_hasnot_purse":
                            if (!this.list_16.Contains(class2))
                            {
                                this.list_16.Add(class2);
                            }
                            break;
                        case "jukebox":
                            RoomMusicController roomMusicController = this.GetRoomMusicController();
                            roomMusicController.LinkRoomOutputItemIfNotAlreadyExits(class2);
                            break;
                        case "freeze_tile":
                            this.GetFreeze().AddFreezeTile(class2);
                            break;
                        case "freeze_ice_block":
                            this.GetFreeze().AddFreezeBlock(class2);
                            break;
                        case "freeze_exit":
                            RoomItem exitTeleport = this.GetFreeze().ExitTeleport;
                            if (exitTeleport == null)
                            {
                                this.GetFreeze().ExitTeleport = class2;
                            }
                            break;
                        case "freeze_blue_gate":
                            this.GetGameManager().AddFreezeGate(class2);
                            break;
                        case "freeze_red_gate":
                            this.GetGameManager().AddFreezeGate(class2);
                            break;
                        case "freeze_green_gate":
                            this.GetGameManager().AddFreezeGate(class2);
                            break;
                        case "freeze_yellow_gate":
                            this.GetGameManager().AddFreezeGate(class2);
                            break;
                        case "freeze_blue_score":
                            this.GetGameManager().AddFreezeScoreboard(class2);
                            break;
                        case "freeze_red_score":
                            this.GetGameManager().AddFreezeScoreboard(class2);
                            break;
                        case "freeze_green_score":
                            this.GetGameManager().AddFreezeScoreboard(class2);
                            break;
                        case "freeze_yellow_score":
                            this.GetGameManager().AddFreezeScoreboard(class2);
                            break;
                    }
                    if (this.hashtable_0.Contains(class2.uint_0))
                    {
                        this.hashtable_0.Remove(class2.uint_0);
                    }
                    if (this.hashtable_4.Contains(class2.uint_0))
                    {
                        this.hashtable_4.Remove(class2.uint_0);
                    }
                    if (class2.Boolean_2)
                    {
                        this.hashtable_0.Add(class2.uint_0, class2);
                    }
                    else
                    {
                        this.hashtable_4.Add(class2.uint_0, class2);
                    }
                }
            }

        }
示例#10
0
        public void Dispose()
        {
            SendPacket(new CloseConnectionComposer());

            if (!mDisposed)
            {
                isCrashed = false;
                mDisposed = true;

                /* TODO: Needs reviewing */
                try
                {
                    if (ProcessTask != null && ProcessTask.IsCompleted)
                    {
                        ProcessTask.Dispose();
                    }
                }
                catch { }

                if (ActiveTrades.Count > 0)
                {
                    ActiveTrades.Clear();
                }

                TonerData     = null;
                MoodlightData = null;

                if (MutedUsers.Count > 0)
                {
                    MutedUsers.Clear();
                }

                if (Tents.Count > 0)
                {
                    Tents.Clear();
                }

                if (UsersWithRights.Count > 0)
                {
                    UsersWithRights.Clear();
                }

                if (_gameManager != null)
                {
                    _gameManager.Dispose();
                    _gameManager = null;
                }

                if (_freeze != null)
                {
                    _freeze.Dispose();
                    _freeze = null;
                }

                if (_soccer != null)
                {
                    _soccer.Dispose();
                    _soccer = null;
                }

                if (_banzai != null)
                {
                    _banzai.Dispose();
                    _banzai = null;
                }

                if (_gamemap != null)
                {
                    _gamemap.Dispose();
                    _gamemap = null;
                }

                if (_gameItemHandler != null)
                {
                    _gameItemHandler.Dispose();
                    _gameItemHandler = null;
                }

                // Room Data?

                if (teambanzai != null)
                {
                    teambanzai.Dispose();
                    teambanzai = null;
                }

                if (teamfreeze != null)
                {
                    teamfreeze.Dispose();
                    teamfreeze = null;
                }

                if (_roomUserManager != null)
                {
                    _roomUserManager.Dispose();
                    _roomUserManager = null;
                }

                if (_roomItemHandling != null)
                {
                    _roomItemHandling.Dispose();
                    _roomItemHandling = null;
                }

                if (_wordFilterList.Count > 0)
                {
                    _wordFilterList.Clear();
                }

                if (_filterComponent != null)
                {
                    _filterComponent.Cleanup();
                }

                if (_wiredComponent != null)
                {
                    _wiredComponent.Cleanup();
                }

                if (_bansComponent != null)
                {
                    _bansComponent.Cleanup();
                }

                if (_tradingComponent != null)
                {
                    _tradingComponent.Cleanup();
                }
            }
        }
示例#11
0
 public bool method_82(GameClient Session, RoomItem RoomItem_0, bool bool_13, string string_10)
 {
     if (bool_13)
     {
         RoomItem_0.Class69_0.OnPlace(Session, RoomItem_0);
         string text = RoomItem_0.GetBaseItem().InteractionType.ToLower();
         if (text != null && text == "dimmer" && this.class67_0 == null)
         {
             this.class67_0 = new MoodlightData(RoomItem_0.uint_0);
             RoomItem_0.ExtraData = this.class67_0.method_7();
         }
         if (!this.hashtable_3.ContainsKey(RoomItem_0.uint_0))
         {
             this.hashtable_3.Add(RoomItem_0.uint_0, RoomItem_0);
             if (RoomItem_0.Boolean_2)
             {
                 this.hashtable_0.Add(RoomItem_0.uint_0, RoomItem_0);
             }
             else
             {
                 if (!this.hashtable_4.Contains(RoomItem_0.uint_0))
                 {
                     this.hashtable_4.Add(RoomItem_0.uint_0, RoomItem_0);
                 }
             }
         }
         ServerMessage Message5_ = new ServerMessage(83u);
         RoomItem_0.method_6(Message5_);
         this.SendMessage(Message5_, null);
     }
     else
     {
         if (!this.hashtable_2.Contains(RoomItem_0.uint_0))
         {
             this.hashtable_2.Add(RoomItem_0.uint_0, RoomItem_0);
         }
     }
     if (!bool_13)
     {
         RoomItem_0.string_7 = string_10;
         ServerMessage Message5_ = new ServerMessage(85u);
         RoomItem_0.method_6(Message5_);
         this.SendMessage(Message5_, null);
     }
     return true;
 }
示例#12
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom)
            {
                return;
            }

            if (Session.GetHabbo().ViewInventory)
            {
                Session.SendMessage("Oeps! Je kunt dit item niet plaatsen omdat je momenteel iemand anders zijn of haar inventaris aan het bekijken bent.");
                return;
            }

            Room Room = null;

            if (!QuasarEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room))
            {
                return;
            }

            int ItemId = 0;

            string[] Data = null;

            string RawData = Packet.PopString();

            Data = RawData.Split(' ');

            if (!int.TryParse(Data[0], out ItemId))
            {
                return;
            }

            bool HasRights = false;

            if (Room.CheckRights(Session, false, true))
            {
                HasRights = true;
            }

            if (!HasRights)
            {
                Session.SendMessage(RoomNotificationComposer.SendBubble("bubble_bouwen", "Oeps! Je kan dit item hier niet plaatsen.", ""));
                return;
            }

            Item Item = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId);

            if (Item == null)
            {
                return;
            }

            if (Room.ForSale)
            {
                Session.SendWhisper("Oeps! Je kunt de kamer niet bewerken wanneer deze te koop staat!");
                Session.SendWhisper("Als je de verkoop wilt annuleren gebruik dan de command :unload.");
                return;
            }

            if (Room.GetRoomItemHandler().GetWallAndFloor.Count() > QuasarStaticGameSettings.RoomFurnitureLimit)
            {
                Session.SendNotification("Oeps! Je kunt niet meer dan " + QuasarStaticGameSettings.RoomFurnitureLimit + " items in één kamer hebben.");
                return;
            }
            else if (Item.GetBaseItem().ItemName.ToLower().Contains("cf") && Room.OwnerId != Session.GetHabbo().Id&& !Session.GetHabbo().GetPermissions().HasRight("room_item_place_exchange_anywhere"))
            {
                Session.SendNotification("Oeps! Je hebt niet de bevoegdheid om deze actie uit te voeren.");
                return;
            }

            if (Item.GetBaseItem().InteractionType == InteractionType.HOLE)
            {
                QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_RoomDecoHoleFurniCount", 1, false);
            }


            if (Item.GetBaseItem().InteractionType == InteractionType.DICE)
            {
                QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_CasinoPlaceDices", 1, false);
            }

            if (Item.GetBaseItem().InteractionType == InteractionType.POKER)
            {
                QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_CasinoPlayPoker", 1, false);
            }

            //TODO: Make neat.
            switch (Item.GetBaseItem().InteractionType)
            {
                #region Interaction Types
            case InteractionType.MOODLIGHT:
            {
                MoodlightData moodData = Room.MoodlightData;
                if (moodData != null && Room.GetRoomItemHandler().GetItem(moodData.ItemId) != null)
                {
                    Session.SendMessage(new RoomCustomizedAlertComposer("Oeps! Je kunt maar één sfeerverlichter per kamer."));
                    return;
                }
                break;
            }

            case InteractionType.TONER:
            {
                TonerData tonerData = Room.TonerData;
                if (tonerData != null && Room.GetRoomItemHandler().GetItem(tonerData.ItemId) != null)
                {
                    Session.SendNotification("Oeps! Je kunt maar één kamer achtergrond toner per kamer.");
                    return;
                }
                break;
            }

            case InteractionType.HOPPER:
            {
                if (Room.GetRoomItemHandler().HopperCount > 0)
                {
                    Session.SendNotification("Oeps! Je kunt maar één hopper per kamer.");
                    return;
                }
                break;
            }

            case InteractionType.JUKEBOX:
            {
                QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_JukeboxPlaceRadio", 1);
            }
            break;

            case InteractionType.TENT:
            case InteractionType.TENT_SMALL:
            {
                Room.AddTent(Item.Id);
                break;
            }
                #endregion
            }
            QuasarEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, QuestType.FURNI_PLACE); // Quests
            if (!Item.IsWallItem)
            {
                if (Data.Length < 4)
                {
                    return;
                }

                int X        = 0;
                int Y        = 0;
                int Rotation = 0;

                if (!int.TryParse(Data[1], out X))
                {
                    return;
                }
                if (!int.TryParse(Data[2], out Y))
                {
                    return;
                }
                if (!int.TryParse(Data[3], out Rotation))
                {
                    return;
                }

                Item RoomItem = new Item(Item.Id, Room.RoomId, Item.BaseItem, Item.ExtraData, X, Y, 0, Rotation, Session.GetHabbo().Id, Item.GroupId, Item.LimitedNo, Item.LimitedTot, string.Empty, Room);
                if (Room.GetRoomItemHandler().SetFloorItem(Session, RoomItem, X, Y, Rotation, true, false, true))
                {
                    Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId);

                    if (Session.GetHabbo().Id == Room.OwnerId)
                    {
                        QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_RoomDecoFurniCount", 1, false);
                    }

                    if (RoomItem.IsWired)
                    {
                        try { Room.GetWired().LoadWiredBox(RoomItem); }
                        catch { Console.WriteLine(Item.GetBaseItem().InteractionType); }
                    }

                    if (RoomItem.IsTrigger)
                    {
                        QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_WiredExpertTriggers", 1, false);
                    }

                    if (RoomItem.IsAction)
                    {
                        QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_WiredExpertActions", 1, false);
                    }

                    if (RoomItem.IsCondition)
                    {
                        QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_WiredExpertConditions", 1, false);
                    }


                    if (RoomItem.IsHighscore)
                    {
                        QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_WiredExpertHighscores", 1, false);
                    }
                }
                else
                {
                    Session.SendMessage(RoomNotificationComposer.SendBubble("bubble_bouwen", "Oeps! Je kan dit item hier niet plaatsen.", ""));
                    return;
                }
            }
            else if (Item.IsWallItem)
            {
                string[] CorrectedData = new string[Data.Length - 1];

                for (int i = 1; i < Data.Length; i++)
                {
                    CorrectedData[i - 1] = Data[i];
                }

                string WallPos = string.Empty;

                if (TrySetWallItem(Session.GetHabbo(), Item, CorrectedData, out WallPos))
                {
                    try
                    {
                        Item RoomItem = new Item(Item.Id, Room.RoomId, Item.BaseItem, Item.ExtraData, 0, 0, 0, 0, Session.GetHabbo().Id, Item.GroupId, Item.LimitedNo, Item.LimitedTot, WallPos, Room);

                        if (Room.GetRoomItemHandler().SetWallItem(Session, RoomItem))
                        {
                            Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId);
                            if (Session.GetHabbo().Id == Room.OwnerId)
                            {
                                QuasarEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_RoomDecoFurniCount", 1, false);
                            }
                        }
                    }
                    catch
                    {
                        Session.SendMessage(RoomNotificationComposer.SendBubble("bubble_bouwen", "Oeps! Je kan dit item hier niet plaatsen.", ""));
                        return;
                    }
                }
                else
                {
                    Session.SendMessage(RoomNotificationComposer.SendBubble("bubble_bouwen", "Oeps! Je kan dit item hier niet plaatsen.", ""));
                    return;
                }
            }
        }
示例#13
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = null;

            if (!RocketEmulador.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room))
            {
                return;
            }

            int ItemId = 0;

            string[] Data = null;

            string RawData = Packet.PopString();

            Data = RawData.Split(' ');

            if (!int.TryParse(Data[0], out ItemId))
            {
                return;
            }

            bool HasRights = false;

            if (Room.CheckRights(Session, false, true))
            {
                HasRights = true;
            }

            if (!HasRights)
            {
                Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_not_owner}"));
                return;
            }

            Item Item = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId);

            if (Item == null)
            {
                return;
            }

            if (Room.GetRoomItemHandler().GetWallAndFloor.Count() > RocketGame.RoomFurnitureLimit)
            {
                Session.SendNotification("You cannot have more than " + RocketGame.RoomFurnitureLimit + " items in a room!");
                return;
            }
            else if (Item.GetBaseItem().ItemName.ToLower().Contains("cf") && Room.OwnerId != Session.GetHabbo().Id&& !Session.GetHabbo().GetPermissions().HasRight("room_item_place_exchange_anywhere"))
            {
                Session.SendNotification("You cannot place exchange items in other people's rooms!");
                return;
            }

            //TODO: Make neat.
            switch (Item.GetBaseItem().InteractionType)
            {
                #region Interaction Types
            case InteractionType.MOODLIGHT:
            {
                MoodlightData moodData = Room.MoodlightData;
                if (moodData != null && Room.GetRoomItemHandler().GetItem(moodData.ItemId) != null)
                {
                    Session.SendNotification("You can only have one background moodlight per room!");
                    return;
                }
                break;
            }

            case InteractionType.TONER:
            {
                TonerData tonerData = Room.TonerData;
                if (tonerData != null && Room.GetRoomItemHandler().GetItem(tonerData.ItemId) != null)
                {
                    Session.SendNotification("You can only have one background toner per room!");
                    return;
                }
                break;
            }

            case InteractionType.HOPPER:
            {
                if (Room.GetRoomItemHandler().HopperCount > 0)
                {
                    Session.SendNotification("You can only have one hopper per room!");
                    return;
                }
                break;
            }

            case InteractionType.TENT:
            case InteractionType.TENT_SMALL:
            {
                Room.AddTent(Item.Id);
                break;
            }
                #endregion
            }

            if (!Item.IsWallItem)
            {
                if (Data.Length < 4)
                {
                    return;
                }

                int X        = 0;
                int Y        = 0;
                int Rotation = 0;

                if (!int.TryParse(Data[1], out X))
                {
                    return;
                }
                if (!int.TryParse(Data[2], out Y))
                {
                    return;
                }
                if (!int.TryParse(Data[3], out Rotation))
                {
                    return;
                }

                Item RoomItem = new Item(Item.Id, Room.RoomId, Item.BaseItem, Item.ExtraData, X, Y, 0, Rotation, Session.GetHabbo().Id, Item.GroupId, Item.LimitedNo, Item.LimitedTot, string.Empty, Room);
                if (Room.GetRoomItemHandler().SetFloorItem(Session, RoomItem, X, Y, Rotation, true, false, true))
                {
                    Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId);

                    if (Session.GetHabbo().Id == Room.OwnerId)
                    {
                        RocketEmulador.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_RoomDecoFurniCount", 1, false);
                    }

                    if (RoomItem.IsWired)
                    {
                        try { Room.GetWired().LoadWiredBox(RoomItem); }
                        catch { Console.WriteLine(Item.GetBaseItem().InteractionType); }
                    }
                }
                else
                {
                    Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                    return;
                }
            }
            else if (Item.IsWallItem)
            {
                string[] CorrectedData = new string[Data.Length - 1];

                for (int i = 1; i < Data.Length; i++)
                {
                    CorrectedData[i - 1] = Data[i];
                }

                string WallPos = string.Empty;

                if (TrySetWallItem(Session.GetHabbo(), Item, CorrectedData, out WallPos))
                {
                    try
                    {
                        Item RoomItem = new Item(Item.Id, Room.RoomId, Item.BaseItem, Item.ExtraData, 0, 0, 0, 0, Session.GetHabbo().Id, Item.GroupId, Item.LimitedNo, Item.LimitedTot, WallPos, Room);

                        if (Room.GetRoomItemHandler().SetWallItem(Session, RoomItem))
                        {
                            Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId);
                            if (Session.GetHabbo().Id == Room.OwnerId)
                            {
                                RocketEmulador.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_RoomDecoFurniCount", 1, false);
                            }
                        }
                    }
                    catch
                    {
                        Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                        return;
                    }
                }
                else
                {
                    Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                    return;
                }
            }
        }
示例#14
0
 public MoodlightConfigComposer(MoodlightData MoodlightData)
     : base(ServerPacketHeader.MoodlightConfigMessageComposer)
 {
     this.Data = MoodlightData;
 }
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom)
            {
                return;
            }

            if (!NeonEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room Room))
            {
                return;
            }

            string RawData = Packet.PopString();

            string[] Data = RawData.Split(' ');
            if (!int.TryParse(Data[0], out int ItemId))
            {
                return;
            }

            bool HasRights = false;

            if (Room.CheckRights(Session, false, true))
            {
                HasRights = true;
            }

            if (!HasRights)
            {
                Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_not_owner}"));
                return;
            }

            Item Item = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId);

            if (Item == null)
            {
                return;
            }

            if (Room.ForSale)
            {
                Session.SendWhisper("No se puede editar la Sala mientras está a la venta.");
                Session.SendWhisper("Cancela la Venta de la Sala expulsando a todos escribe ':unload' (sin las '')");
                return;
            }

            if (Room.GetRoomItemHandler().GetWallAndFloor.Count() > NeonStaticGameSettings.RoomFurnitureLimit)
            {
                Session.SendNotification("no se puede tener mas de " + NeonStaticGameSettings.RoomFurnitureLimit + " furnis en una sala!");
                return;
            }
            else if (Item.GetBaseItem().ItemName.ToLower().Contains("cf") && Room.OwnerId != Session.GetHabbo().Id&& !Session.GetHabbo().GetPermissions().HasRight("room_item_place_exchange_anywhere"))
            {
                Session.SendNotification("No se puede colocar monedas canjeables en esta sala!");
                return;
            }

            //TODO: Make neat.
            switch (Item.GetBaseItem().InteractionType)
            {
                #region Interaction Types
            case InteractionType.MOODLIGHT:
            {
                MoodlightData moodData = Room.MoodlightData;
                if (moodData != null && Room.GetRoomItemHandler().GetItem(moodData.ItemId) != null)
                {
                    Session.SendNotification("Solo puedes tener un (1) regulador por sala!");
                    return;
                }
                break;
            }

            case InteractionType.TONER:
            {
                TonerData tonerData = Room.TonerData;
                if (tonerData != null && Room.GetRoomItemHandler().GetItem(tonerData.ItemId) != null)
                {
                    Session.SendNotification("Solo puedes tener un (1) pinta fondo por sala!");
                    return;
                }
                break;
            }

            case InteractionType.HOPPER:
            {
                if (Room.GetRoomItemHandler().HopperCount > 0)
                {
                    Session.SendNotification("Solo puedes tener un (1) SaltaSalas en esta habitacion!");
                    return;
                }
                break;
            }

            case InteractionType.TENT:
            case InteractionType.TENT_SMALL:
            {
                Room.AddTent(Item.Id);
                break;
            }
                #endregion
            }

            if (!Item.IsWallItem)
            {
                if (Data.Length < 4)
                {
                    return;
                }

                if (!int.TryParse(Data[1], out int X))
                {
                    return;
                }
                if (!int.TryParse(Data[2], out int Y))
                {
                    return;
                }
                if (!int.TryParse(Data[3], out int Rotation))
                {
                    return;
                }

                Item RoomItem = new Item(Item.Id, Room.RoomId, Item.BaseItem, Item.ExtraData, X, Y, 0, Rotation, Session.GetHabbo().Id, Item.GroupId, Item.LimitedNo, Item.LimitedTot, string.Empty, Room);
                if (Room.GetRoomItemHandler().SetFloorItem(Session, RoomItem, X, Y, Rotation, true, false, true))
                {
                    Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId);

                    if (Session.GetHabbo().Id == Room.OwnerId)
                    {
                        NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_RoomDecoFurniCount", 1, false);
                    }

                    if (RoomItem.IsWired)
                    {
                        try { Room.GetWired().LoadWiredBox(RoomItem); }
                        catch { Console.WriteLine(Item.GetBaseItem().InteractionType); }
                    }
                }
                else
                {
                    Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                    return;
                }
            }
            else if (Item.IsWallItem)
            {
                string[] CorrectedData = new string[Data.Length - 1];

                for (int i = 1; i < Data.Length; i++)
                {
                    CorrectedData[i - 1] = Data[i];
                }

                if (TrySetWallItem(Session.GetHabbo(), Item, CorrectedData, out string WallPos))
                {
                    try
                    {
                        Item RoomItem = new Item(Item.Id, Room.RoomId, Item.BaseItem, Item.ExtraData, 0, 0, 0, 0, Session.GetHabbo().Id, Item.GroupId, Item.LimitedNo, Item.LimitedTot, WallPos, Room);

                        if (Room.GetRoomItemHandler().SetWallItem(Session, RoomItem))
                        {
                            Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId);
                            if (Session.GetHabbo().Id == Room.OwnerId)
                            {
                                NeonEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_RoomDecoFurniCount", 1, false);
                            }
                        }
                    }
                    catch
                    {
                        Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                        return;
                    }
                }
                else
                {
                    Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                    return;
                }
            }
        }
示例#16
0
 private void method_66(bool bool_13)
 {
     if (!this.bool_12)
     {
         this.bool_12 = true;
         if (bool_13)
         {
             this.bool_11 = false;
             if (this.timer_0 != null)
             {
                 this.bool_6 = true;
                 this.timer_0.Change(-1, -1);
             }
             this.method_64();
             using (DatabaseClient @class = GoldTree.GetDatabase().GetClient())
             {
                 @class.ExecuteQuery(string.Concat(new object[]
                 {
                     "UPDATE user_pets SET room_id = 0 WHERE room_id = ",
                     this.uint_0,
                     " AND NOT user_id = ",
                     GoldTree.GetGame().GetClientManager().method_27(this.Owner)
                 }));
             }
             this.timer_0.Dispose();
             this.timer_0 = null;
             this.bool_9 = false;
             if (this.Tags != null)
             {
                 this.Tags.Clear();
             }
             this.Tags = null;
             if (this.RoomUser_0 != null)
             {
                 Array.Clear(this.RoomUser_0, 0, this.RoomUser_0.Length);
             }
             this.RoomUser_0 = null;
             this.class29_0 = null;
             if (this.UsersWithRights != null)
             {
                 this.UsersWithRights.Clear();
             }
             this.class29_0 = null;
             if (this.dictionary_0 != null)
             {
                 this.dictionary_0.Clear();
             }
             this.dictionary_0 = null;
             this.Wallpaper = null;
             this.Floor = null;
             this.Landscape = null;
             if (this.hashtable_0 != null)
             {
                 this.hashtable_0.Clear();
             }
             this.hashtable_0 = null;
             if (this.hashtable_4 != null)
             {
                 this.hashtable_4.Clear();
             }
             this.hashtable_4 = null;
             this.class67_0 = null;
             if (this.list_2 != null)
             {
                 this.list_2.Clear();
             }
             this.list_2 = null;
         }
     }
 }
示例#17
0
        public void Parse(GameClient session, ClientPacket packet)
        {
            if (session == null || session.Habbo == null || !session.Habbo.InRoom)
            {
                return;
            }

            if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(session.Habbo.CurrentRoomId, out Room room))
            {
                return;
            }

            string rawData = packet.PopString();
            var    data    = rawData.Split(' ');

            if (!int.TryParse(data[0], out int itemId))
            {
                return;
            }

            bool hasRights = room.CheckRights(session, false, true);

            if (!hasRights)
            {
                session.SendPacket(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_not_owner}"));
                return;
            }

            Item item = session.Habbo.GetInventoryComponent().GetItem(itemId);

            if (item == null)
            {
                return;
            }

            if (room.GetRoomItemHandler().GetWallAndFloor.Count() > Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("room.item.placement_limit")))
            {
                session.SendNotification("You cannot have more than " + Convert.ToInt32(PlusEnvironment.GetSettingsManager().TryGetValue("room.item.placement_limit")) + " items in a room!");
                return;
            }

            if (item.Data.InteractionType == InteractionType.EXCHANGE && room.OwnerId != session.Habbo.Id && !session.Habbo.GetPermissions().HasRight("room_item_place_exchange_anywhere"))
            {
                session.SendNotification("You cannot place exchange items in other people's rooms!");
                return;
            }

            //TODO: Make neat.
            switch (item.GetBaseItem().InteractionType)
            {
                #region Interaction Types
            case InteractionType.MOODLIGHT:
            {
                MoodlightData moodData = room.MoodlightData;
                if (moodData != null && room.GetRoomItemHandler().GetItem(moodData.ItemId) != null)
                {
                    session.SendNotification("You can only have one background moodlight per room!");
                    return;
                }
                break;
            }

            case InteractionType.TONER:
            {
                TonerData tonerData = room.TonerData;
                if (tonerData != null && room.GetRoomItemHandler().GetItem(tonerData.ItemId) != null)
                {
                    session.SendNotification("You can only have one background toner per room!");
                    return;
                }
                break;
            }

            case InteractionType.HOPPER:
            {
                if (room.GetRoomItemHandler().HopperCount > 0)
                {
                    session.SendNotification("You can only have one hopper per room!");
                    return;
                }
                break;
            }

            case InteractionType.TENT:
            case InteractionType.TENT_SMALL:
            {
                room.AddTent(item.Id);
                break;
            }
                #endregion
            }

            if (!item.IsWallItem)
            {
                if (data.Length < 4)
                {
                    return;
                }

                if (!int.TryParse(data[1], out int x))
                {
                    return;
                }
                if (!int.TryParse(data[2], out int y))
                {
                    return;
                }
                if (!int.TryParse(data[3], out int rotation))
                {
                    return;
                }

                Item roomItem = new Item(item.Id, room.RoomId, item.BaseItem, item.ExtraData, x, y, 0, rotation, session.Habbo.Id, item.GroupId, item.LimitedNo, item.LimitedTot, string.Empty, room);
                if (room.GetRoomItemHandler().SetFloorItem(session, roomItem, x, y, rotation, true, false, true))
                {
                    session.Habbo.GetInventoryComponent().RemoveItem(itemId);

                    if (session.Habbo.Id == room.OwnerId)
                    {
                        _achievementManager.ProgressAchievement(session, "ACH_RoomDecoFurniCount", 1);
                    }

                    if (roomItem.IsWired)
                    {
                        try { room.GetWired().LoadWiredBox(roomItem); }
                        catch { Console.WriteLine(item.GetBaseItem().InteractionType); }
                    }
                }
                else
                {
                    session.SendPacket(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                }
            }
            else if (item.IsWallItem)
            {
                string[] correctedData = new string[data.Length - 1];

                for (int i = 1; i < data.Length; i++)
                {
                    correctedData[i - 1] = data[i];
                }

                if (TrySetWallItem(correctedData, out string wallPos))
                {
                    try
                    {
                        Item roomItem = new Item(item.Id, room.RoomId, item.BaseItem, item.ExtraData, 0, 0, 0, 0, session.Habbo.Id, item.GroupId, item.LimitedNo, item.LimitedTot, wallPos, room);

                        if (room.GetRoomItemHandler().SetWallItem(session, roomItem))
                        {
                            session.Habbo.GetInventoryComponent().RemoveItem(itemId);
                            if (session.Habbo.Id == room.OwnerId)
                            {
                                _achievementManager.ProgressAchievement(session, "ACH_RoomDecoFurniCount", 1);
                            }
                        }
                    }
                    catch
                    {
                        session.SendPacket(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                    }
                }
                else
                {
                    session.SendPacket(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                }
            }
        }
示例#18
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = null;

            if (!CloudServer.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room))
            {
                return;
            }

            int ItemId = 0;

            string[] Data = null;

            string RawData = Packet.PopString();

            Data = RawData.Split(' ');

            if (!int.TryParse(Data[0], out ItemId))
            {
                return;
            }

            bool HasRights = false;

            if (Room.CheckRights(Session, false, true))
            {
                HasRights = true;
            }

            if (!HasRights)
            {
                Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_not_owner}"));
                return;
            }

            Item Item = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId);

            if (Item == null)
            {
                return;
            }

            if (Room.ForSale)
            {
                Session.SendWhisper("Você não pode editar o quarto enquanto ele esta a venda");
                Session.SendWhisper("Para cancelar a venda digite ':unload' (sem'')");
                return;
            }

            if (Room.GetRoomItemHandler().GetWallAndFloor.Count() > Convert.ToInt32(CloudServer.GetGame().GetSettingsManager().TryGetValue("room.item.placement_limit")))
            {
                Session.SendNotification("Você não pode ter mais de " + Convert.ToInt32(CloudServer.GetGame().GetSettingsManager().TryGetValue("room.item.placement_limit")) + " mobs em uma sala!");
                return;
            }
            else if (Item.GetBaseItem().ItemName.ToLower().Contains("cf") && Room.OwnerId != Session.GetHabbo().Id&& !Session.GetHabbo().GetPermissions().HasRight("room_item_place_exchange_anywhere"))
            {
                Session.SendNotification("Você não pode colocar moedas trocadas nesta sala!");
                return;
            }

            //TODO: Make neat.
            switch (Item.GetBaseItem().InteractionType)
            {
                #region Interaction Types
            case InteractionType.MOODLIGHT:
            {
                MoodlightData moodData = Room.MoodlightData;
                if (moodData != null && Room.GetRoomItemHandler().GetItem(moodData.ItemId) != null)
                {
                    Session.SendNotification("Você pode ter apenas um (1) regulador de quarto!");
                    return;
                }
                break;
            }

            case InteractionType.TONER:
            {
                TonerData tonerData = Room.TonerData;
                if (tonerData != null && Room.GetRoomItemHandler().GetItem(tonerData.ItemId) != null)
                {
                    Session.SendNotification("Você pode ter apenas um (1) Sala de fundo pintado!");
                    return;
                }
                break;
            }

            case InteractionType.HOPPER:
            {
                if (Room.GetRoomItemHandler().HopperCount > 0)
                {
                    Session.SendNotification("Você só pode ter um (1) SaltaSalas nesta sala!");
                    return;
                }
                break;
            }

            case InteractionType.TENT:
            case InteractionType.TENT_SMALL:
            {
                Room.AddTent(Item.Id);
                break;
            }
                #endregion
            }

            if (!Item.IsWallItem)
            {
                if (Data.Length < 4)
                {
                    return;
                }

                int X        = 0;
                int Y        = 0;
                int Rotation = 0;

                if (!int.TryParse(Data[1], out X))
                {
                    return;
                }
                if (!int.TryParse(Data[2], out Y))
                {
                    return;
                }
                if (!int.TryParse(Data[3], out Rotation))
                {
                    return;
                }

                Item RoomItem = new Item(Item.Id, Room.RoomId, Item.BaseItem, Item.ExtraData, X, Y, 0, Rotation, Session.GetHabbo().Id, Item.GroupId, Item.LimitedNo, Item.LimitedTot, string.Empty, Room);
                if (Room.GetRoomItemHandler().SetFloorItem(Session, RoomItem, X, Y, Rotation, true, false, true))
                {
                    Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId);

                    if (Session.GetHabbo().Id == Room.OwnerId)
                    {
                        CloudServer.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_RoomDecoFurniCount", 1, false);
                    }

                    if (RoomItem.IsWired)
                    {
                        try { Room.GetWired().LoadWiredBox(RoomItem); }
                        catch { Console.WriteLine(Item.GetBaseItem().InteractionType); }
                    }
                }
                else
                {
                    Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                    return;
                }
            }
            else if (Item.IsWallItem)
            {
                string[] CorrectedData = new string[Data.Length - 1];

                for (int i = 1; i < Data.Length; i++)
                {
                    CorrectedData[i - 1] = Data[i];
                }

                string WallPos = string.Empty;

                if (TrySetWallItem(Session.GetHabbo(), Item, CorrectedData, out WallPos))
                {
                    try
                    {
                        Item RoomItem = new Item(Item.Id, Room.RoomId, Item.BaseItem, Item.ExtraData, 0, 0, 0, 0, Session.GetHabbo().Id, Item.GroupId, Item.LimitedNo, Item.LimitedTot, WallPos, Room);

                        if (Room.GetRoomItemHandler().SetWallItem(Session, RoomItem))
                        {
                            Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId);
                            if (Session.GetHabbo().Id == Room.OwnerId)
                            {
                                CloudServer.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_RoomDecoFurniCount", 1, false);
                            }
                        }
                    }
                    catch
                    {
                        Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                        return;
                    }
                }
                else
                {
                    Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                    return;
                }
            }
        }
        public void Dispose()
        {
            SendMessage(new CloseConnectionComposer());

            if (!mDisposed)
            {
                isCrashed = false;
                mDisposed = true;

                try
                {
                    if (ProcessTask != null && ProcessTask.IsCompleted)
                    {
                        ProcessTask.Dispose();
                    }
                }
                catch { }

                GetRoomItemHandler().SaveFurniture();

                using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.runFastQuery("UPDATE `rooms` SET `users_now` = '0' WHERE `id` = '" + Id + "' LIMIT 1");
                }

                if (this._roomUserManager.PetCount > 0)
                {
                    this._roomUserManager.UpdatePets();
                }

                this.SaveAI();

                UsersNow          = 0;
                RoomData.UsersNow = 0;

                UsersWithRights.Clear();
                Bans.Clear();
                MutedUsers.Clear();
                Tents.Clear();

                this.TonerData     = null;
                this.MoodlightData = null;

                this._filterComponent.Cleanup();
                this._wiredComponent.Cleanup();

                if (this._gameItemHandler != null)
                {
                    this._gameItemHandler.Dispose();
                }

                if (this._gameManager != null)
                {
                    this._gameManager.Dispose();
                }

                if (this._freeze != null)
                {
                    this._freeze.Dispose();
                }

                if (this._banzai != null)
                {
                    this._banzai.Dispose();
                }

                if (this._soccer != null)
                {
                    this._soccer.Dispose();
                }

                if (this._gamemap != null)
                {
                    this._gamemap.Dispose();
                }

                if (this._roomUserManager != null)
                {
                    this._roomUserManager.Dispose();
                }

                if (this._roomItemHandling != null)
                {
                    this._roomItemHandling.Dispose();
                }



                if (ActiveTrades.Count > 0)
                {
                    ActiveTrades.Clear();
                }
            }
        }
示例#20
0
        public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet)
        {
            if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom)
            {
                return;
            }

            Room Room = null;

            if (!PlusEnvironment.GetGame().GetRoomManager().TryGetRoom(Session.GetHabbo().CurrentRoomId, out Room))
            {
                return;
            }

            int ItemId = 0;

            string[] Data = null;

            string RawData = Packet.PopString();

            Data = RawData.Split(' ');

            if (!int.TryParse(Data[0], out ItemId))
            {
                return;
            }

            bool HasRights = false;

            if (Room.CheckRights(Session, false, true))
            {
                HasRights = true;
            }

            var  RentableItems = Room.GetRoomItemHandler().GetFloor.Where(x => x.GetBaseItem().InteractionType == InteractionType.RENTABLE_SPACE).ToList();
            Item SpaceItem     = null;

            if (RentableItems.Count > 0)
            {
                foreach (var RentableSpace in RentableItems)
                {
                    var SpaceData = RentableSpace.RentableSpaceData;

                    if (SpaceData == null)
                    {
                        continue;
                    }

                    if (SpaceData.FarmingSpace != null)
                    {
                        continue;
                    }

                    if (SpaceData.OwnerId != Session.GetHabbo().Id)
                    {
                        continue;
                    }

                    HasRights = true;
                    SpaceItem = RentableSpace;
                    break;
                }
            }

            if (!HasRights)
            {
                Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_not_owner}"));
                return;
            }

            Item Item = Session.GetHabbo().GetInventoryComponent().GetItem(ItemId);

            if (Item == null)
            {
                return;
            }

            if (Room.GetRoomItemHandler().GetWallAndFloor.Count() > PlusStaticGameSettings.RoomFurnitureLimit)
            {
                Session.SendNotification("Você não pode ter mais do que " + PlusStaticGameSettings.RoomFurnitureLimit + " items no quarto!");
                return;
            }
            else if (Item.GetBaseItem().ItemName.ToLower().Contains("cf") && Room.OwnerId != Session.GetHabbo().Id&& !Session.GetHabbo().GetPermissions().HasRight("room_item_place_exchange_anywhere"))
            {
                Session.SendNotification("Você não pode colocar itens de troca em salas de outras pessoas!");
                return;
            }

            //TODO: Make neat.
            switch (Item.GetBaseItem().InteractionType)
            {
                #region Interaction Types
            case InteractionType.MOODLIGHT:
            {
                MoodlightData moodData = Room.MoodlightData;
                if (moodData != null && Room.GetRoomItemHandler().GetItem(moodData.ItemId) != null)
                {
                    Session.SendNotification("Você só pode ter um estilo de fundo claro por sala!");
                    return;
                }
                break;
            }

            case InteractionType.TONER:
            {
                TonerData tonerData = Room.TonerData;
                if (tonerData != null && Room.GetRoomItemHandler().GetItem(tonerData.ItemId) != null)
                {
                    Session.SendNotification("Você só pode ter um toner de fundo por sala!");
                    return;
                }
                break;
            }

            case InteractionType.HOPPER:
            {
                if (Room.GetRoomItemHandler().HopperCount > 0)
                {
                    Session.SendNotification("Você só pode ter um funil por sala!");
                    return;
                }
                break;
            }

            case InteractionType.TENT:
            case InteractionType.TENT_SMALL:
            {
                Room.AddTent(Item.Id);
                break;
            }
                #endregion
            }

            if (!Item.IsWallItem)
            {
                if (Data.Length < 4)
                {
                    return;
                }

                int X        = 0;
                int Y        = 0;
                int Rotation = 0;

                if (!int.TryParse(Data[1], out X))
                {
                    return;
                }
                if (!int.TryParse(Data[2], out Y))
                {
                    return;
                }
                if (!int.TryParse(Data[3], out Rotation))
                {
                    return;
                }

                Item RoomItem = new Item(Item.Id, Room.RoomId, Item.BaseItem, Item.ExtraData, X, Y, 0, Rotation, Session.GetHabbo().Id, Item.GroupId, Item.LimitedNo, Item.LimitedTot, string.Empty, Room);
                if (Room.GetRoomItemHandler().SetFloorItem(Session, RoomItem, X, Y, Rotation, true, false, true, false, true, SpaceItem))
                {
                    Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId);

                    if (RoomItem.IsWired)
                    {
                        try { Room.GetWired().LoadWiredBox(RoomItem); }
                        catch { Console.WriteLine(Item.GetBaseItem().InteractionType); }
                    }

                    if (!Item.GetBaseItem().IsSeat)
                    {
                        foreach (var square in Item.GetAffectedTiles)
                        {
                            if (Room.GetGameMap().SquareHasUsers(square.X, square.Y))
                            {
                                foreach (var user in Room.GetGameMap().GetRoomUsers(square))
                                {
                                    if (!user.IsWalking)
                                    {
                                        user.SetPos(user.Coordinate.X, user.Coordinate.Y, Room.GetGameMap().GetHeightForSquare(square));
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                    return;
                }
            }
            else if (Item.IsWallItem)
            {
                string[] CorrectedData = new string[Data.Length - 1];

                for (int i = 1; i < Data.Length; i++)
                {
                    CorrectedData[i - 1] = Data[i];
                }

                string WallPos = string.Empty;

                if (TrySetWallItem(Session.GetHabbo(), Item, CorrectedData, out WallPos))
                {
                    try
                    {
                        Item RoomItem = new Item(Item.Id, Room.RoomId, Item.BaseItem, Item.ExtraData, 0, 0, 0, 0, Session.GetHabbo().Id, Item.GroupId, Item.LimitedNo, Item.LimitedTot, WallPos, Room);

                        if (Room.GetRoomItemHandler().SetWallItem(Session, RoomItem))
                        {
                            Session.GetHabbo().GetInventoryComponent().RemoveItem(ItemId);
                            //if (Session.GetHabbo().Id == Room.OwnerId)
                            //PlusEnvironment.GetGame().GetAchievementManager().ProgressAchievement(Session, "ACH_RoomDecoFurniCount", 1, false);
                        }
                    }
                    catch
                    {
                        Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                        return;
                    }
                }
                else
                {
                    Session.SendMessage(new RoomNotificationComposer("furni_placement_error", "message", "${room.error.cant_set_item}"));
                    return;
                }
            }
        }