Exemplo n.º 1
0
        /// <summary>
        /// Gets the inventory.
        /// </summary>
        internal void GetInventory()
        {
            var queuedServerMessage = new QueuedServerMessage(Session.GetConnection());

            queuedServerMessage.AppendResponse(Session.GetHabbo().GetInventoryComponent().SerializeFloorItemInventory());
            queuedServerMessage.SendResponse();
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Gets the inventory.
        /// </summary>
        internal void GetInventory()
        {
            QueuedServerMessage queuedServerMessage = new QueuedServerMessage(Session.GetConnection());

            queuedServerMessage.AppendResponse(Session.GetHabbo().GetInventoryComponent().SerializeFloorItemInventory());
            queuedServerMessage.SendResponse();
        }
Exemplo n.º 3
0
        internal bool tryLogin(string AuthTicket)
        {
            try
            {
                if (GetConnection() == null)
                {
                    return(false);
                }

                var userData = UserDataFactory.GetUserData(AuthTicket);
                if (userData == null)
                {
                    this.Disconnect();
                    return(false);
                }

                OtanixEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.user.Id, userData.user.Username);
                Habbo = userData.user;

                if (userData.user.Username == null || GetHabbo() == null)
                {
                    SendBanMessage("Você não possui um nome.");
                    return(false);
                }

                userData.user.Init(userData);
                Habbo.MachineId = MachineId;

                var response = new QueuedServerMessage(Connection);

                var authok = new ServerMessage(Outgoing.AuthenticationOK);
                response.AppendResponse(authok);

                //HabboEnvironment.GetGame().GetUserLookManager().Load();
                var HomeRoom = new ServerMessage(Outgoing.HomeRoom);
                HomeRoom.AppendUInt((OtanixEnvironment.GetGame().GetPrisaoManager().estaPreso(GetHabbo().Id)) ? OtanixEnvironment.prisaoId() : GetHabbo().HomeRoom); // first home
                HomeRoom.AppendUInt((OtanixEnvironment.GetGame().GetPrisaoManager().estaPreso(GetHabbo().Id)) ? OtanixEnvironment.prisaoId() : GetHabbo().HomeRoom); // current home
                response.AppendResponse(HomeRoom);

                var FavouriteRooms = new ServerMessage(Outgoing.FavouriteRooms);
                FavouriteRooms.AppendInt32(30); // max rooms
                FavouriteRooms.AppendInt32(userData.user.FavoriteRooms.Count);
                foreach (var Id in userData.user.FavoriteRooms.ToArray())
                {
                    FavouriteRooms.AppendUInt(Id);
                }
                response.AppendResponse(FavouriteRooms);

                ServerMessage sendClub = new ServerMessage(Outgoing.SerializeClub);
                sendClub.AppendString("club_habbo");

                if (GetHabbo().GetClubManager().GetSubscription("club_habbo") != null)
                {
                    double TimeLeft      = GetHabbo().GetClubManager().GetSubscription("club_habbo").TimestampExpire - OtanixEnvironment.GetUnixTimestamp();
                    int    TotalDaysLeft = (int)Math.Ceiling(TimeLeft / 86400);
                    int    MonthsLeft    = TotalDaysLeft / 31;

                    if (MonthsLeft >= 1)
                    {
                        MonthsLeft--;
                    }

                    sendClub.AppendInt32(TotalDaysLeft - (MonthsLeft * 31));
                    sendClub.AppendInt32(0);
                    sendClub.AppendInt32(MonthsLeft);

                    if (GetHabbo().GetClubManager().GetSubscription("club_habbo").TimeLeftInHours <= 72)
                    {
                        sendClub.AppendInt32(3);
                    }

                    else
                    {
                        sendClub.AppendInt32(1);
                    }

                    sendClub.AppendBoolean(true);
                    sendClub.AppendBoolean(true);
                    sendClub.AppendInt32(0);
                    sendClub.AppendInt32(GetHabbo().GetClubManager().GetTotalMembershipLength);
                    sendClub.AppendInt32(GetHabbo().GetClubManager().GetSubscription("club_habbo").TimeLeft);
                    sendClub.AppendInt32(GetHabbo().GetClubManager().GetSubscription("club_habbo").TimeLeft);
                }

                else
                {
                    sendClub.AppendInt32(0);
                    sendClub.AppendInt32(0);
                    sendClub.AppendInt32(0);
                    sendClub.AppendInt32(0); // type
                    sendClub.AppendBoolean(false);
                    sendClub.AppendBoolean(false);
                    sendClub.AppendInt32(0);
                    sendClub.AppendInt32(0); //days i have on hc
                    sendClub.AppendInt32(0); // days i have on vip
                    sendClub.AppendInt32(0);
                }
                response.AppendResponse(sendClub);


                var roomAccessConfig = new ServerMessage(Outgoing.RoomAccessConfig);
                roomAccessConfig.AppendBoolean(true); // isOpen
                roomAccessConfig.AppendBoolean(false);
                roomAccessConfig.AppendBoolean(true);
                response.AppendResponse(roomAccessConfig);

                var fuserights = new ServerMessage(Outgoing.Fuserights);
                fuserights.AppendInt32(GetHabbo().GetClubManager().UserHasSubscription("club_habbo") ? 2 : 1); // normal|hc|vip
                fuserights.AppendUInt(GetHabbo().Rank);
                fuserights.AppendBoolean(GetHabbo().HasFuse("fuse_ambassador"));                               // embajador ?
                // fuserights.AppendInt32(0); // New Identity (1 == 1 min and Alert!)
                response.AppendResponse(fuserights);

                var newidentity = new ServerMessage(Outgoing.SendNewIdentityState);
                newidentity.AppendInt32(GetHabbo().NewIdentity);
                response.AppendResponse(newidentity);

                var HabboInformation = new ServerMessage(Outgoing.HabboInfomation);
                HabboInformation.AppendUInt(GetHabbo().Id);
                HabboInformation.AppendString(GetHabbo().Username);
                HabboInformation.AppendString(GetHabbo().Look);
                HabboInformation.AppendString(GetHabbo().Gender.ToUpper());
                HabboInformation.AppendString(GetHabbo().Motto);
                HabboInformation.AppendString(GetHabbo().RealName);
                HabboInformation.AppendBoolean(false);
                HabboInformation.AppendUInt(GetHabbo().Respect);
                HabboInformation.AppendUInt(GetHabbo().DailyRespectPoints); // respect to give away
                HabboInformation.AppendUInt(GetHabbo().DailyPetRespectPoints);
                HabboInformation.AppendBoolean(true);
                HabboInformation.AppendString(OtanixEnvironment.UnixTimeStampToDateTime(GetHabbo().LastOnline).ToString());
                HabboInformation.AppendBoolean(GetHabbo().NameChanges < EmuSettings.MAX_NAME_CHANGES); // CHANGENAME - HabboInformation.AppendBoolean((this.GetHabbo().Diamonds<=0||this.GetHabbo().NameChanges>=ButterflyEnvironment.maxNameChanges)?false:true);
                HabboInformation.AppendBoolean(false);
                response.AppendResponse(HabboInformation);

                var IsGuide            = (Habbo.Rank > 1) ? true : false;
                var VoteInCompetitions = false;
                var Trade     = true;
                var Citizien  = (Habbo.CitizenshipLevel >= 4) ? true : false;
                var JudgeChat = (Habbo.Rank > 2) ? true : false;
                var NavigatorThumbailCamera = true;
                var navigatorphaseTwo       = true;
                var Camera        = true;
                var CallHelpers   = true;
                var BuilderAtWork = true;
                var MouseZoom     = false;

                var Allows = new ServerMessage(Outgoing.PerkAllowancesMessageParser);
                Allows.AppendInt32(11); // count
                Allows.AppendString("TRADE");
                Allows.AppendString((!Trade) ? "requirement.unfulfilled.citizenship_level_3" : "");
                Allows.AppendBoolean(Trade);
                Allows.AppendString("NAVIGATOR_ROOM_THUMBNAIL_CAMERA");
                Allows.AppendString((!NavigatorThumbailCamera) ? "" : "");
                Allows.AppendBoolean(NavigatorThumbailCamera);
                Allows.AppendString("NAVIGATOR_PHASE_TWO_2014");
                Allows.AppendString((!navigatorphaseTwo) ? "requirement.unfulfilled.feature_disabled" : "");
                Allows.AppendBoolean(navigatorphaseTwo);
                Allows.AppendString("VOTE_IN_COMPETITIONS");
                Allows.AppendString((!VoteInCompetitions) ? "requirement.unfulfilled.helper_level_2" : "");
                Allows.AppendBoolean(VoteInCompetitions);
                Allows.AppendString("BUILDER_AT_WORK");
                Allows.AppendString((!BuilderAtWork) ? "requirement.unfulfilled.group_membership" : "");
                Allows.AppendBoolean(BuilderAtWork);
                Allows.AppendString("MOUSE_ZOOM");
                Allows.AppendString((!MouseZoom) ? "requirement.unfulfilled.feature_disabled" : "");
                Allows.AppendBoolean(MouseZoom);
                Allows.AppendString("CAMERA");
                Allows.AppendString((!Camera) ? "requirement.unfulfilled.feature_disabled" : "");
                Allows.AppendBoolean(Camera);
                Allows.AppendString("CALL_ON_HELPERS");
                Allows.AppendString((!CallHelpers) ? "requirement.unfulfilled.citizenship_level_1" : "");
                Allows.AppendBoolean(CallHelpers);
                Allows.AppendString("CITIZEN");
                Allows.AppendString((!Citizien) ? "requirement.unfulfilled.citizenship_level_3" : "");
                Allows.AppendBoolean(Citizien);
                Allows.AppendString("USE_GUIDE_TOOL");
                Allows.AppendString((!IsGuide) ? "requirement.unfulfilled.helper_level_4" : "");
                Allows.AppendBoolean(IsGuide);
                Allows.AppendString("JUDGE_CHAT_REVIEWS");
                Allows.AppendString((!JudgeChat) ? "requirement.unfulfilled.citizenship_level_6" : "");
                Allows.AppendBoolean(JudgeChat);
                response.AppendResponse(Allows);

                var enabledBuilderClub = new ServerMessage(Outgoing.EnableBuilderClub);
                enabledBuilderClub.AppendInt32(GetHabbo().IsPremium() ? GetHabbo().GetPremiumManager().GetRemainingTime() : 0); // Tiempo restante de Constructor (2678400 = 1 mes entero (s))
                enabledBuilderClub.AppendUInt(GetHabbo().IsPremium() ? GetHabbo().GetPremiumManager().GetMaxItems() : 50);      // Furnis que puedo alquilar
                enabledBuilderClub.AppendInt32(20000);                                                                          // Se puede ampliar la alquilación hasta..
                enabledBuilderClub.AppendInt32(0);
                response.AppendResponse(enabledBuilderClub);

                response.AppendResponse(GetHabbo().GetUserClothingManager().SerializeClothes());

                var achivPoints = new ServerMessage(Outgoing.AchievementPoints);
                achivPoints.AppendUInt(GetHabbo().AchievementPoints);
                response.AppendResponse(achivPoints);

                var loadVolumen = new ServerMessage(Outgoing.LoadVolumen);
                loadVolumen.AppendInt32(int.Parse(GetHabbo().volumenSystem.Split(';')[0]));
                loadVolumen.AppendInt32(int.Parse(GetHabbo().volumenSystem.Split(';')[1]));
                loadVolumen.AppendInt32(int.Parse(GetHabbo().volumenSystem.Split(';')[2]));
                loadVolumen.AppendBoolean(GetHabbo().preferOldChat);
                loadVolumen.AppendBoolean(GetHabbo().IgnoreRoomInvitations);
                loadVolumen.AppendBoolean(GetHabbo().DontFocusUser);  // fcus user
                loadVolumen.AppendInt32(0);                           //
                loadVolumen.AppendInt32(GetHabbo().LastSpeechBubble); // freeFlowChat
                response.AppendResponse(loadVolumen);

                var muteUsers = new ServerMessage(Outgoing.SerializeMuteUsers);
                muteUsers.AppendInt32(GetHabbo().MutedUsers.Count);
                foreach (string IgnoreName in GetHabbo().MutedUsers)
                {
                    muteUsers.AppendString(IgnoreName);
                }
                response.AppendResponse(muteUsers);

                TargetedOffer to = OtanixEnvironment.GetGame().GetTargetedOfferManager().GetRandomStaticTargetedOffer();
                if (to != null)
                {
                    if (!GetHabbo().TargetedOffers.ContainsKey(to.Id) || GetHabbo().TargetedOffers[to.Id] < to.PurchaseLimit)
                    {
                        response.AppendResponse(OtanixEnvironment.GetGame().GetTargetedOfferManager().SerializeTargetedOffer(to));
                    }
                }

                //Club club = GetHabbo().GetClubManager().GetSubscription("club_habbo");

                //if (club != null)
                //{
                //    if (GetHabbo().GetClubManager().HasSubscription("club_habbo"))
                //        response.AppendResponse(GetHabbo().GetClubManager().SerializeClubOffer());
                //}
                //response.AppendResponse(GetHabbo().GetClubManager().SerializeClubOffer());

                /*var giftOptions = new ServerMessage(Outgoing.NewUserExperienceGiftOfferParser);
                 * giftOptions.AppendInt32(1); // foreach
                 * {
                 *  giftOptions.AppendInt32(0);
                 *  giftOptions.AppendInt32(0);
                 *  giftOptions.AppendInt32(1); // foreach (items?)
                 *  {
                 *      giftOptions.AppendString("Testeando"); // itemName ??
                 *      giftOptions.AppendInt32(1); // foreach
                 *      {
                 *          giftOptions.AppendString("a1_kumiankka"); // item 1
                 *          giftOptions.AppendString(""); // item 2 (if is empty == null)
                 *      }
                 *  }
                 * }
                 * response.appendResponse(giftOptions);*/

                response.AppendResponse(OtanixEnvironment.GetGame().GetAchievementManager().AchievementPrede);

                if (GetHabbo().HomeRoom <= 0)
                {
                    var homeRoom = new ServerMessage(Outgoing.OutOfRoom);
                    response.AppendResponse(homeRoom);
                }
                else
                {
                    Room room = OtanixEnvironment.GetGame().GetRoomManager().GetRoom(GetHabbo().HomeRoom);
                    if (room != null)
                    {
                        this.GetMessageHandler().enterOnRoom3(room);
                    }
                }

                response.SendResponse();

                // Verifica a conta staff
                if (GetHabbo().Rank >= 4)
                {
                    ServerMessage VerificaSenha = new ServerMessage(Outgoing.MobilePhoneNumero);
                    VerificaSenha.AppendInt32(1);
                    VerificaSenha.AppendInt32(1);
                    SendMessage(VerificaSenha);
                }
                // Termina de verificar a conta staff

                Ban BanReason = OtanixEnvironment.GetGame().GetBanManager().GetBanReason(Habbo.Username, Habbo.MachineId);
                if (BanReason != null)
                {
                    SendScrollNotif("Você tem um banimento do tipo: " + BanReason.Type + "\r\nMotivo: " + BanReason.ReasonMessage);
                    Disconnect();
                    return(false);
                }

                GetHabbo().InitMessenger();

                if (GetHabbo().GetAvatarEffectsInventoryComponent() != null)
                {
                    SendMessage(GetHabbo().GetAvatarEffectsInventoryComponent().Serialize());
                }

                SendMessage(OtanixEnvironment.GetGame().GetModerationTool().SerializeCfhTopics());

                if (LanguageLocale.welcomeAlertEnabled)
                {
                    string strAlert = BlackWordsManager.SpecialReplace(LanguageLocale.welcomeAlert, this);

                    if (LanguageLocale.welcomeAlertType == 0)
                    {
                        SendScrollNotif(strAlert);
                    }
                    else if (LanguageLocale.welcomeAlertType == 1)
                    {
                        SendNotif(strAlert);
                    }
                    else if (LanguageLocale.welcomeAlertType == 2)
                    {
                        SendNotifWithImage(strAlert, LanguageLocale.welcomeAlertImage);
                    }
                }

                OtanixEnvironment.GetGame().GetAchievementManager().ProgressUserAchievement(Habbo.Id, "ACH_EmailVerification", 1);

                GetHabbo().UpdateCreditsBalance();
                GetHabbo().UpdateExtraMoneyBalance();

                if (!GetHabbo().HiddenOnline)
                {
                    GetHabbo().setMeOnline();
                }
                GetHabbo().InitExtra();

                UsersCache.enterProvisionalRoom(this);

                if (DateTime.Now.Day == 15 && Habbo.GetClubManager().UserHasSubscription("club_habbo") && Habbo.GetClubManager().GetSubscription("club_habbo").TotalSpent(Habbo.SpentCredits) > 0 && !Habbo.GetClubManager().GetSubscription("club_habbo").ReceivedPay)
                {
                    string c = "";

                    if (Habbo.GetClubManager().GetSubscription("club_habbo").TotalSpent(Habbo.SpentCredits) == 1)
                    {
                        c = "credito";
                    }

                    else
                    {
                        c = "crediti";
                    }

                    SendNotifWithImage2("Hai ricevuto " + Habbo.GetClubManager().GetSubscription("club_habbo").TotalSpent(Habbo.SpentCredits) + " " + c + " nel tuo Borsellino. Complimenti!", LanguageLocale.GetValue("frank.wave.image"), "Wooooow è arrivata la paga HC");

                    Habbo.Moedas += Habbo.GetClubManager().GetSubscription("club_habbo").TotalSpent(Habbo.SpentCredits);
                    Habbo.UpdateCreditsBalance();

                    using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        dbClient.runFastQuery("UPDATE users SET spent_credits = 0 WHERE id = " + Habbo.Id);
                        dbClient.runFastQuery("UPDATE user_subscriptions SET received_pay = 1 WHERE user_id = " + Habbo.Id);
                    }
                    Habbo.SpentCredits = 0;
                    Habbo.GetClubManager().GetSubscription("club_habbo").ReceivedPay = true;
                }

                if (DateTime.Now.Day == 16)
                {
                    using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
                        dbClient.runFastQuery("UPDATE user_subscriptions SET received_pay = 0");

                    if (Habbo.GetClubManager().UserHasSubscription("club_habbo"))
                    {
                        Habbo.GetClubManager().GetSubscription("club_habbo").ReceivedPay = false;
                    }
                }

                SendMessage(sendClub);

                return(true);
            }
            catch (UserDataNotFoundException e)
            {
                SendScrollNotif(LanguageLocale.GetValue("login.invalidsso") + "extra data: " + e);
            }
            catch (Exception e)
            {
                Logging.LogCriticalException("Invalid Dario bug duing user login: "******"Login error: " + e);
            }
            return(false);
        }
