예제 #1
0
파일: Habbo.cs 프로젝트: nightwolf93/Bfly
        internal void Init(GameClient client, UserData data)
        {
            this.mClient = client;

            this.SubscriptionManager = new SubscriptionManager(Id, data);
            this.BadgeComponent      = new BadgeComponent(Id, data);
            this.InventoryComponent  = InventoryGlobal.GetInventory(Id, client, data);
            this.InventoryComponent.SetActiveState(client);
            this.AvatarEffectsInventoryComponent = new AvatarEffectsInventoryComponent(Id, client, data);
            this.quests             = data.quests;
            this.chatMessageManager = new ChatMessageManager();

            this.Messenger = new HabboMessenger(Id);
            this.Messenger.Init(data.friends, data.requests);

            this.SpectatorMode = false;
            this.Disconnected  = false;
            this.UsersRooms    = data.rooms;
        }
예제 #2
0
 internal void Init(GameClient client, UserData data)
 {
     this.mClient             = client;
     this.SubscriptionManager = new SubscriptionManager(this.Id, data);
     this.BadgeComponent      = new BadgeComponent(this.Id, data);
     this.InventoryComponent  = InventoryGlobal.GetInventory(this.Id, client, data);
     this.InventoryComponent.SetActiveState(client);
     this.CommandHandler = new ChatCommandHandler(client);
     this.AvatarEffectsInventoryComponent = new AvatarEffectsInventoryComponent(this.Id, client, data);
     this.quests    = data.quests;
     this.Messenger = new HabboMessenger(this.Id);
     this.Messenger.Init(data.friends, data.requests);
     this.FriendCount            = Convert.ToUInt32(data.friends.Count);
     this.SpectatorMode          = false;
     this.Disconnected           = false;
     this.UsersRooms             = data.rooms;
     this.MinimailUnreadMessages = data.miniMailCount;
     this.Relationships          = data.Relations;
     this.AnsweredPolls          = data.suggestedPolls;
 }
예제 #3
0
파일: Habbo.cs 프로젝트: Mereos/HabboEMU
 /// <summary>
 /// Initializes the specified client.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="data">The data.</param>
 internal void Init(GameClient client, UserData data)
 {
     _mClient             = client;
     _subscriptionManager = new SubscriptionManager(Id, data);
     _badgeComponent      = new BadgeComponent(Id, data);
     _inventoryComponent  = InventoryGlobal.GetInventory(Id, client, data);
     _inventoryComponent.SetActiveState(client);
     _avatarEffectsInventoryComponent = new AvatarEffectsInventoryComponent(Id, client, data);
     Quests     = data.Quests;
     _messenger = new HabboMessenger(Id);
     _messenger.Init(data.Friends, data.Requests);
     FriendCount            = Convert.ToUInt32(data.Friends.Count);
     SpectatorMode          = false;
     Disconnected           = false;
     UsersRooms             = data.Rooms;
     MinimailUnreadMessages = data.MiniMailCount;
     Relationships          = data.Relations;
     AnsweredPolls          = data.SuggestedPolls;
     _clothingManager       = new UserClothing(Id);
     Preferences            = new UserPreferences(Id);
     _youtubeManager        = new YoutubeManager(Id);
 }
예제 #4
0
파일: Habbo.cs 프로젝트: fuding/Coolmemes
        internal void Init(UserData data)
        {
            this.PresentBuyStopwatch = new Stopwatch();
            this.PresentBuyStopwatch.Start();

            this.FavoriteRooms      = data.favouritedRooms;
            this.InventoryComponent = new InventoryComponent(Id, mClient);
            this.InventoryComponent.SetActiveState(mClient);
            this.AvatarEffectsInventoryComponent = new AvatarEffectsInventoryComponent(Id, mClient, data);
            this.chatMessageManager  = new ChatMessageManager();
            this.premiumManager      = PremiumManager.LoadPremiumData(Id);
            this.userclothingManager = new UserClothing(Id);

            if (HasFuse("fuse_chat_staff"))
            {
                data.friends.Add(EmuSettings.CHAT_USER_ID, StaffChat.MessengerStaff);
            }

            this.Messenger = new HabboMessenger(Id, data.friends, data.requests);
            this.UpdateRooms();
            this.LoadMuteUsers();
        }
