Beispiel #1
0
        private static void AddToPlaylist(GameClient Session, ClientMessage Message)
        {
            Room Instance = Session.GetHabbo().CurrentRoom;

            if (Instance == null || !Instance.CheckRights(Session, true) || !Instance.GotMusicController() ||
                Instance.GetRoomMusicController().PlaylistSize >= Instance.GetRoomMusicController().PlaylistCapacity)
            {
                return;
            }

            UserItem DiskUserItem = Session.GetHabbo().GetInventoryComponent().GetItem(Message.PopWiredUInt());

            if (DiskUserItem == null || DiskUserItem.GetBaseItem().InteractionType != InteractionType.musicdisc)
            {
                return;
            }

            SongItem item = new SongItem(DiskUserItem);

            int NewOrder = Instance.GetRoomMusicController().AddDisk(item);

            if (NewOrder < 0)
            {
                return;
            }

            Session.GetHabbo().GetInventoryComponent().RemoveItem(item.itemID, true);

            Session.SendMessage(JukeboxComposer.Compose(Instance.GetRoomMusicController().PlaylistCapacity,
                Instance.GetRoomMusicController().Playlist.Values.ToList()));
        }
Beispiel #2
0
        public void Parse(GameClient Session, ClientMessage Packet)
        {
            Room Room = SilverwaveEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

            if (Room == null)
            {
                return;
            }

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

            if (User == null)
            {
                return;
            }

            User.UnIdle();

            int Action = Packet.PopWiredInt32();
            User.DanceId = 0;

            Room.SendMessage(new ActionComposer(User, Action));

            if (Action == 5) // idle
            {
                User.IsAsleep = true;
                Room.SendMessage(new SleepComposer(User, true));
            }

            SilverwaveEnvironment.GetGame().GetQuestManager().ProgressUserQuest(Session, HabboHotel.Quests.QuestType.SOCIAL_WAVE);
        }
Beispiel #3
0
 void parser_onNewPacket(ClientMessage Message)
 {
     try
     {
         MessageHandler.HandleRequest(Message);
     }
     catch (Exception e) { Logging.LogPacketException(Message.ToString(), e.ToString()); }
 }
 internal void HandleRequest(ClientMessage request)
 {
     if (!SilverwaveEnvironment.GetGame().GetPacketManager().TryExecutePacket(this.Session, request))
     {
         this.Request = request;
         StaticClientMessageHandler.HandlePacket(this, request);
     }
 }
Beispiel #5
0
        internal void ActivateQuest(GameClient Session, ClientMessage Message)
        {
            Quest Quest = GetQuest(Message.PopWiredUInt());

            if (Quest == null)
            {
                return;
            }

            using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("REPLACE INTO user_quests(user_id,quest_id) VALUES (" + Session.GetHabbo().Id + ", " + Quest.Id + ")");
                dbClient.runFastQuery("UPDATE user_stats SET quest_id = " + Quest.Id + " WHERE id = " + Session.GetHabbo().Id);
            }

            Session.GetHabbo().CurrentQuestId = Quest.Id;
                GetList(Session, null);
                Session.SendMessage(QuestStartedComposer.Compose(Session, Quest));
        }
Beispiel #6
0
        private static List<RoomItem> GetFurniItems(ClientMessage Request, Room Room)
        {
            List<RoomItem> Items = new List<RoomItem>();

            int FurniCount = Request.PopWiredInt32();

            for (int i = 0; i < FurniCount; i++)
            {
                RoomItem Item = Room.GetRoomItemHandler().GetItem(Request.PopWiredUInt());

                if (Item != null)
                {
                    Items.Add(Item);
                }
            }

            return Items;
        }
Beispiel #7
0
        public void ExecutePacket(GameClient Session, ClientMessage Packet)
        {
            IPacketEvent Pak = null;

            if (!this._incomingPackets.TryGetValue(Packet.Id, out Pak))
            {
                return;
            }

            if (!IgnoreTasks)
            {
                ExecutePacketAsync(Session, Packet, Pak);
            }
            else
            {
                Pak.Parse(Session, Packet);
            }
        }