Exemplo n.º 4
0
        internal void PrepareRoomForUser(uint id, string pWd, bool isReload = false)
        {
            try
            {
                if (Session?.GetHabbo() == null || Session.GetHabbo().LoadingRoom == id)
                    return;

                if (Yupi.ShutdownStarted)
                {
                    Session.SendNotif(Yupi.GetLanguage().GetVar("server_shutdown"));
                    return;
                }

                Session.GetHabbo().LoadingRoom = id;
                QueuedServerMessage queuedServerMessage = new QueuedServerMessage(Session.GetConnection());

                Room room;

                if (Session.GetHabbo().InRoom)
                {
                    room = Yupi.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

                    if (room?.GetRoomUserManager() != null)
                        room.GetRoomUserManager().RemoveUserFromRoom(Session, false, false);
                }

                room = Yupi.GetGame().GetRoomManager().LoadRoom(id);

                if (room == null)
                    return;

                if (room.UserCount >= room.RoomData.UsersMax && !Session.GetHabbo().HasFuse("fuse_enter_full_rooms") &&
                    Session.GetHabbo().Id != (ulong) room.RoomData.OwnerId)
                {
                    ServerMessage roomQueue = new ServerMessage(LibraryParser.OutgoingRequest("RoomsQueue"));

                    roomQueue.AppendInteger(2);
                    roomQueue.AppendString("visitors");
                    roomQueue.AppendInteger(2);
                    roomQueue.AppendInteger(1);
                    roomQueue.AppendString("visitors");
                    roomQueue.AppendInteger(room.UserCount - (int) room.RoomData.UsersNow);
                    roomQueue.AppendString("spectators");
                    roomQueue.AppendInteger(1);
                    roomQueue.AppendInteger(1);
                    roomQueue.AppendString("spectators");
                    roomQueue.AppendInteger(0);

                    Session.SendMessage(roomQueue);

                    //ClearRoomLoading();
                    return;

                    /* var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("RoomEnterErrorMessageComposer"));
                     serverMessage.AppendInteger(1);
                     Session.SendMessage(serverMessage);
                     var message = new ServerMessage(LibraryParser.OutgoingRequest("OutOfRoomMessageComposer"));
                     Session.SendMessage(message);

                     ClearRoomLoading();
                     return;

                 */
                }

                CurrentLoadingRoom = room;

                if (!Session.GetHabbo().HasFuse("fuse_enter_any_room") && room.UserIsBanned(Session.GetHabbo().Id))
                {
                    if (!room.HasBanExpired(Session.GetHabbo().Id))
                    {
                        ClearRoomLoading();

                        ServerMessage serverMessage2 = new ServerMessage(LibraryParser.OutgoingRequest("RoomEnterErrorMessageComposer"));
                        serverMessage2.AppendInteger(4);
                        Session.SendMessage(serverMessage2);
                        Response.Init(LibraryParser.OutgoingRequest("OutOfRoomMessageComposer"));
                        queuedServerMessage.AppendResponse(GetResponse());
                        queuedServerMessage.SendResponse();

                        return;
                    }

                    room.RemoveBan(Session.GetHabbo().Id);
                }

                Response.Init(LibraryParser.OutgoingRequest("PrepareRoomMessageComposer"));
                queuedServerMessage.AppendResponse(GetResponse());
                if (!isReload && !Session.GetHabbo().HasFuse("fuse_enter_any_room") &&
                    !room.CheckRightsDoorBell(Session, true, true, room.RoomData.Group != null && room.RoomData.Group.Members.ContainsKey(Session.GetHabbo().Id)) &&
                    !(Session.GetHabbo().IsTeleporting && Session.GetHabbo().TeleportingRoomId == id) &&
                    !Session.GetHabbo().IsHopping)
                {
                    if (room.RoomData.State == 1)
                    {
                        if (room.UserCount == 0)
                        {
                            Response.Init(LibraryParser.OutgoingRequest("DoorbellNoOneMessageComposer"));
                            queuedServerMessage.AppendResponse(GetResponse());
                        }
                        else
                        {
                            Response.Init(LibraryParser.OutgoingRequest("DoorbellMessageComposer"));
                            Response.AppendString(string.Empty);
                            queuedServerMessage.AppendResponse(GetResponse());

                            ServerMessage serverMessage3 = new ServerMessage(LibraryParser.OutgoingRequest("DoorbellMessageComposer"));
                            serverMessage3.AppendString(Session.GetHabbo().UserName);
                            room.SendMessageToUsersWithRights(serverMessage3);
                        }

                        queuedServerMessage.SendResponse();

                        return;
                    }

                    if (room.RoomData.State == 2 && !string.Equals(pWd, room.RoomData.PassWord, StringComparison.CurrentCultureIgnoreCase))
                    {
                        ClearRoomLoading();

                        Session.GetMessageHandler()
                            .GetResponse()
                            .Init(LibraryParser.OutgoingRequest("RoomErrorMessageComposer"));
                        Session.GetMessageHandler().GetResponse().AppendInteger(-100002);
                        Session.GetMessageHandler().SendResponse();

                        Session.GetMessageHandler()
                            .GetResponse()
                            .Init(LibraryParser.OutgoingRequest("OutOfRoomMessageComposer"));
                        Session.GetMessageHandler().GetResponse();
                        Session.GetMessageHandler().SendResponse();

                        return;
                    }
                }

                Session.GetHabbo().LoadingChecksPassed = true;
                queuedServerMessage.AddBytes(LoadRoomForUser().GetPacket);
                queuedServerMessage.SendResponse();

                if (Session.GetHabbo().RecentlyVisitedRooms.Contains(room.RoomId))
                    Session.GetHabbo().RecentlyVisitedRooms.Remove(room.RoomId);

                Session.GetHabbo().RecentlyVisitedRooms.AddFirst(room.RoomId);
            }
            catch (Exception e)
            {
                YupiLogManager.LogException("PrepareRoomForUser. RoomId: " + id + "; UserId: " + (Session?.GetHabbo().Id.ToString(CultureInfo.InvariantCulture) ?? "null") + Environment.NewLine + e, "Failed Preparing Room for User.");
            }
        }
