Beispiel #1
0
        internal bool tryLogin(string AuthTicket)
        {
            int loginProgress = 0;
            try
            {
                string ip = GetConnection().getIp();
                byte errorCode = 0;
                UserData userData = UserDataFactory.GetUserData(AuthTicket, ip, out errorCode);
                if (errorCode == 1)
                {
                    SendNotifWithScroll(LanguageLocale.GetValue("login.invalidsso"));
                    return false;
                }
                else if (errorCode == 2)
                {
                    SendNotifWithScroll(LanguageLocale.GetValue("login.loggedin"));
                    return false;
                }
                loginProgress++;

                FirewindEnvironment.GetGame().GetClientManager().RegisterClient(this, userData.userID, userData.user.Username);
                this.Habbo = userData.user;
                userData.user.LoadData(userData);
                loginProgress++;

                if (userData.user.Username == null)
                {
                    SendBanMessage("You have no username.");
                    return false;
                }
                string banReason = FirewindEnvironment.GetGame().GetBanManager().GetBanReason(userData.user.Username, ip);
                loginProgress++;
                if (!string.IsNullOrEmpty(banReason))
                {
                    SendBanMessage(banReason);
                    return false;
                }

                userData.user.Init(this, userData);

                QueuedServerMessage response = new QueuedServerMessage(Connection);

                ServerMessage UniqueId = new ServerMessage(Outgoing.UniqueID);
                UniqueId.AppendString(this.MachineId);
                response.appendResponse(UniqueId);

                ServerMessage authok = new ServerMessage(Outgoing.AuthenticationOK);
                response.appendResponse(authok);

                ServerMessage HomeRoom = new ServerMessage(Outgoing.HomeRoom);
                HomeRoom.AppendUInt(this.GetHabbo().HomeRoom); // first home
                HomeRoom.AppendUInt(this.GetHabbo().HomeRoom); // first home
                SendMessage(HomeRoom);

                loginProgress++;

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

                loginProgress++;

                ServerMessage fuserights = new ServerMessage(Outgoing.Fuserights);
                if (GetHabbo().GetSubscriptionManager().HasSubscription("habbo_vip")) // VIP
                    fuserights.AppendInt32(2);
                else if (GetHabbo().GetSubscriptionManager().HasSubscription("habbo_club")) // HC
                    fuserights.AppendInt32(1);
                else
                    fuserights.AppendInt32(0);
                fuserights.AppendUInt(this.GetHabbo().Rank);
                response.appendResponse(fuserights);

                loginProgress++;

                ServerMessage bools1 = new ServerMessage(Outgoing.AvailabilityStatus);
                bools1.AppendBoolean(true);
                bools1.AppendBoolean(false);
                response.appendResponse(bools1);

                ServerMessage bools2 = new ServerMessage(Outgoing.InfoFeedEnable);
                bools2.AppendBoolean(false);
                response.appendResponse(bools2);

                loginProgress++;

                ServerMessage setRanking = new ServerMessage(Outgoing.SerializeCompetitionWinners);
                setRanking.AppendString("hlatCompetitions"); // competition type
                setRanking.AppendInt32(Ranking.getCompetitionForInfo("hlatCompetitions").Count);

                loginProgress++;
                int i = 0;
                foreach (Ranking r in Ranking.getCompetitionForInfo("hlatCompetitions"))
                {
                    i++;
                    setRanking.AppendUInt(r.UserId);
                    Habbo data = FirewindEnvironment.getHabboForId(r.UserId);
                    setRanking.AppendString((data != null) ? data.Username : "******");
                    setRanking.AppendString((data != null) ? data.Look : "sh-907-96.hd-3096-3.he-3082-91.lg-3018-81.ch-660-95.hr-9534-34");
                    setRanking.AppendInt32(i); // position
                    setRanking.AppendInt32(r.Score);
                }
                response.appendResponse(setRanking);

                loginProgress++;

                if (userData.user.HasFuse("fuse_mod"))
                {
                    this.SendMessage(FirewindEnvironment.GetGame().GetModerationTool().SerializeTool());
                    FirewindEnvironment.GetGame().GetModerationTool().SerializeOpenTickets(ref response, userData.userID);
                }

                if (LanguageLocale.welcomeAlertEnabled)
                {
                    this.SendMOTD(LanguageLocale.welcomeAlert);
                }

                loginProgress++;
                using (IQueryAdapter db = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    db.setQuery("UPDATE users SET online = '1' WHERE id = @id");
                    db.addParameter("id", this.GetHabbo().Id);
                    db.runQuery();
                }

                loginProgress++;

                // Send the big chunk
                response.sendResponse();

                // fire the event!
                FirewindEnvironment.GetGame().GetClientManager().ClientLoggedIn(this);
                return true;

            }
            catch (UserDataNotFoundException e)
            {
                SendNotifWithScroll(LanguageLocale.GetValue("login.invalidsso") + "extra data: " + e.ToString());
            }
            catch (Exception e)
            {
                Logging.LogCriticalException(String.Format("Invalid Dario bug duing user login (progress = {0}): ", loginProgress) + e.ToString());
                SendNotifWithScroll("Login error: " + e.ToString());
            }
            return false;
        }