예제 #5
0
        internal void UpdateUserStatus(RoomUser User, bool cyclegameitems)
        {
            if (User == null)
            {
                return;
            }
            bool isBot = User.IsBot;

            if (isBot)
            {
                cyclegameitems = false;
            }

            if (User.Statusses.ContainsKey("lay") || User.Statusses.ContainsKey("sit"))
            {
                User.Statusses.Remove("lay");
                User.Statusses.Remove("sit");
                User.UpdateNeeded = true;
            }

            //List<RoomItem> ItemsOnSquare = GetFurniObjects(User.X, User.Y);
            CoordItemSearch ItemSearch    = new CoordItemSearch(room.GetGameMap().CoordinatedItems);
            List <RoomItem> ItemsOnSquare = ItemSearch.GetAllRoomItemForSquare(User.X, User.Y);
            double          newZ          = room.GetGameMap().SqAbsoluteHeight(User.X, User.Y, ItemsOnSquare);

            if (newZ != User.Z)
            {
                User.Z = newZ;
                if (User.isFlying)
                {
                    User.Z += 4 + (0.5 * Math.Sin(0.7 * User.flyk));
                }
                User.UpdateNeeded = true;
            }

            DynamicRoomModel Model = room.GetGameMap().Model;

            if (Model.SqState[User.X, User.Y] == SquareState.SEAT)
            {
                if (!User.Statusses.ContainsKey("sit"))
                {
                    User.Statusses.Add("sit", "1.0");
                }

                User.Z = Model.SqFloorHeight[User.X, User.Y];
                if (User.isFlying)
                {
                    User.Z += 4 + (0.5 * Math.Sin(0.7 * User.flyk));
                }
                User.RotHead = Model.SqSeatRot[User.X, User.Y];
                User.RotBody = Model.SqSeatRot[User.X, User.Y];

                User.UpdateNeeded = true;
            }

            foreach (RoomItem Item in ItemsOnSquare)
            {
                if (cyclegameitems)
                {
                    Item.UserWalksOnFurni(User);
                }

                if (Item.GetBaseItem().IsSeat)
                {
                    if (!User.Statusses.ContainsKey("sit"))
                    {
                        User.Statusses.Add("sit", TextHandling.GetString(Item.GetBaseItem().Height));
                    }

                    User.Z = Item.GetZ;
                    if (User.isFlying)
                    {
                        User.Z += 4 + (0.5 * Math.Sin(0.7 * User.flyk));
                    }
                    User.RotHead = Item.Rot;
                    User.RotBody = Item.Rot;

                    User.UpdateNeeded = true;
                }


                switch (Item.GetBaseItem().InteractionType)
                {
                case InteractionType.bed:
                {
                    if (!User.Statusses.ContainsKey("lay"))
                    {
                        User.Statusses.Add("lay", TextHandling.GetString(Item.GetBaseItem().Height) + " null");
                    }

                    User.Z = Item.GetZ;
                    if (User.isFlying)
                    {
                        User.Z += 4 + (0.2 * 0.5 * Math.Sin(0.7 * User.flyk));
                    }
                    User.RotHead = Item.Rot;
                    User.RotBody = Item.Rot;

                    User.UpdateNeeded = true;
                    break;
                }

                case InteractionType.fbgate:
                {
                    if (cyclegameitems)
                    {
                        if (User.team != Item.team)
                        {
                            User.team = Item.team;
                        }

                        else if (User.team == Item.team)
                        {
                            User.team = Team.none;
                        }

                        if (!string.IsNullOrEmpty(Item.Figure))
                        {
                            //User = GetUserForSquare(Item.Coordinate.X, Item.Coordinate.Y);
                            if (User != null && !User.IsBot)
                            {
                                if (User.Coordinate == Item.Coordinate)
                                {
                                    if (User.GetClient().GetHabbo().Gender != Item.Gender && User.GetClient().GetHabbo().Look != Item.Figure)
                                    {
                                        User.GetClient().GetHabbo().tempGender = User.GetClient().GetHabbo().Gender;
                                        User.GetClient().GetHabbo().tempLook   = User.GetClient().GetHabbo().Look;

                                        User.GetClient().GetHabbo().Gender = Item.Gender;
                                        User.GetClient().GetHabbo().Look   = Item.Figure;
                                    }
                                    else
                                    {
                                        User.GetClient().GetHabbo().Gender = User.GetClient().GetHabbo().tempGender;
                                        User.GetClient().GetHabbo().Look   = User.GetClient().GetHabbo().tempLook;
                                    }

                                    ServerMessage RoomUpdate = new ServerMessage(266);
                                    RoomUpdate.AppendInt32(User.VirtualId);
                                    RoomUpdate.AppendStringWithBreak(User.GetClient().GetHabbo().Look);
                                    RoomUpdate.AppendStringWithBreak(User.GetClient().GetHabbo().Gender.ToLower());
                                    RoomUpdate.AppendStringWithBreak(User.GetClient().GetHabbo().Motto);
                                    room.SendMessage(RoomUpdate);
                                }
                            }
                        }
                    }

                    break;
                }

                //33: Red
                //34: Green
                //35: Blue
                //36: Yellow

                case InteractionType.banzaigategreen:
                case InteractionType.banzaigateblue:
                case InteractionType.banzaigatered:
                case InteractionType.banzaigateyellow:
                {
                    if (cyclegameitems)
                    {
                        int effectID = (int)Item.team + 32;
                        AvatarEffectsInventoryComponent efectmanager = User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent();

                        if (User.team != Item.team)
                        {
                            User.team = Item.team;

                            if (efectmanager.CurrentEffect != effectID)
                            {
                                efectmanager.ApplyCustomEffect(effectID);
                            }
                        }
                        else
                        {
                            if (efectmanager.CurrentEffect == effectID)
                            {
                                efectmanager.ApplyCustomEffect(0);
                            }
                            User.team = Team.none;
                        }
                    }
                    break;
                }

                case InteractionType.freezeyellowgate:
                case InteractionType.freezeredgate:
                case InteractionType.freezegreengate:
                case InteractionType.freezebluegate:
                {
                    if (cyclegameitems)
                    {
                        int effectID = (int)Item.team + 39;
                        AvatarEffectsInventoryComponent efectmanager = User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent();

                        if (User.team != Item.team)
                        {
                            User.team = Item.team;

                            if (efectmanager.CurrentEffect != effectID)
                            {
                                efectmanager.ApplyCustomEffect(effectID);
                            }
                        }
                        else
                        {
                            if (efectmanager.CurrentEffect == effectID)
                            {
                                efectmanager.ApplyCustomEffect(0);
                            }
                            User.team = Team.none;
                        }

                        ServerMessage message = new ServerMessage(700);
                        message.AppendBoolean((User.team != Team.none));

                        User.GetClient().SendMessage(message);
                    }
                    break;
                }

                case InteractionType.banzaitele:
                {
                    room.GetGameItemHandler().onTeleportRoomUserEnter(User, Item);
                    break;
                }
                }
            }

            if (cyclegameitems)
            {
                if (room.GotSoccer())
                {
                    room.GetSoccer().OnUserWalk(User);
                }

                if (room.GotBanzai())
                {
                    room.GetBanzai().OnUserWalk(User);
                }

                //if (room.GotFreeze())
                room.GetFreeze().OnUserWalk(User);
            }
        }