Exemplo n.º 5
0
        internal void OnRoomUserAdd()
        {
            if (Session == null || GetResponse() == null)
                return;

            QueuedServerMessage queuedServerMessage = new QueuedServerMessage(Session.GetConnection());

            if (CurrentLoadingRoom?.GetRoomUserManager() == null || CurrentLoadingRoom.GetRoomUserManager().UserList == null)
                return;

            IEnumerable<RoomUser> list = CurrentLoadingRoom.GetRoomUserManager().UserList.Values.Where(current => current != null && !current.IsSpectator);

            Response.Init(LibraryParser.OutgoingRequest("SetRoomUserMessageComposer"));
            Response.StartArray();

            foreach (RoomUser current2 in list)
            {
                try
                {
                    current2.Serialize(Response, CurrentLoadingRoom.GetGameMap().GotPublicPool);
                    Response.SaveArray();
                }
                catch (Exception e)
                {
                    YupiLogManager.LogException(e, "Registered Room YupiDatabaseManager Exception.");
                    Response.Clear();
                }
            }

            Response.EndArray();

            queuedServerMessage.AppendResponse(GetResponse());
            queuedServerMessage.AppendResponse(RoomFloorAndWallComposer(CurrentLoadingRoom));
            queuedServerMessage.AppendResponse(GetResponse());

            Response.Init(LibraryParser.OutgoingRequest("RoomOwnershipMessageComposer"));
            Response.AppendInteger(CurrentLoadingRoom.RoomId);
            Response.AppendBool(CurrentLoadingRoom.CheckRights(Session, true));
            queuedServerMessage.AppendResponse(GetResponse());

            foreach (Habbo habboForId in CurrentLoadingRoom.UsersWithRights.Select(Yupi.GetHabboById))
            {
                if (habboForId == null) continue;

                GetResponse().Init(LibraryParser.OutgoingRequest("GiveRoomRightsMessageComposer"));
                GetResponse().AppendInteger(CurrentLoadingRoom.RoomId);
                GetResponse().AppendInteger(habboForId.Id);
                GetResponse().AppendString(habboForId.UserName);
                queuedServerMessage.AppendResponse(GetResponse());
            }

            ServerMessage serverMessage = CurrentLoadingRoom.GetRoomUserManager().SerializeStatusUpdates(true);

            if (serverMessage != null)
                queuedServerMessage.AppendResponse(serverMessage);

            if (CurrentLoadingRoom.RoomData.Event != null)
                Yupi.GetGame().GetRoomEvents().SerializeEventInfo(CurrentLoadingRoom.RoomId);

            CurrentLoadingRoom.JustLoaded = false;

            foreach (RoomUser current4 in CurrentLoadingRoom.GetRoomUserManager().UserList.Values.Where(current4 => current4 != null))
            {
                if (current4.IsBot)
                {
                    if (current4.BotData.DanceId > 0)
                    {
                        Response.Init(LibraryParser.OutgoingRequest("DanceStatusMessageComposer"));
                        Response.AppendInteger(current4.VirtualId);
                        Response.AppendInteger(current4.BotData.DanceId);
                        queuedServerMessage.AppendResponse(GetResponse());
                    }
                }
                else if (current4.IsDancing)
                {
                    Response.Init(LibraryParser.OutgoingRequest("DanceStatusMessageComposer"));
                    Response.AppendInteger(current4.VirtualId);
                    Response.AppendInteger(current4.DanceId);
                    queuedServerMessage.AppendResponse(GetResponse());
                }

                if (current4.IsAsleep)
                {
                    ServerMessage sleepMsg = new ServerMessage(LibraryParser.OutgoingRequest("RoomUserIdleMessageComposer"));
                    sleepMsg.AppendInteger(current4.VirtualId);
                    sleepMsg.AppendBool(true);
                    queuedServerMessage.AppendResponse(sleepMsg);
                }

                if (current4.CarryItemId > 0 && current4.CarryTimer > 0)
                {
                    Response.Init(LibraryParser.OutgoingRequest("ApplyHanditemMessageComposer"));
                    Response.AppendInteger(current4.VirtualId);
                    Response.AppendInteger(current4.CarryTimer);
                    queuedServerMessage.AppendResponse(GetResponse());
                }

                if (current4.IsBot)
                    continue;

                try
                {
                    if (current4.GetClient() != null && current4.GetClient().GetHabbo() != null)
                    {
                        if (current4.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent() != null && current4.CurrentEffect >= 1)
                        {
                            Response.Init(LibraryParser.OutgoingRequest("ApplyEffectMessageComposer"));
                            Response.AppendInteger(current4.VirtualId);
                            Response.AppendInteger(current4.CurrentEffect);
                            Response.AppendInteger(0);
                            queuedServerMessage.AppendResponse(GetResponse());
                        }

                        ServerMessage serverMessage2 = new ServerMessage(LibraryParser.OutgoingRequest("UpdateUserDataMessageComposer"));
                        serverMessage2.AppendInteger(current4.VirtualId);
                        serverMessage2.AppendString(current4.GetClient().GetHabbo().Look);
                        serverMessage2.AppendString(current4.GetClient().GetHabbo().Gender.ToLower());
                        serverMessage2.AppendString(current4.GetClient().GetHabbo().Motto);
                        serverMessage2.AppendInteger(current4.GetClient().GetHabbo().AchievementPoints);
                        CurrentLoadingRoom?.SendMessage(serverMessage2);
                    }
                }
                catch (Exception e)
                {
                    YupiLogManager.LogException(e, "Failed Broadcasting Room Data to Client.", "Yupi.Rooms");
                }
            }

            queuedServerMessage.SendResponse();
        }