Beispiel #2
0
 internal void SerializeOpenTickets(ref QueuedServerMessage serverMessages, uint userID)
 {
     foreach (SupportTicket ticket in Tickets)
     {
         if (ticket.Status == TicketStatus.OPEN || (ticket.Status == TicketStatus.PICKED && ticket.ModeratorId == userID) || (ticket.Status == TicketStatus.PICKED && ticket.ModeratorId == null))
             serverMessages.appendResponse(ticket.Serialize());
     }
 }
Beispiel #3
0
 internal void GetInventory()
 {
     QueuedServerMessage response = new QueuedServerMessage(Session.GetConnection());
     response.appendResponse(Session.GetHabbo().GetInventoryComponent().SerializeFloorItemInventory());
     response.appendResponse(Session.GetHabbo().GetInventoryComponent().SerializeWallItemInventory());
     response.sendResponse();
 }
Beispiel #4
0
        internal void GetGuestRoom()
        {
            int roomID = Request.ReadInt32();
            bool unk1 = Request.ReadBoolean(); // these 2 bools could have with forwarding to do
            bool unk2 = Request.ReadBoolean();

            //Logging.LogDebug(String.Format("p1: {0}, p2: {1}", unk1, unk2));
            if (!Session.GetHabbo().HasFuse("fuse_enter_any_room") && (Session.GetHabbo().LoadingRoom != roomID || CurrentLoadingRoom == null || !Session.GetHabbo().LoadingChecksPassed))
                return;

            Habbo targetHabbo = Session.GetHabbo();

            RoomData room = FirewindEnvironment.GetGame().GetRoomManager().GenerateRoomData((uint)roomID);

            if (CurrentLoadingRoom == null) // Happens with MOD-tool
            {
                CurrentLoadingRoom = FirewindEnvironment.GetGame().GetRoomManager().LoadRoom((uint)roomID);

                Response.Init(Outgoing.PrepareRoomForUsers);
                SendResponse();

                Response.Init(Outgoing.RoomReady);
                Response.AppendStringWithBreak(room.ModelName); // if starts with "model_", roomCategory = 1
                Response.AppendInt32(roomID); // flatId
                SendResponse();
                //return;
            }

            if (Session.GetHabbo().InRoom)
            {
                Room oldRoom = FirewindEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId);

                if (oldRoom != null)
                {
                    oldRoom.GetRoomUserManager().RemoveUserFromRoom(Session, false, false);
                    Session.CurrentRoomUserID = -1;
                }
            }

            if (room == null || CurrentLoadingRoom == null)
                return;

            Response.Init(Outgoing.GetGuestRoomResult);
            Response.AppendBoolean(true); // enterRoom
            room.Serialize(Response, false);
            Response.AppendBoolean(false); // roomForward
            Response.AppendString("");

            SendResponse();

            if (room.Wallpaper != "0.0")
            {
                Response.Init(Outgoing.RoomDecoration);
                Response.AppendStringWithBreak("wallpaper");
                Response.AppendStringWithBreak(room.Wallpaper);
                SendResponse();
            }

            if (room.Floor != "0.0")
            {
                Response.Init(Outgoing.RoomDecoration);
                Response.AppendStringWithBreak("floor");
                Response.AppendStringWithBreak(room.Floor);
                SendResponse();
            }

            Response.Init(Outgoing.RoomDecoration);
            Response.AppendStringWithBreak("landscape");
            Response.AppendStringWithBreak(room.Landscape);
            SendResponse();

            if (CurrentLoadingRoom.CheckRights(Session, true))
            {
                Response.Init(Outgoing.RoomRightsLevel);
                Response.AppendInt32(4);
                SendResponse();

                Response.Init(Outgoing.HasOwnerRights);
                SendResponse();
            }
            else if (CurrentLoadingRoom.CheckRights(Session))
            {
                Response.Init(Outgoing.RoomRightsLevel);
                Response.AppendInt32(1);
                SendResponse();
            }
            else
            {
                Response.Init(Outgoing.RoomRightsLevel);
                Response.AppendInt32(0);
                SendResponse();
            }

            Response.Init(Outgoing.ScoreMeter);
            Response.AppendInt32(room.Score);
            Response.AppendBoolean(!(Session.GetHabbo().RatedRooms.Contains(room.Id) || CurrentLoadingRoom.CheckRights(Session, true)));
            SendResponse();

            if (CurrentLoadingRoom.HasOngoingEvent)
            {
                //Session.SendMessage(Room.Event.Serialize(Session));
            }
            else
            {
                Response.Init(Outgoing.RoomEvent);
                Response.AppendStringWithBreak("-1");
                SendResponse();
            }

            Session.SendMessage(CurrentLoadingRoom.GetGameMap().Model.GetHeightmap());
            Session.SendMessage(CurrentLoadingRoom.GetGameMap().Model.SerializeRelativeHeightmap());

            QueuedServerMessage response = new QueuedServerMessage(Session.GetConnection());
            RoomItem[] floorItems = CurrentLoadingRoom.GetRoomItemHandler().mFloorItems.Values.ToArray();
            RoomItem[] wallItems = CurrentLoadingRoom.GetRoomItemHandler().mWallItems.Values.ToArray();

            Response.Init(Outgoing.Objects);
            Response.AppendInt32(1); // count of owners

            // serialize all owners
            Response.AppendInt32(CurrentLoadingRoom.OwnerId);
            Response.AppendString(CurrentLoadingRoom.Owner);

            // serialize items
            Response.AppendInt32(floorItems.Length);

            foreach (RoomItem Item in floorItems)
                Item.Serialize(Response, CurrentLoadingRoom.OwnerId);

            response.appendResponse(GetResponse());

            Response.Init(Outgoing.SerializeWallItems);
            Response.AppendInt32(1); // count of owners

            // serialize all owners
            Response.AppendInt32(CurrentLoadingRoom.OwnerId);
            Response.AppendString(CurrentLoadingRoom.Owner);

            // serialize items
            Response.AppendInt32(wallItems.Length);

            foreach (RoomItem Item in wallItems)
                Item.Serialize(Response, CurrentLoadingRoom.OwnerId);

            response.appendResponse(GetResponse());

            Array.Clear(floorItems, 0, floorItems.Length);
            Array.Clear(wallItems, 0, wallItems.Length);
            floorItems = null;
            wallItems = null;

            CurrentLoadingRoom.GetRoomUserManager().AddUserToRoom(Session, false);

            response.sendResponse();
            ClearRoomLoading();
        }