예제 #6
0
        internal void UpdateUserStatus(RoomUnit unit, bool cyclegameitems)
        {
            try
            {
                if (unit == null)
                {
                    return;
                }
                RoomUser user  = unit as RoomUser;
                bool     isBot = user == null;
                if (isBot)
                {
                    cyclegameitems = false;
                }

                if (unit.Statuses.ContainsKey("lay") || unit.Statuses.ContainsKey("sit"))
                {
                    unit.Statuses.Remove("lay");
                    unit.Statuses.Remove("sit");
                    unit.UpdateNeeded = true;
                }

                if (unit.Statuses.ContainsKey("sign"))
                {
                    unit.Statuses.Remove("sign");
                    unit.UpdateNeeded = true;
                }

                //List<RoomItem> ItemsOnSquare = GetFurniObjects(User.X, User.Y);
                CoordItemSearch ItemSearch    = new CoordItemSearch(room.GetGameMap().CoordinatedItems);
                List <RoomItem> ItemsOnSquare = ItemSearch.GetAllRoomItemForSquare(unit.X, unit.Y);
                double          newZ;
                //if (user.isMounted == true && user.IsPet == false)
                //{
                //    newZ = room.GetGameMap().SqAbsoluteHeight(user.X, user.Y, ItemsOnSquare) + 1;
                //}
                //else
                {
                    newZ = room.GetGameMap().SqAbsoluteHeight(unit.X, unit.Y, ItemsOnSquare);
                }

                if (!isBot)
                {
                    if (newZ != user.Z)
                    {
                        user.Z = newZ;
                        if (user.IsFlying)
                        {
                            user.Z += 4 + (0.5 * Math.Sin(0.7 * user.FlyCounter));
                        }
                        user.UpdateNeeded = true;
                    }
                }

                DynamicRoomModel Model = room.GetGameMap().Model;
                if (Model.SqState[unit.X, unit.Y] == SquareState.SEAT)
                {
                    if (!unit.Statuses.ContainsKey("sit"))
                    {
                        unit.Statuses.Add("sit", "1.0");
                    }

                    unit.Z = Model.SqFloorHeight[unit.X, unit.Y];
                    if (!isBot && user.IsFlying)
                    {
                        user.Z += 4 + (0.5 * Math.Sin(0.7 * user.FlyCounter));
                    }
                    unit.RotHead = Model.SqSeatRot[unit.X, unit.Y];
                    unit.RotBody = Model.SqSeatRot[unit.X, unit.Y];

                    unit.UpdateNeeded = true;
                }

                foreach (RoomItem Item in ItemsOnSquare)
                {
                    if (cyclegameitems)
                    {
                        Item.UserWalksOnFurni(user);
                    }

                    if (Item.GetBaseItem().IsSeat)
                    {
                        if (!unit.Statuses.ContainsKey("sit"))
                        {
                            unit.Statuses.Add("sit", TextHandling.GetString(Item.GetBaseItem().Height));
                        }

                        unit.Z = Item.GetZ;
                        if (!isBot && user.IsFlying)
                        {
                            user.Z += 4 + (0.5 * Math.Sin(0.7 * user.FlyCounter));
                        }
                        unit.RotHead = Item.Rot;
                        unit.RotBody = Item.Rot;

                        unit.UpdateNeeded = true;
                    }


                    switch (Item.GetBaseItem().InteractionType)
                    {
                    case InteractionType.bed:
                    {
                        if (!unit.Statuses.ContainsKey("lay"))
                        {
                            unit.Statuses.Add("lay", TextHandling.GetString(Item.GetBaseItem().Height) + " null");
                        }

                        unit.Z = Item.GetZ;
                        if (!isBot && user.IsFlying)
                        {
                            user.Z += 4 + (0.2 * 0.5 * Math.Sin(0.7 * user.FlyCounter));
                        }
                        unit.RotHead = Item.Rot;
                        unit.RotBody = Item.Rot;

                        unit.UpdateNeeded = true;
                        break;
                    }

                    case InteractionType.fbgate:
                    {
                        if (cyclegameitems)
                        {
                            if (user.Team != Item.team)
                            {
                                user.Team = Item.team;
                            }

                            else if (user.Team == Item.team)
                            {
                                user.Team = Team.none;
                            }

                            if (!string.IsNullOrEmpty(Item.Figure))
                            {
                                //User = GetUserForSquare(Item.Coordinate.X, Item.Coordinate.Y);
                                if (user != null)
                                {
                                    if (user.Coordinate == Item.Coordinate)
                                    {
                                        if (user.GetClient().GetHabbo().Gender != Item.Gender && user.GetClient().GetHabbo().Look != Item.Figure)
                                        {
                                            user.GetClient().GetHabbo().tempGender = user.GetClient().GetHabbo().Gender;
                                            user.GetClient().GetHabbo().tempLook   = user.GetClient().GetHabbo().Look;

                                            user.GetClient().GetHabbo().Gender = Item.Gender;
                                            user.GetClient().GetHabbo().Look   = Item.Figure;
                                        }
                                        else
                                        {
                                            user.GetClient().GetHabbo().Gender = user.GetClient().GetHabbo().tempGender;
                                            user.GetClient().GetHabbo().Look   = user.GetClient().GetHabbo().tempLook;
                                        }

                                        ServerMessage RoomUpdate = new ServerMessage(Outgoing.UpdateUserInformation);
                                        RoomUpdate.AppendInt32(user.VirtualID);
                                        RoomUpdate.AppendStringWithBreak(user.GetClient().GetHabbo().Look);
                                        RoomUpdate.AppendStringWithBreak(user.GetClient().GetHabbo().Gender.ToLower());
                                        RoomUpdate.AppendStringWithBreak(user.GetClient().GetHabbo().Motto);
                                        RoomUpdate.AppendInt32(user.GetClient().GetHabbo().AchievementPoints);
                                        room.SendMessage(RoomUpdate);
                                    }
                                }
                            }
                        }

                        break;
                    }

                    //33: Red
                    //34: Green
                    //35: Blue
                    //36: Yellow

                    case InteractionType.banzaigategreen:
                    case InteractionType.banzaigateblue:
                    case InteractionType.banzaigatered:
                    case InteractionType.banzaigateyellow:
                    {
                        if (cyclegameitems)
                        {
                            int         effectID = (int)Item.team + 32;
                            TeamManager t        = user.GetClient().GetHabbo().CurrentRoom.GetTeamManagerForBanzai();
                            AvatarEffectsInventoryComponent efectmanager = user.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent();

                            if (user.Team != Item.team)
                            {
                                if (t.CanEnterOnTeam(Item.team))
                                {
                                    if (user.Team != Team.none)
                                    {
                                        t.OnUserLeave(user);
                                    }
                                    user.Team = Item.team;
                                    t.AddUser(user);

                                    if (efectmanager.CurrentEffect != effectID)
                                    {
                                        efectmanager.ApplyCustomEffect(effectID);
                                    }
                                }
                            }
                            else
                            {
                                //usersOnTeam--;
                                t.OnUserLeave(user);
                                if (efectmanager.CurrentEffect == effectID)
                                {
                                    efectmanager.ApplyCustomEffect(0);
                                }
                                user.Team = Team.none;
                            }
                            //((StringData)Item.data).Data = usersOnTeam.ToString();
                            //Item.UpdateState(false, true);
                        }
                        break;
                    }

                    case InteractionType.freezeyellowgate:
                    case InteractionType.freezeredgate:
                    case InteractionType.freezegreengate:
                    case InteractionType.freezebluegate:
                    {
                        if (cyclegameitems)
                        {
                            int         effectID = (int)Item.team + 39;
                            TeamManager t        = user.GetClient().GetHabbo().CurrentRoom.GetTeamManagerForFreeze();
                            //int usersOnTeam = 0;
                            //if (((StringData)Item.data).Data != "")
                            //usersOnTeam = int.Parse(((StringData)Item.data).Data);
                            AvatarEffectsInventoryComponent efectmanager = user.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent();

                            if (user.Team != Item.team)
                            {
                                if (t.CanEnterOnTeam(Item.team))
                                {
                                    if (user.Team != Team.none)
                                    {
                                        t.OnUserLeave(user);
                                    }
                                    user.Team = Item.team;
                                    t.AddUser(user);

                                    if (efectmanager.CurrentEffect != effectID)
                                    {
                                        efectmanager.ApplyCustomEffect(effectID);
                                    }
                                }
                            }
                            else
                            {
                                //usersOnTeam--;
                                t.OnUserLeave(user);
                                if (efectmanager.CurrentEffect == effectID)
                                {
                                    efectmanager.ApplyCustomEffect(0);
                                }
                                user.Team = Team.none;
                            }
                            //((StringData)Item.data).Data = usersOnTeam.ToString();
                            //Item.UpdateState(false, true);

                            ServerMessage message = new ServerMessage(700);
                            message.AppendBoolean((user.Team != Team.none));

                            user.GetClient().SendMessage(message);
                        }
                        break;
                    }

                    case InteractionType.banzaitele:
                    {
                        room.GetGameItemHandler().onTeleportRoomUserEnter(user, Item);
                        break;
                    }
                    }
                }

                if (cyclegameitems)
                {
                    if (room.GotSoccer())
                    {
                        room.GetSoccer().OnUserWalk(user);
                    }

                    if (room.GotBanzai())
                    {
                        room.GetBanzai().OnUserWalk(user);
                    }

                    //if (room.GotFreeze())
                    room.GetFreeze().OnUserWalk(user);
                }
            }
            catch (Exception e)
            {
            }
        }