Exemplo n.º 6
0
        internal void GetRoomData3()
        {
            if (Session.GetHabbo().LoadingRoom <= 0u || !Session.GetHabbo().LoadingChecksPassed ||  CurrentLoadingRoom == null || Session == null)
                return;

            if (CurrentLoadingRoom.RoomData.UsersNow + 1 > CurrentLoadingRoom.RoomData.UsersMax &&
                !Session.GetHabbo().HasFuse("fuse_enter_full_rooms"))
            {
                ServerMessage roomFull = new ServerMessage(LibraryParser.OutgoingRequest("RoomEnterErrorMessageComposer"));
                roomFull.AppendInteger(1);
                return;
            }

            QueuedServerMessage queuedServerMessage = new QueuedServerMessage(Session.GetConnection());
            RoomItem[] array = CurrentLoadingRoom.GetRoomItemHandler().FloorItems.Values.ToArray();
            RoomItem[] array2 = CurrentLoadingRoom.GetRoomItemHandler().WallItems.Values.ToArray();

            Response.Init(LibraryParser.OutgoingRequest("RoomFloorItemsMessageComposer"));

            if (CurrentLoadingRoom.RoomData.Group != null)
            {
                if (CurrentLoadingRoom.RoomData.Group.AdminOnlyDeco == 1u)
                {
                    Response.AppendInteger(CurrentLoadingRoom.RoomData.Group.Admins.Count + 1);

                    using (Dictionary<uint, GroupMember>.ValueCollection.Enumerator enumerator = CurrentLoadingRoom.RoomData.Group.Admins.Values.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            GroupMember current = enumerator.Current;

                            if (current != null && Yupi.GetHabboById(current.Id) == null)
                                continue;

                            if (current != null)
                            {
                                Response.AppendInteger(current.Id);
                                Response.AppendString(Yupi.GetHabboById(current.Id).UserName);
                            }
                        }

                        goto IL_220;
                    }
                }

                Response.AppendInteger(CurrentLoadingRoom.RoomData.Group.Members.Count + 1);

                foreach (GroupMember current2 in CurrentLoadingRoom.RoomData.Group.Members.Values)
                {
                    Response.AppendInteger(current2.Id);
                    Response.AppendString(Yupi.GetHabboById(current2.Id).UserName);
                }

                IL_220:

                Response.AppendInteger(CurrentLoadingRoom.RoomData.OwnerId);
                Response.AppendString(CurrentLoadingRoom.RoomData.Owner);
            }
            else
            {
                Response.AppendInteger(1);
                Response.AppendInteger(CurrentLoadingRoom.RoomData.OwnerId);
                Response.AppendString(CurrentLoadingRoom.RoomData.Owner);
            }

            Response.AppendInteger(array.Length);

            foreach (RoomItem roomItem in array)
                roomItem.Serialize(Response);

            queuedServerMessage.AppendResponse(GetResponse());
            Response.Init(LibraryParser.OutgoingRequest("RoomWallItemsMessageComposer"));

            if (CurrentLoadingRoom.RoomData.Group != null)
            {
                if (CurrentLoadingRoom.RoomData.Group.AdminOnlyDeco == 1u)
                {
                    Response.AppendInteger(CurrentLoadingRoom.RoomData.Group.Admins.Count + 1);

                    using (Dictionary<uint, GroupMember>.ValueCollection.Enumerator enumerator3 = CurrentLoadingRoom.RoomData.Group.Admins.Values.GetEnumerator())
                    {
                        while (enumerator3.MoveNext())
                        {
                            GroupMember current3 = enumerator3.Current;

                            if (current3 != null)
                            {
                                Response.AppendInteger(current3.Id);
                                Response.AppendString(Yupi.GetHabboById(current3.Id).UserName);
                            }
                        }

                        goto IL_423;
                    }
                }

                Response.AppendInteger(CurrentLoadingRoom.RoomData.Group.Members.Count + 1);

                foreach (GroupMember current4 in CurrentLoadingRoom.RoomData.Group.Members.Values)
                {
                    Response.AppendInteger(current4.Id);
                    Response.AppendString(Yupi.GetHabboById(current4.Id).UserName);
                }

                IL_423:
                Response.AppendInteger(CurrentLoadingRoom.RoomData.OwnerId);
                Response.AppendString(CurrentLoadingRoom.RoomData.Owner);
            }
            else
            {
                Response.AppendInteger(1);
                Response.AppendInteger(CurrentLoadingRoom.RoomData.OwnerId);
                Response.AppendString(CurrentLoadingRoom.RoomData.Owner);
            }

            Response.AppendInteger(array2.Length);

            RoomItem[] array4 = array2;

            foreach (RoomItem roomItem2 in array4)
                roomItem2.Serialize(Response);

            queuedServerMessage.AppendResponse(GetResponse());
            Array.Clear(array, 0, array.Length);
            Array.Clear(array2, 0, array2.Length);

            CurrentLoadingRoom.GetRoomUserManager().AddUserToRoom(Session, Session.GetHabbo().SpectatorMode);
            Session.GetHabbo().SpectatorMode = false;

            RoomCompetition competition = Yupi.GetGame().GetRoomManager().GetCompetitionManager().Competition;

            if (competition != null)
            {
                if (CurrentLoadingRoom.CheckRights(Session, true))
                {
                    if (!competition.Entries.ContainsKey(CurrentLoadingRoom.RoomData.Id))
                        competition.AppendEntrySubmitMessage(Response, CurrentLoadingRoom.RoomData.State != 0 ? 4 : 1);
                    else
                    {
                        switch (competition.Entries[CurrentLoadingRoom.RoomData.Id].CompetitionStatus)
                        {
                            case 3:
                                break;
                            default:
                                if (competition.HasAllRequiredFurnis(CurrentLoadingRoom))
                                    competition.AppendEntrySubmitMessage(Response, 2);
                                else
                                    competition.AppendEntrySubmitMessage(Response, 3, CurrentLoadingRoom);
                                break;
                        }
                    }
                }
                else if (!CurrentLoadingRoom.CheckRights(Session, true) &&
                         competition.Entries.ContainsKey(CurrentLoadingRoom.RoomData.Id))
                {
                    if (Session.GetHabbo().DailyCompetitionVotes > 0)
                        competition.AppendVoteMessage(Response, Session.GetHabbo());
                }

                queuedServerMessage.AppendResponse(GetResponse());
            }

            queuedServerMessage.SendResponse();

            if (Yupi.GetUnixTimeStamp() < Session.GetHabbo().FloodTime && Session.GetHabbo().FloodTime != 0)
            {
                ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("FloodFilterMessageComposer"));
                serverMessage.AppendInteger(Session.GetHabbo().FloodTime - Yupi.GetUnixTimeStamp());

                Session.SendMessage(serverMessage);
            }

            ClearRoomLoading();

            Poll poll;

            if (!Yupi.GetGame().GetPollManager().TryGetPoll(CurrentLoadingRoom.RoomId, out poll) ||
                Session.GetHabbo().GotPollData(poll.Id))
                return;

            Response.Init(LibraryParser.OutgoingRequest("SuggestPollMessageComposer"));
            poll.Serialize(Response);

            SendResponse();
        }