Beispiel #8
0
        private void ExecutePacketAsync(GameClient Session, ClientMessage Packet, IPacketEvent Pak)
        {
            DateTime Start = DateTime.Now;

            var CancelSource = new CancellationTokenSource();
            var Token = CancelSource.Token;

            Task t = _eventDispatcher.StartNew(() =>
            {
                Pak.Parse(Session, Packet);
                Token.ThrowIfCancellationRequested();
            }, Token);

            this._runningTasks.TryAdd(t.Id, t);

            try
            {
                if (!t.Wait(MaximumRunTimeInSec * 1000, Token))
                {
                    CancelSource.Cancel();
                }
            }
            catch (AggregateException ex)
            {
                foreach (var e in ex.Flatten().InnerExceptions)
                {
                    if (ThrowUserErrors)
                    {
                        throw e;
                    }
                    else
                    {
                        //log.Fatal("Unhandled Error: " + e.Message + " - " + e.StackTrace);
                        Session.Disconnect();
                    }
                }
            }
            catch (OperationCanceledException)
            {
                Session.Disconnect();
            }
            finally
            {
                Task RemovedTask = null;
                this._runningTasks.TryRemove(t.Id, out RemovedTask);

                CancelSource.Dispose();

                //log.Debug("Event took " + (DateTime.Now - Start).Milliseconds + "ms to complete.");
            }
        }
Beispiel #9
0
        public bool TryExecutePacket(GameClient Session, ClientMessage Packet)
        {
            IPacketEvent Pak = null;

            if (!this._incomingPackets.TryGetValue(Packet.Id, out Pak))
            {
                return false;
            }

            WriteLine("Cargado ->" + Packet.ToString(), ConsoleColor.White);// WriteLine("Handled Packet:" + Packet.ToString(), ConsoleColor.Green); )

            if (!IgnoreTasks)
            {
                ExecutePacketAsync(Session, Packet, Pak);
                return true;
            }
            else
            {
                Pak.Parse(Session, Packet);
                return true;
            }
        }
Beispiel #10
0
        internal void GetCurrentQuest(GameClient Session, ClientMessage Message)
        {
            if (!Session.GetHabbo().InRoom)
            {
                return;
            }

            Quest UserQuest = GetQuest(Session.GetHabbo().LastCompleted);
            Quest NextQuest = GetNextQuestInSeries(UserQuest.Category, UserQuest.Number + 1);

            if (NextQuest == null)
            {
                return;
            }

            using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("REPLACE INTO user_quests(user_id,quest_id) VALUES (" + Session.GetHabbo().Id + ", " + NextQuest.Id + ")");
                dbClient.runFastQuery("UPDATE user_stats SET quest_id = " + NextQuest.Id + " WHERE id = " + Session.GetHabbo().Id);
            }

            Session.GetHabbo().CurrentQuestId = NextQuest.Id;
            GetList(Session, null);
            Session.SendMessage(QuestStartedComposer.Compose(Session, NextQuest));
        }
Beispiel #11
0
 internal void GetList(GameClient Session, ClientMessage Message)
 {
     Session.SendMessage(QuestListComposer.Compose(Session, quests.Values.ToList(), (Message != null)));
 }
Beispiel #12
0
 private static void GetDisks(GameClient Session, ClientMessage Message)
 {
     Session.SendMessage(JukeboxComposer.Compose(Session));
 }
Beispiel #13
0
        internal void CancelQuest(GameClient Session, ClientMessage Message)
        {
            Quest Quest = GetQuest(Session.GetHabbo().CurrentQuestId);

            if (Quest == null)
            {
                return;
            }

            using (IQueryAdapter dbClient = SilverwaveEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.runFastQuery("DELETE FROM user_quests WHERE user_id = " + Session.GetHabbo().Id + " AND quest_id = " + Quest.Id + ";" +
                    "UPDATE user_stats SET quest_id=0 WHERE id=" + Session.GetHabbo().Id);
            }
            Session.GetHabbo().CurrentQuestId = 0;
            Session.SendMessage(QuestAbortedComposer.Compose());
            GetList(Session, null);
        }