예제 #7
0
        public Habbo(uint Id, string Username, string RealName, string SSO, uint Rank, string Motto, string Look, string Gender, int Credits, int Pixels, double Activity_Points_LastUpdate, bool Muted, uint HomeRoom, int NewbieStatus, bool BlockNewFriends, bool HideInRoom, bool HideOnline, bool Vip, int Volume, int Points, bool AcceptTrading, string LastIp, GameClient Session, HabboData HabboData, bool FriendStream)
        {
            if (Session != null)
            {
                PhoenixEnvironment.GetGame().GetClientManager().RegisterClientShit(Id, Username, Session);
            }
            this.Id                       = Id;
            this.Username                 = Username;
            this.RealName                 = RealName;
            this.isAaron                  = false;
            this.Visible                  = true;
            this.SSO                      = SSO;
            this.Rank                     = Rank;
            this.Motto                    = Motto;
            this.Look                     = PhoenixEnvironment.FilterInjectionChars(Look.ToLower());
            this.Gender                   = Gender.ToLower();
            this.Credits                  = Credits;
            this.shells                   = Points;
            this.ActivityPoints           = Pixels;
            this.LastActivityPointsUpdate = Activity_Points_LastUpdate;
            this.AcceptTrading            = AcceptTrading;
            this.Muted                    = Muted;
            this.LoadingRoom              = 0;
            this.LoadingChecksPassed      = false;
            this.Waitingfordoorbell       = false;
            this.CurrentRoomId            = 0;
            this.HomeRoom                 = HomeRoom;
            this.FavoriteRooms            = new List <uint>();
            this.MutedUsers               = new List <uint>();
            this.Tags                     = new List <string>();
            this.Achievements             = new Dictionary <uint, int>();
            this.RatedRooms               = new List <uint>();
            this.NewbieStatus             = NewbieStatus;
            this.CalledGuideBot           = false;
            this.BlockNewFriends          = BlockNewFriends;
            this.HideInRom                = HideInRoom;
            this.HideOnline               = HideOnline;
            this.Vip                      = Vip;
            this.Volume                   = Volume;
            this.Rigger                   = 0;
            this.BuyCount                 = 1;
            this.LastIp                   = LastIp;
            this.IsTeleporting            = false;
            this.TeleporterId             = 0;
            this.Session                  = Session;
            this.HabboData                = HabboData;
            this.UsersRooms               = new List <RoomData>();
            this.GroupReqs                = new List <int>();
            this.FriendStreamEnabled      = FriendStream;
            DataRow dataRow = null;

            using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
            {
                adapter.AddParamWithValue("user_id", Id);
                dataRow = adapter.ReadDataRow("SELECT * FROM user_stats WHERE Id = @user_id LIMIT 1");
                if (dataRow == null)
                {
                    adapter.ExecuteQuery("INSERT INTO user_stats (Id) VALUES ('" + Id + "')");
                    dataRow = adapter.ReadDataRow("SELECT * FROM user_stats WHERE Id = @user_id LIMIT 1");
                }
                this.GroupMemberships = adapter.ReadDataTable("SELECT * FROM group_memberships WHERE userid = @user_id");
                IEnumerator enumerator;
                if (this.GroupMemberships != null)
                {
                    enumerator = this.GroupMemberships.Rows.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            DataRow dataRow2 = (DataRow)enumerator.Current;
                            Group   class2   = GroupManager.GetGroup((int)dataRow2["groupid"]);
                            if (class2 == null)
                            {
                                DataTable   dataTable   = adapter.ReadDataTable("SELECT * FROM groups WHERE Id = " + (int)dataRow2["groupid"] + " LIMIT 1;");
                                IEnumerator enumerator2 = dataTable.Rows.GetEnumerator();
                                try
                                {
                                    while (enumerator2.MoveNext())
                                    {
                                        DataRow dataRow3 = (DataRow)enumerator2.Current;
                                        if (!GroupManager.GroupList.ContainsKey((int)dataRow3["Id"]))
                                        {
                                            GroupManager.GroupList.Add((int)dataRow3["Id"], new Group((int)dataRow3["Id"], dataRow3, adapter));
                                        }
                                    }
                                    continue;
                                }
                                finally
                                {
                                    IDisposable disposable = enumerator2 as IDisposable;
                                    if (disposable != null)
                                    {
                                        disposable.Dispose();
                                    }
                                }
                            }
                            if (!class2.List.Contains((int)Id))
                            {
                                class2.AddMember((int)Id);
                            }
                        }
                    }
                    finally
                    {
                        IDisposable disposable = enumerator as IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                    int   num    = (int)dataRow["groupid"];
                    Group class3 = GroupManager.GetGroup(num);
                    if (class3 != null)
                    {
                        this.GroupID = num;
                    }
                    else
                    {
                        this.GroupID = 0;
                    }
                }
                else
                {
                    this.GroupID = 0;
                }
                DataTable dataTable2 = adapter.ReadDataTable("SELECT groupid FROM group_requests WHERE userid = '" + Id + "';");
                enumerator = dataTable2.Rows.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        DataRow dataRow2 = (DataRow)enumerator.Current;
                        this.GroupReqs.Add((int)dataRow2["groupid"]);
                    }
                }
                finally
                {
                    IDisposable disposable = enumerator as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
            }
            this.RoomVisits            = (int)dataRow["RoomVisits"];
            this.Stat_LoginTime        = (int)PhoenixEnvironment.GetUnixTimestamp();
            this.Stat_OnlineTime       = (int)dataRow["OnlineTime"];
            this.Respect               = (int)dataRow["Respect"];
            this.RespectGiven          = (int)dataRow["RespectGiven"];
            this.GiftsGiven            = (int)dataRow["GiftsGiven"];
            this.GiftsReceived         = (int)dataRow["GiftsReceived"];
            this.DailyRespectPoints    = (int)dataRow["DailyRespectPoints"];
            this.DailyPetRespectPoints = (int)dataRow["DailyPetRespectPoints"];
            this.AchievementScore      = (int)dataRow["AchievementScore"];
            this.CompletedQuests       = new List <uint>();
            this.LastQuestId           = 0u;
            this.CurrentQuestId        = (uint)dataRow["quest_id"];
            this.CurrentQuestProgress  = (int)dataRow["quest_progress"];
            this.LevelBuilder          = (int)dataRow["lev_builder"];
            this.LevelIdentity         = (int)dataRow["lev_identity"];
            this.LevelSocial           = (int)dataRow["lev_social"];
            this.LevelExplorer         = (int)dataRow["lev_explore"];
            if (Session != null)
            {
                this.SubscriptionManager             = new SubscriptionManager(Id, HabboData);
                this.BadgeComponent                  = new BadgeComponent(Id, HabboData);
                this.InventoryComponent              = new InventoryComponent(Id, Session, HabboData);
                this.AvatarEffectsInventoryComponent = new AvatarEffectsInventoryComponent(Id, Session, HabboData);
                this.SpectatorMode = false;
                this.Disconnected  = false;
                foreach (DataRow dataRow3 in HabboData.GetUsersRooms.Rows)
                {
                    this.UsersRooms.Add(PhoenixEnvironment.GetGame().GetRoomManager().FetchRoomData((uint)dataRow3["Id"], dataRow3));
                }
            }
        }