Exemplo n.º 7
0
        internal void GetRoomData2()
        {
            try
            {
                if (Session?.GetConnection() != null)
                {
                    QueuedServerMessage queuedServerMessage = new QueuedServerMessage(Session.GetConnection());

                    if (Session.GetHabbo().LoadingRoom <= 0u || CurrentLoadingRoom == null)
                        return;

                    RoomData roomData = CurrentLoadingRoom.RoomData;

                    if (roomData == null)
                        return;

                    if (roomData.Model == null || CurrentLoadingRoom.GetGameMap() == null)
                    {
                        Session.SendMessage(new ServerMessage(LibraryParser.OutgoingRequest("OutOfRoomMessageComposer")));
                        ClearRoomLoading();
                    }
                    else
                    {
                        queuedServerMessage.AppendResponse(CurrentLoadingRoom.GetGameMap().GetNewHeightmap());
                        queuedServerMessage.AppendResponse(CurrentLoadingRoom.GetGameMap().Model.GetHeightmap());
                        queuedServerMessage.SendResponse();
                        GetRoomData3();
                    }
                }
            }
            catch (Exception ex)
            {
                YupiLogManager.LogException(ex, "Failed Broadcasting Room Data to Client.", "Yupi.Rooms");
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Tries the login.
        /// </summary>
        /// <param name="authTicket">The authentication ticket.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        internal bool TryLogin(string authTicket)
        {
            try
            {
                string   ip        = GetConnection().getIp();
                uint     errorCode = 0;
                UserData userData  = UserDataFactory.GetUserData(authTicket, out errorCode);
                if (errorCode == 1 || errorCode == 2)
                {
                    Disconnect("error");
                    return(false);
                }

                #region Ban Checking
                //Let's have a quick search for a ban before we successfully authenticate..
                ModerationBan BanRecord;
                if (!string.IsNullOrEmpty(MachineId))
                {
                    if (Plus.GetGame().GetBanManager().IsBanned(MachineId, out BanRecord))
                    {
                        if (Plus.GetGame().GetBanManager().MachineBanCheck(MachineId))
                        {
                            Disconnect("machine banned - login attempt");
                            return(false);
                        }
                    }
                }

                if (userData.User != null)
                {
                    //Now let us check for a username ban record..
                    BanRecord = null;
                    if (Plus.GetGame().GetBanManager().IsBanned(userData.User.UserName, out BanRecord))
                    {
                        if (Plus.GetGame().GetBanManager().UsernameBanCheck(userData.User.UserName))
                        {
                            Disconnect("banned - login attempt");
                            return(false);
                        }
                    }
                }
                #endregion

                Plus.GetGame().GetClientManager().RegisterClient(this, userData.UserId, userData.User.UserName);
                _habbo = userData.User;

                if (_habbo != null)
                {
                    userData.User.LoadData(userData);

                    using (Database.Manager.Database.Session_Details.Interfaces.IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
                    {
                        dbClient.SetQuery("SELECT * FROM `rp_stats` WHERE `id` = '" + userData.UserId + "'");
                        DataRow Row = dbClient.GetRow();

                        RoleplayInstance RPData = CreateRoleplayInstance.GenerateInstance(Row);
                        _roleplay = RPData;

                        _roleplay.setRoleplayComponents();
                    }

                    userData.User.Init(this, userData);
                    var queuedServerMessage = new QueuedServerMessage(_connection);
                    var serverMessage       = new ServerMessage(LibraryParser.OutgoingRequest("UniqueMachineIDMessageComposer"));
                    serverMessage.AppendString(MachineId);
                    queuedServerMessage.AppendResponse(serverMessage);
                    queuedServerMessage.AppendResponse(
                        new ServerMessage(LibraryParser.OutgoingRequest("AuthenticationOKMessageComposer")));
                    if (_habbo != null)
                    {
                        var serverMessage2 = new ServerMessage(LibraryParser.OutgoingRequest("HomeRoomMessageComposer"));
                        serverMessage2.AppendInteger(_habbo.HomeRoom);
                        serverMessage2.AppendInteger(_habbo.HomeRoom);
                        queuedServerMessage.AppendResponse(serverMessage2);
                    }
                    serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("MinimailCountMessageComposer"));
                    serverMessage.AppendInteger(_habbo.MinimailUnreadMessages);
                    queuedServerMessage.AppendResponse(serverMessage);

                    serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("FavouriteRoomsMessageComposer"));
                    serverMessage.AppendInteger(30);

                    if (userData.User.FavoriteRooms == null || !userData.User.FavoriteRooms.Any())
                    {
                        serverMessage.AppendInteger(0);
                    }
                    else
                    {
                        serverMessage.AppendInteger(userData.User.FavoriteRooms.Count);
                        foreach (uint i in userData.User.FavoriteRooms)
                        {
                            serverMessage.AppendInteger(i);
                        }
                    }
                    queuedServerMessage.AppendResponse(serverMessage);

                    var rightsMessage = new ServerMessage(LibraryParser.OutgoingRequest("UserClubRightsMessageComposer"));
                    rightsMessage.AppendInteger(userData.User.GetSubscriptionManager().HasSubscription ? 2 : 0);
                    rightsMessage.AppendInteger(userData.User.Rank);
                    rightsMessage.AppendInteger(0);
                    queuedServerMessage.AppendResponse(rightsMessage);

                    serverMessage =
                        new ServerMessage(LibraryParser.OutgoingRequest("EnableNotificationsMessageComposer"));
                    serverMessage.AppendBool(true); //isOpen
                    serverMessage.AppendBool(false);
                    queuedServerMessage.AppendResponse(serverMessage);

                    serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("EnableTradingMessageComposer"));
                    serverMessage.AppendBool(true);
                    queuedServerMessage.AppendResponse(serverMessage);
                    userData.User.UpdateCreditsBalance();

                    serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ActivityPointsMessageComposer"));
                    serverMessage.AppendInteger(2);
                    serverMessage.AppendInteger(0);
                    serverMessage.AppendInteger(userData.User.ActivityPoints);
                    serverMessage.AppendInteger(5);
                    serverMessage.AppendInteger(userData.User.BelCredits);
                    queuedServerMessage.AppendResponse(serverMessage);

                    if (userData.User.HasFuse("fuse_mod"))
                    {
                        queuedServerMessage.AppendResponse(Plus.GetGame().GetModerationTool().SerializeTool(this));
                    }
                    queuedServerMessage.AppendResponse(
                        Plus.GetGame().GetAchievementManager().AchievementDataCached);

                    if (!GetHabbo().NuxPassed&& ExtraSettings.NEW_users_gifts_ENABLED)
                    {
                        queuedServerMessage.AppendResponse(
                            new ServerMessage(LibraryParser.OutgoingRequest("NuxSuggestFreeGiftsMessageComposer")));
                    }
                    queuedServerMessage.AppendResponse(GetHabbo().GetAvatarEffectsInventoryComponent().GetPacket());
                    queuedServerMessage.SendResponse();
                    Plus.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(this);
                    Plus.GetGame().GetAchievementManager().TryProgressRegistrationAchievements(this);
                    Plus.GetGame().GetAchievementManager().TryProgressLoginAchievements(this);
                    return(true);
                }
            }
            catch (Exception e)
            {
                Logging.LogCriticalException("Bug during user login: " + e);
            }
            return(false);
        }