Beispiel #14
0
        public static void SaveWired(GameClient Session, RoomItem Item, ClientMessage Request)
        {
            if (!Item.IsWired)
            {
                return;
            }

            Room Room = Item.GetRoom();
            WiredHandler Handler = Room.GetWiredHandler();

            switch (Item.GetBaseItem().InteractionType)
            {
                #region Triggers
                case InteractionType.triggerroomenter:
                    {
                        int Unknown = Request.PopWiredInt32();
                        string User = Request.PopFixedString();

                        WiredItem WItem = Handler.GetWired(Item);
                        WItem.OtherString = User;
                        Handler.ReloadWired(WItem);

                        break;
                    }

                case InteractionType.triggeronusersay:
                    {
                        int Unknown = Request.PopWiredInt32();
                        int OwnerOnly = Request.PopWiredInt32();
                        string Message = Request.PopFixedString();

                        WiredItem WItem = Handler.GetWired(Item);
                        WItem.OtherString = Message;
                        WItem.OtherBool = (OwnerOnly == 1);
                        Handler.ReloadWired(WItem);

                        break;
                    }

                case InteractionType.triggerrepeater:
                    {
                        int Unknown = Request.PopWiredInt32();
                        int Delay = Request.PopWiredInt32() * 500;

                        WiredItem WItem = Handler.GetWired(Item);
                        WItem.Delay = Delay;
                        Handler.ReloadWired(WItem);
                        break;
                    }

                case InteractionType.triggerstatechanged:
                    {
                        int Unknown = Request.PopWiredInt32();
                        string Unknown2 = Request.PopFixedString();

                        List<RoomItem> Items = GetFurniItems(Request, Room);

                        int Delay = Request.PopWiredInt32();

                        WiredItem WItem = Handler.GetWired(Item);
                        WItem.Delay = Delay * 500;
                        WItem.Items = Items;
                        Handler.ReloadWired(WItem);
                        break;
                    }

                case InteractionType.triggerwalkonfurni:
                    {
                        int Unknown = Request.PopWiredInt32();
                        string Message = Request.PopFixedString();

                        List<RoomItem> Items = GetFurniItems(Request, Room);

                        int Delay = Request.PopWiredInt32();

                        WiredItem WItem = Handler.GetWired(Item);
                        WItem.Delay = Delay * 500;
                        WItem.Items = Items;
                        Handler.ReloadWired(WItem);
                        break;
                    }

                case InteractionType.triggerwalkofffurni:
                    {
                        int Unknown = Request.PopWiredInt32();
                        string Message = Request.PopFixedString();

                        List<RoomItem> Items = GetFurniItems(Request, Room);

                        int Delay = Request.PopWiredInt32();

                        WiredItem WItem = Handler.GetWired(Item);
                        WItem.Delay = Delay * 500;
                        WItem.Items = Items;
                        Handler.ReloadWired(WItem);
                        break;
                    }
                #endregion

                #region Effects
                case InteractionType.actionkickuser:
                case InteractionType.actionshowmessage:
                    {
                        int Unknown = Request.PopWiredInt32();
                        string Message = Request.PopFixedString();

                        WiredItem WItem = Handler.GetWired(Item);
                        WItem.OtherString = Message;
                        Handler.ReloadWired(WItem);
                        break;
                    }

                case InteractionType.actionteleportto:
                    {
                        int Unknown = Request.PopWiredInt32();
                        string Unknown2 = Request.PopFixedString();

                        List<RoomItem> Items = GetFurniItems(Request, Room);

                        int Delay = Request.PopWiredInt32();

                        WiredItem WItem = Handler.GetWired(Item);
                        WItem.Items = Items;
                        WItem.Delay = Delay * 500;
                        Handler.ReloadWired(WItem);

                        break;
                    }

                case InteractionType.actiontogglestate:
                    {
                        int Unknown = Request.PopWiredInt32();
                        string Unknown2 = Request.PopFixedString();

                        List<RoomItem> Items = GetFurniItems(Request, Room);

                        int Delay = Request.PopWiredInt32();

                        WiredItem WItem = Handler.GetWired(Item);
                        WItem.Items = Items;
                        WItem.Delay = Delay * 500;
                        Handler.ReloadWired(WItem);
                        break;
                    }

                case InteractionType.actionmoverotate:
                    {
                        int Unknown = Request.PopWiredInt32();
                        int Movement = Request.PopWiredInt32();
                        int Rotation = Request.PopWiredInt32();
                        string Unknown2 = Request.PopFixedString();

                        List<RoomItem> Items = GetFurniItems(Request, Room);

                        int Delay = Request.PopWiredInt32();

                        WiredItem WItem = Handler.GetWired(Item);
                        WItem.Items = Items;
                        WItem.Delay = Delay * 500;
                        WItem.OtherString = Rotation + ";" + Movement;
                        Handler.ReloadWired(WItem);
                        break;
                    }
                #endregion

                #region Conditions
                case InteractionType.conditionfurnishaveusers:
                case InteractionType.conditionfurnihasfurni:
                case InteractionType.conditiontriggeronfurni:
                    {
                        int Unknown = Request.PopWiredInt32();
                        string Unknown2 = Request.PopFixedString();

                        List<RoomItem> Items = GetFurniItems(Request, Room);

                        WiredItem WItem = Handler.GetWired(Item);
                        WItem.Items = Items;
                        Handler.ReloadWired(WItem);
                        break;
                    }
                #endregion
            }

            Session.SendMessage(new ServerMessage(Outgoing.SaveWired));
        }