예제 #8
0
        internal void OnDisconnect()
        {
            try
            {
                if (Disconnected)
                {
                    return;
                }

                Disconnected = true;

                if (Messenger != null)
                {
                    Messenger.AppearOffline = true;
                    Messenger.Destroy();
                    Messenger = null;
                }

                if (IsPremium())
                {
                    GetPremiumManager().Destroy();
                }

                saveWardrobe();
                SaveBadges();
                //HabboEnvironment.GetGame().GetMuteManager().RemoveUserMute(Id);

                var pollParticipation = "";
                if (this.PollParticipation.Count > 0)
                {
                    foreach (UInt32 value in this.PollParticipation)
                    {
                        pollParticipation += value + ";";
                    }
                    pollParticipation = pollParticipation.Remove(pollParticipation.Length - 1);
                }

                var votedRooms = "";
                if (this.RatedRooms.Count > 0)
                {
                    foreach (UInt32 value in this.RatedRooms)
                    {
                        votedRooms += value + ";";
                    }
                    votedRooms = votedRooms.Remove(votedRooms.Length - 1);
                }

                var actrewards = "";
                if (this.WiredRewards.Count > 0)
                {
                    foreach (WiredActReward wrd in this.WiredRewards.Values)
                    {
                        actrewards += wrd.ItemId + "," + wrd.LastUpdate + "," + wrd.ActualRewards + "," + wrd.OriginalInt + ";";
                    }
                    actrewards = actrewards.Remove(actrewards.Length - 1);
                }

                var navilogs = "";
                if (this.navigatorLogs.Count > 0)
                {
                    foreach (NaviLogs navi in this.navigatorLogs.Values)
                    {
                        navilogs += navi.Id + "," + navi.Value1 + "," + navi.Value2 + ";";
                    }
                    navilogs = navilogs.Remove(navilogs.Length - 1);
                }

                var targetedoffers = "";
                if (this.TargetedOffers.Count > 0)
                {
                    foreach (KeyValuePair <uint, uint> k in this.TargetedOffers)
                    {
                        targetedoffers += k.Key + "-" + k.Value + ";";
                    }
                    targetedoffers = targetedoffers.Remove(targetedoffers.Length - 1);
                }

                using (var dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    dbClient.setQuery("UPDATE users SET namechanges = '" + NameChanges + "', respect = '" + Respect +
                                      "', daily_respect_points = '" + DailyRespectPoints +
                                      "', daily_pet_respect_points = '" + DailyPetRespectPoints + "'," +
                                      " diamonds = '" + Diamonds + "',  machine_last = @machineLast, currentquestid = '" + CurrentQuestId +
                                      "', block_trade = '" + ((BlockTrade) ? "1" : "0") + "'," +
                                      " block_newfriends = '" + ((HasFriendRequestsDisabled) ? "1" : "0") +
                                      "', look = @look, motto = @motto, gender = @gender, last_online = '" + LastOnline.ToString() + "'," +
                                      " achievement_points = '" + AchievementPoints + "', home_room = '" + HomeRoom + "', volumenSystem = '" +
                                      volumenSystem + "', prefer_old_chat = '" + ((preferOldChat) ? "1" : "0") + "'," +
                                      " last_purchase = '" + LastPurchase + "'," +
                                      " poll_participation = '" + pollParticipation + "', voted_rooms = '" + votedRooms + "'," +
                                      " lastfollowinglogin = '******', ignoreRoomInvitations = '" + ((IgnoreRoomInvitations) ? "1" : "0") + "'," +
                                      " citizenship_level = '" + CitizenshipLevel + "', helper_level = '" + HelperLevel + "', actrewards = '" + actrewards + "', dontfocususers = '" + ((DontFocusUser) ? "1" : "0") + "'," +
                                      " navilogs = @navilogs, targeted_offers = @targetedoffers, alertasAtivados = '" + ((alertasAtivados) ? "1" : "0") + "', frankJaApareceu = '" + ((frankJaApareceu) ? "1" : "0") + "', FavoriteGroup = '" + FavoriteGroup + "', moedas = '" + Moedas + "', corAtual = @coratual, coresjaTenho  = '" + coresjaTenho + "', new_identity = '" + NewIdentity + "', new_bot = '" + NewBot + "', coins_purchased = '" + CoinsPurchased + "' WHERE id = " + Id);
                    dbClient.addParameter("look", Look);
                    dbClient.addParameter("coratual", corAtual);
                    dbClient.addParameter("motto", Motto);
                    dbClient.addParameter("gender", Gender);
                    dbClient.addParameter("machineLast", MachineId);
                    dbClient.addParameter("navilogs", navilogs);
                    dbClient.addParameter("targetedoffers", targetedoffers);
                    dbClient.runQuery();

                    dbClient.runFastQuery("DELETE FROM users_online WHERE user_id = '" + Id + "'");
                }

                if (this.AlfaServiceEnabled)
                {
                    if (this.AlfaGuideEnabled)
                    {
                        OtanixEnvironment.GetGame().GetAlfaManager().GetTourManager().RemoveAlfa(this.Id);
                        this.AlfaGuideEnabled = false;
                    }
                    if (this.AlfaHelperEnabled)
                    {
                        Help help = null;
                        if (OtanixEnvironment.GetGame().GetAlfaManager().GetHelpManager().Helps.ContainsKey(AlfaServiceId))
                        {
                            help = OtanixEnvironment.GetGame().GetAlfaManager().GetHelpManager().Helps[AlfaServiceId];
                        }

                        if (help != null)
                        {
                            if (help.helpState == HelpState.TALKING)
                            {
                                help.helpState = HelpState.FINISHED;
                            }
                            else if (help.helpState == HelpState.SEARCHING_USER)
                            {
                                help.NeedUpdate = true;
                            }
                        }

                        OtanixEnvironment.GetGame().GetAlfaManager().GetHelpManager().RemoveAlfa(this.Id);
                        this.AlfaHelperEnabled = false;
                    }
                    if (this.AlfaGuardianEnabled)
                    {
                        Bully bully = null;
                        if (OtanixEnvironment.GetGame().GetAlfaManager().GetBullyManager().Bullies.ContainsKey(AlfaServiceId))
                        {
                            bully = OtanixEnvironment.GetGame().GetAlfaManager().GetBullyManager().Bullies[AlfaServiceId];
                        }

                        if (bully != null)
                        {
                            if (bully.bullyState == BullyState.WAITING_RESPONSE)
                            {
                                bully.bullySolution = BullySolution.EXIT;
                                bully.bullyState    = BullyState.FINISHED;
                            }
                            else if (bully.bullyState == BullyState.SEARCHING_USER)
                            {
                                bully.NeedUpdate = true;
                            }
                        }

                        OtanixEnvironment.GetGame().GetAlfaManager().GetBullyManager().RemoveGuardian(this.Id);
                        this.AlfaGuardianEnabled = false;
                    }
                }

                if (InRoom && CurrentRoom != null && CurrentRoom.GetRoomUserManager() != null)
                {
                    CurrentRoom.GetRoomUserManager().RemoveUserFromRoom(mClient, false, false, false);
                }

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

                if (InventoryComponent != null)
                {
                    InventoryComponent.SetIdleState();
                    InventoryComponent.RunDBUpdate();
                    InventoryComponent.Destroy();
                    InventoryComponent = null;
                }

                if (BadgeComponent != null)
                {
                    BadgeComponentLoaded = false;
                    BadgeComponent.Destroy();
                    BadgeComponent = null;
                }

                if (RelationshipComposer != null)
                {
                    RelationsLoaded = false;
                    RelationshipComposer.Destroy();
                    RelationshipComposer = null;
                }

                if (Achievements != null && Achievements.Count > 0)
                {
                    AchievementsLoaded = false;
                    Achievements.Clear();
                    Achievements = null;
                }

                if (quests != null && quests.Count > 0)
                {
                    QuestsLoaded = false;
                    quests.Clear();
                    quests = null;
                }

                if (wardrobes != null && wardrobes.Count > 0)
                {
                    WardrobeLoaded = false;
                    wardrobes.Clear();
                    wardrobes = null;
                }

                if (clubManager != null)
                {
                    clubManager.Clear();
                    clubManager = null;
                }

                if (sanctionManager != null)
                {
                    sanctionManager.Clear();
                    sanctionManager = null;
                }
            }
            catch (Exception e)
            {
                Logging.LogCriticalException("Disconnecting user " + e);
            }
            finally
            {
                OtanixEnvironment.GetGame().GetClientManager().UnregisterClient(Id, Username);
                Logging.WriteLine(Username + " has logged out.");
            }
        }