Exemplo n.º 9
0
        /// <summary>
        ///     Tries the login.
        /// </summary>
        /// <param name="authTicket">The authentication ticket.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        internal bool TryLogin(string authTicket)
        {
            try
            {
                string ip = GetConnection().GetIp();

                uint errorCode;

                UserData userData = UserDataFactory.GetUserData(authTicket, out errorCode);

                if (errorCode == 1 || errorCode == 2)
                {
                    return(false);
                }

                Yupi.GetGame().GetClientManager().RegisterClient(this, userData.UserId, userData.User.UserName);

                _habbo = userData.User;
                userData.User.LoadData(userData);

                string banReason = Yupi.GetGame().GetBanManager().GetBanReason(userData.User.UserName, ip, MachineId);

                if (!string.IsNullOrEmpty(banReason) || userData.User.UserName == null)
                {
                    SendNotifWithScroll(banReason);
                    using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                    {
                        queryReactor.SetQuery($"SELECT ip_last FROM users WHERE id={GetHabbo().Id} LIMIT 1");

                        string supaString = queryReactor.GetString();

                        queryReactor.SetQuery($"SELECT COUNT(0) FROM users_bans_access WHERE user_id={_habbo.Id} LIMIT 1");
                        int integer = queryReactor.GetInteger();

                        if (integer > 0)
                        {
                            queryReactor.RunFastQuery("UPDATE users_bans_access SET attempts = attempts + 1, ip='" + supaString + "' WHERE user_id=" + GetHabbo().Id + " LIMIT 1");
                        }
                        else
                        {
                            queryReactor.RunFastQuery("INSERT INTO users_bans_access (user_id, ip) VALUES (" + GetHabbo().Id + ", '" + supaString + "')");
                        }
                    }

                    return(false);
                }

                using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                    queryReactor.RunFastQuery($"UPDATE users SET ip_last='{ip}' WHERE id={GetHabbo().Id}");

                userData.User.Init(this, userData);

                QueuedServerMessage queuedServerMessage = new QueuedServerMessage(_connection);

                ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("UniqueMachineIDMessageComposer"));

                serverMessage.AppendString(MachineId);
                queuedServerMessage.AppendResponse(serverMessage);

                queuedServerMessage.AppendResponse(new ServerMessage(LibraryParser.OutgoingRequest("AuthenticationOKMessageComposer")));

                ServerMessage serverMessage2 = new ServerMessage(LibraryParser.OutgoingRequest("HomeRoomMessageComposer"));

                serverMessage2.AppendInteger(_habbo.HomeRoom);
                serverMessage2.AppendInteger(_habbo.HomeRoom);
                queuedServerMessage.AppendResponse(serverMessage2);

                serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("MinimailCountMessageComposer"));

                serverMessage.AppendInteger(_habbo.MinimailUnreadMessages);
                queuedServerMessage.AppendResponse(serverMessage);

                serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("FavouriteRoomsMessageComposer"));

                serverMessage.AppendInteger(30);

                if (userData.User.FavoriteRooms == null || !userData.User.FavoriteRooms.Any())
                {
                    serverMessage.AppendInteger(0);
                }
                else
                {
                    serverMessage.AppendInteger(userData.User.FavoriteRooms.Count);

                    foreach (uint i in userData.User.FavoriteRooms)
                    {
                        serverMessage.AppendInteger(i);
                    }
                }

                queuedServerMessage.AppendResponse(serverMessage);

                ServerMessage rightsMessage = new ServerMessage(LibraryParser.OutgoingRequest("UserClubRightsMessageComposer"));

                rightsMessage.AppendInteger(userData.User.GetSubscriptionManager().HasSubscription ? 2 : 0);
                rightsMessage.AppendInteger(userData.User.Rank);
                rightsMessage.AppendInteger(0);
                queuedServerMessage.AppendResponse(rightsMessage);

                serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("EnableNotificationsMessageComposer"));
                serverMessage.AppendBool(true); //isOpen
                serverMessage.AppendBool(false);
                queuedServerMessage.AppendResponse(serverMessage);

                serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("EnableTradingMessageComposer"));
                serverMessage.AppendBool(true);
                queuedServerMessage.AppendResponse(serverMessage);
                userData.User.UpdateCreditsBalance();

                serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("ActivityPointsMessageComposer"));
                serverMessage.AppendInteger(2);
                serverMessage.AppendInteger(0);
                serverMessage.AppendInteger(userData.User.ActivityPoints);
                serverMessage.AppendInteger(5);
                serverMessage.AppendInteger(userData.User.Diamonds);
                queuedServerMessage.AppendResponse(serverMessage);

                if (userData.User.HasFuse("fuse_mod"))
                {
                    queuedServerMessage.AppendResponse(Yupi.GetGame().GetModerationTool().SerializeTool(this));
                }

                queuedServerMessage.AppendResponse(Yupi.GetGame().GetAchievementManager().AchievementDataCached);

                if (!GetHabbo().NuxPassed&& ServerExtraSettings.NewUsersGiftsEnabled)
                {
                    queuedServerMessage.AppendResponse(new ServerMessage(LibraryParser.OutgoingRequest("NuxSuggestFreeGiftsMessageComposer")));
                }

                queuedServerMessage.AppendResponse(GetHabbo().GetAvatarEffectsInventoryComponent().GetPacket());
                queuedServerMessage.SendResponse();

                Yupi.GetGame().GetAchievementManager().TryProgressHabboClubAchievements(this);
                Yupi.GetGame().GetAchievementManager().TryProgressRegistrationAchievements(this);
                Yupi.GetGame().GetAchievementManager().TryProgressLoginAchievements(this);

                return(true);
            }
            catch (Exception ex)
            {
                ServerLogManager.LogCriticalException($"Bug during user login: {ex}");
            }

            return(false);
        }