Beispiel #5
0
        internal void OnRoomUserAdd()
        {
            QueuedServerMessage response = new QueuedServerMessage(Session.GetConnection());

            List<RoomUser> UsersToDisplay = new List<RoomUser>();

            if (CurrentLoadingRoom == null)
                return;

            foreach (RoomUser User in CurrentLoadingRoom.GetRoomUserManager().UserList.Values)
            {
                if (User.IsSpectator)
                    continue;

                UsersToDisplay.Add(User);
            }

            Response.Init(Outgoing.SetRoomUser);
            Response.AppendInt32(UsersToDisplay.Count);

            foreach (RoomUser User in UsersToDisplay)
            {
                User.Serialize(Response);
            }
            response.appendResponse(GetResponse());

            Response.Init(Outgoing.ConfigureWallandFloor);
            GetResponse().AppendBoolean(CurrentLoadingRoom.Hidewall);
            GetResponse().AppendInt32(CurrentLoadingRoom.WallThickness);
            GetResponse().AppendInt32(CurrentLoadingRoom.FloorThickness);
            response.appendResponse(GetResponse());

            if (CurrentLoadingRoom.UsersWithRights.Count > 0/* && CurrentLoadingRoom.CheckRights(Session, true)*/)
            {
                GetResponse().Init(Outgoing.FlatControllerAdded);
                GetResponse().AppendUInt(CurrentLoadingRoom.RoomData.Id);
                GetResponse().AppendInt32(CurrentLoadingRoom.UsersWithRights.Count);
                foreach (uint i in CurrentLoadingRoom.UsersWithRights)
                {
                    Habbo xUser = FirewindEnvironment.getHabboForId(i);
                    GetResponse().AppendUInt(xUser.Id);
                    GetResponse().AppendString(xUser.Username);
                }
                response.appendResponse(GetResponse());

                foreach (uint i in CurrentLoadingRoom.UsersWithRights)
                {
                    Habbo xUser = FirewindEnvironment.getHabboForId(i);
                    GetResponse().Init(Outgoing.GivePowers);
                    GetResponse().AppendUInt(CurrentLoadingRoom.RoomId);
                    GetResponse().AppendUInt(xUser.Id);
                    GetResponse().AppendString(xUser.Username);
                    response.appendResponse(GetResponse());
                }
            }
            ServerMessage Updates = CurrentLoadingRoom.GetRoomUserManager().SerializeStatusUpdates(true);

            if (Updates != null)
            {
                //Session.SendMessage(Updates);
                response.appendResponse(Updates);
            }
            //return;
            foreach (RoomUser User in CurrentLoadingRoom.GetRoomUserManager().UserList.Values)
            {
                if (User.IsSpectator)
                    continue;

                if (User.IsDancing)
                {
                    Response.Init(Outgoing.Dance);
                    Response.AppendInt32(User.VirtualId);
                    Response.AppendInt32(User.DanceId);
                    response.appendResponse(GetResponse());
                }

                if (User.IsAsleep)
                {
                    Response.Init(Outgoing.IdleStatus);
                    Response.AppendInt32(User.VirtualId);
                    Response.AppendBoolean(true);
                    response.appendResponse(GetResponse());
                }

                if (User.CarryItemID > 0 && User.CarryTimer > 0)
                {
                    Response.Init(Outgoing.ApplyCarryItem);
                    Response.AppendInt32(User.VirtualId);
                    Response.AppendInt32(User.CarryTimer);
                    response.appendResponse(GetResponse());
                }

                if (!User.IsBot)
                {
                    try
                    {
                        if (User.GetClient() != null && User.GetClient().GetHabbo() != null && User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent() != null && User.CurrentEffect >= 1)
                        {
                            Response.Init(Outgoing.ApplyEffects);
                            Response.AppendInt32(User.VirtualId);
                            Response.AppendInt32(User.CurrentEffect);
                            Response.AppendInt32(0);
                            response.appendResponse(GetResponse());
                        }
                    }
                    catch (Exception e) { Logging.HandleException(e, "Rooms.SendRoomData3"); }
                }
            }

            response.sendResponse();
            CurrentLoadingRoom = null;
        }