Beispiel #15
0
        private static void GetPlaylist(GameClient Session, ClientMessage Message)
        {
            Room Instance = Session.GetHabbo().CurrentRoom;

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

            Session.SendMessage(JukeboxComposer.Compose(Instance.GetRoomMusicController().PlaylistCapacity,
                Instance.GetRoomMusicController().Playlist.Values.ToList()));
        }
Beispiel #16
0
 internal void GetList(GameClient Session, ClientMessage Message)
 {
     Session.SendMessage(AchievementListComposer.Compose(Session, Achievements.Values.ToList()));
 }
Beispiel #17
0
        private static void GetSongData(GameClient Session, ClientMessage Message)
        {
            int Amount = Message.PopWiredInt32();
            List<SongData> Songs = new List<SongData>();

            for (int i = 0; i < Amount; i++)
            {
                SongData Song = GetSong(Message.PopWiredUInt());

                if (Song == null)
                    continue;

                Songs.Add(Song);
            }

            Session.SendMessage(JukeboxComposer.Compose(Songs));
        }
Beispiel #18
0
        private static void RemoveFromPlaylist(GameClient Session, ClientMessage Message)
        {
            Room Instance = Session.GetHabbo().CurrentRoom;

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

            SongItem TakenItem = Instance.GetRoomMusicController().RemoveDisk(Message.PopWiredInt32());
            // playlist will skip to the next item automatically if it has to

            if (TakenItem == null)
            {
                return;
            }

            Session.GetHabbo().GetInventoryComponent().AddNewItem(TakenItem.itemID, TakenItem.baseItem.ItemId, TakenItem.songID.ToString(), 0, true, true,0,0);

            Session.SendMessage(JukeboxComposer.Compose(Session));
            Session.SendMessage(JukeboxComposer.Compose(Instance.GetRoomMusicController().PlaylistCapacity,
                Instance.GetRoomMusicController().Playlist.Values.ToList()));
        }