Exemplo n.º 10
0
 internal void GetRoomData2()
 {
     try
     {
         if (Session != null && Session.GetConnection() != null)
         {
             var queuedServerMessage = new QueuedServerMessage(Session.GetConnection());
             if (Session.GetHabbo().LoadingRoom <= 0u || CurrentLoadingRoom == null)
                 return;
             var roomData = CurrentLoadingRoom.RoomData;
             if (roomData == null)
                 return;
             if (roomData.Model == null || CurrentLoadingRoom.GetGameMap() == null)
             {
                 Session.SendMessage(
                     new ServerMessage(LibraryParser.OutgoingRequest("OutOfRoomMessageComposer")));
                 ClearRoomLoading();
             }
             else
             {
                 queuedServerMessage.AppendResponse(CurrentLoadingRoom.GetGameMap().GetNewHeightmap());
                 queuedServerMessage.AppendResponse(CurrentLoadingRoom.GetGameMap().Model.GetHeightmap());
                 queuedServerMessage.SendResponse();
                 GetRoomData3();
             }
         }
     }
     catch (Exception ex)
     {
         Logging.LogException("Unable to load room ID [" + Session.GetHabbo().LoadingRoom + "]" + ex);
         Logging.HandleException(ex, "Azure.Messages.Handlers.Rooms");
     }
 }