Beispiel #6
0
        internal QueuedServerMessage LoadRoomForUser()
        {
            //Room Room = FirewindEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().LoadingRoom);

            Room Room = CurrentLoadingRoom;

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

            if (Room == null || !Session.GetHabbo().LoadingChecksPassed)
                return response;

            // todo: Room.SerializeGroupBadges()
            /*Response.Init(309);
            Response.AppendInt32(1); //yes or no i guess
            Response.AppendInt32(122768); // group iD
            Response.AppendStringWithBreak("b1201Xs03097s55091s17094a7a396e8d44670744d87bf913858b1fc");*/

            Response.Init(Outgoing.RoomReady);
            Response.AppendStringWithBreak(Room.ModelName); // if starts with "model_", roomCategory = 1
            Response.AppendUInt(Room.RoomId); // flatId
            response.appendResponse(GetResponse());

            if (Session.GetHabbo().SpectatorMode)
            {
                //Response.Init(254);
                //response.appendResponse(GetResponse());
            }

                if (Room.Wallpaper != "0.0")
                {
                    Response.Init(Outgoing.RoomDecoration);
                    Response.AppendStringWithBreak("wallpaper");
                    Response.AppendStringWithBreak(Room.Wallpaper);
                    response.appendResponse(GetResponse());
                }

                if (Room.Floor != "0.0")
                {
                    Response.Init(Outgoing.RoomDecoration);
                    Response.AppendStringWithBreak("floor");
                    Response.AppendStringWithBreak(Room.Floor);
                    response.appendResponse(GetResponse());
                }

                Response.Init(Outgoing.RoomDecoration);
                Response.AppendStringWithBreak("landscape");
                Response.AppendStringWithBreak(Room.Landscape);
                response.appendResponse(GetResponse());

                if (Room.CheckRights(Session, true))
                {
                    Response.Init(Outgoing.RoomRightsLevel);
                    Response.AppendInt32(4);
                    response.appendResponse(GetResponse());

                    Response.Init(Outgoing.HasOwnerRights);
                    response.appendResponse(GetResponse());
                }
                else if (Room.CheckRights(Session))
                {
                    Response.Init(Outgoing.RoomRightsLevel);
                    Response.AppendInt32(1);
                    response.appendResponse(GetResponse());
                }
                else
                {
                    Response.Init(Outgoing.RoomRightsLevel);
                    Response.AppendInt32(0);
                    response.appendResponse(GetResponse());
                }

                Response.Init(Outgoing.ScoreMeter);
                Response.AppendInt32(Room.Score);
                Response.AppendBoolean(!(Session.GetHabbo().RatedRooms.Contains(Room.RoomId) || Room.CheckRights(Session, true)));
                response.appendResponse(GetResponse());

                if (Room.HasOngoingEvent)
                {
                    //Session.SendMessage(Room.Event.Serialize(Session));
                }
                else
                {
                    Response.Init(Outgoing.RoomEvent);
                    Response.AppendStringWithBreak("-1");
                    response.appendResponse(GetResponse());
                }

            //response.sendResponse();
            return response;
        }