Exemplo n.º 11
0
        internal void GetRoomData3()
        {
            if (Session.GetHabbo().LoadingRoom <= 0u || !Session.GetHabbo().LoadingChecksPassed ||
                CurrentLoadingRoom == null || Session == null)
                return;

            var queuedServerMessage = new QueuedServerMessage(Session.GetConnection());
            var array = CurrentLoadingRoom.GetRoomItemHandler().FloorItems.Values.ToArray();
            var array2 = CurrentLoadingRoom.GetRoomItemHandler().WallItems.Values.ToArray();
            Response.Init(LibraryParser.OutgoingRequest("RoomFloorItemsMessageComposer"));

            if (CurrentLoadingRoom.RoomData.Group != null)
            {
                if (CurrentLoadingRoom.RoomData.Group.AdminOnlyDeco == 1u)
                {
                    Response.AppendInteger(CurrentLoadingRoom.RoomData.Group.Admins.Count + 1);
                    using (var enumerator = CurrentLoadingRoom.RoomData.Group.Admins.Values.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            var current = enumerator.Current;
                            if (AzureEmulator.GetHabboById(current.Id) == null)
                                continue;
                            Response.AppendInteger(current.Id);
                            Response.AppendString(AzureEmulator.GetHabboById(current.Id).UserName);
                        }
                        goto IL_220;
                    }
                }
                Response.AppendInteger(CurrentLoadingRoom.RoomData.Group.Members.Count + 1);
                foreach (var current2 in CurrentLoadingRoom.RoomData.Group.Members.Values)
                {
                    Response.AppendInteger(current2.Id);
                    Response.AppendString(AzureEmulator.GetHabboById(current2.Id).UserName);
                }
            IL_220:
                Response.AppendInteger(CurrentLoadingRoom.RoomData.OwnerId);
                Response.AppendString(CurrentLoadingRoom.RoomData.Owner);
            }
            else
            {
                Response.AppendInteger(1);
                Response.AppendInteger(CurrentLoadingRoom.RoomData.OwnerId);
                Response.AppendString(CurrentLoadingRoom.RoomData.Owner);
            }
            Response.AppendInteger(array.Length);
            var array3 = array;
            foreach (var roomItem in array3)
            {
                roomItem.Serialize(Response);
            }
            queuedServerMessage.AppendResponse(GetResponse());
            Response.Init(LibraryParser.OutgoingRequest("RoomWallItemsMessageComposer"));
            if (CurrentLoadingRoom.RoomData.Group != null)
            {
                if (CurrentLoadingRoom.RoomData.Group.AdminOnlyDeco == 1u)
                {
                    Response.AppendInteger(CurrentLoadingRoom.RoomData.Group.Admins.Count + 1);
                    using (var enumerator3 = CurrentLoadingRoom.RoomData.Group.Admins.Values.GetEnumerator())
                    {
                        while (enumerator3.MoveNext())
                        {
                            var current3 = enumerator3.Current;
                            Response.AppendInteger(current3.Id);
                            Response.AppendString(AzureEmulator.GetHabboById(current3.Id).UserName);
                        }
                        goto IL_423;
                    }
                }
                Response.AppendInteger(CurrentLoadingRoom.RoomData.Group.Members.Count + 1);
                foreach (var current4 in CurrentLoadingRoom.RoomData.Group.Members.Values)
                {
                    Response.AppendInteger(current4.Id);
                    Response.AppendString(AzureEmulator.GetHabboById(current4.Id).UserName);
                }
            IL_423:
                Response.AppendInteger(CurrentLoadingRoom.RoomData.OwnerId);
                Response.AppendString(CurrentLoadingRoom.RoomData.Owner);
            }
            else
            {
                Response.AppendInteger(1);
                Response.AppendInteger(CurrentLoadingRoom.RoomData.OwnerId);
                Response.AppendString(CurrentLoadingRoom.RoomData.Owner);
            }
            Response.AppendInteger(array2.Length);
            var array4 = array2;
            foreach (var roomItem2 in array4)
            {
                roomItem2.Serialize(Response);
            }

            queuedServerMessage.AppendResponse(GetResponse());
            Array.Clear(array, 0, array.Length);
            Array.Clear(array2, 0, array2.Length);
            array = null;
            array2 = null;
            CurrentLoadingRoom.GetRoomUserManager().AddUserToRoom(Session, Session.GetHabbo().SpectatorMode, false);
            Session.GetHabbo().SpectatorMode = false;

            var competition = AzureEmulator.GetGame().GetRoomManager().GetCompetitionManager().Competition;
            if (competition != null)
            {
                if (CurrentLoadingRoom.CheckRights(Session, true, false))
                {
                    if (!competition.Entries.ContainsKey(CurrentLoadingRoom.RoomData.Id))
                    {
                        competition.AppendEntrySubmitMessage(Response, CurrentLoadingRoom.RoomData.State != 0 ? 4 : 1);
                    }
                    else
                    {
                        if(competition.Entries[CurrentLoadingRoom.RoomData.Id].CompetitionStatus == 3)
                        { }
                            //Competition.AppendEntrySubmitMessage(Response, 0);
                        else if(competition.HasAllRequiredFurnis(CurrentLoadingRoom))
                            competition.AppendEntrySubmitMessage(Response, 2);
                        else
                            competition.AppendEntrySubmitMessage(Response, 3, CurrentLoadingRoom);
                    }
                }
                else if (!CurrentLoadingRoom.CheckRights(Session, true, false) && competition.Entries.ContainsKey(CurrentLoadingRoom.RoomData.Id))
                {
                    if(Session.GetHabbo().DailyCompetitionVotes > 0)
                        competition.AppendVoteMessage(Response, Session.GetHabbo());
                }
                queuedServerMessage.AppendResponse(GetResponse());
            }
            queuedServerMessage.SendResponse();
            if (AzureEmulator.GetUnixTimeStamp() < Session.GetHabbo().FloodTime && Session.GetHabbo().FloodTime != 0)
            {
                var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("FloodFilterMessageComposer"));
                serverMessage.AppendInteger((Session.GetHabbo().FloodTime - AzureEmulator.GetUnixTimeStamp()));

                Session.SendMessage(serverMessage);
            }
            ClearRoomLoading();

            Poll poll;
            if (!AzureEmulator.GetGame().GetPollManager().TryGetPoll(CurrentLoadingRoom.RoomId, out poll) ||
                Session.GetHabbo().GotPollData(poll.Id))
                return;
            Response.Init(LibraryParser.OutgoingRequest("SuggestPollMessageComposer"));
            poll.Serialize(Response);
            SendResponse();
        }
Exemplo n.º 12
0
        internal void GoToHotelView()
        {
            var room = AzureEmulator.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);
            if (room != null)
                room.GetRoomUserManager().RemoveUserFromRoom(Session, true, false);

            var hotelView = AzureEmulator.GetGame().GetHotelView();
            if (hotelView.FurniRewardName != null)
            {
                var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("LandingRewardMessageComposer"));
                serverMessage.AppendString(hotelView.FurniRewardName);
                serverMessage.AppendInteger(hotelView.FurniRewardId);
                serverMessage.AppendInteger(120);
                serverMessage.AppendInteger(120 - Session.GetHabbo().Respect);
                Session.SendMessage(serverMessage);
            }
            Session.CurrentRoomUserId = -1;

            if (roomQueue == true)
            {
                var queuedServerMessage = new QueuedServerMessage(Session.GetConnection());
                Response.Init(LibraryParser.OutgoingRequest("OutOfRoomMessageComposer"));
                queuedServerMessage.AppendResponse(GetResponse());
                queuedServerMessage.SendResponse();
                roomQueue = false;
                return;
            }
        }