Ejemplo n.º 1
0
        public void RoomTalkBroadcast(int sourceX, int sourceY, string chat, int roomUser)
        {
            Logging.LogEvent("Chatting to room " + mRoomID.ToString() + ": " + chat, Logging.LogLevel.Debug);
            foreach (int sessionId in mMemberSessions.Keys)
            {
                if (mRoomUsers.ContainsKey(sessionId))
                {
                    string currentChat = chat;
                    int    xDistance   = Math.Abs(sourceX - mRoomUsers[sessionId].CurrentX);
                    int    yDistance   = Math.Abs(sourceY - mRoomUsers[sessionId].CurrentY);

                    if (xDistance >= 6 || yDistance >= 6) //Garble text
                    {
                        for (int i = 0; i < chat.Length; i++)
                        {
                            if (SpecialMath.RandomNumber(0, 10) > 5 && chat[i] != ' ')
                            {
                                currentChat = currentChat.Replace(chat[i], '.');
                            }
                        }
                    }

                    if (xDistance < 9 && yDistance < 9) // User can at least partially hear
                    {
                        mMessage.Init(24);              //@X
                        mMessage.appendString(ArgumentEncoding.encodeInt(roomUser));
                        mMessage.appendString(currentChat);
                        mMessage.appendChar(2);
                        InstanceManager.Sessions.GetSession(sessionId).SendMessage(mMessage.ToString(), false);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private string BuildSubCategoryList(RoomCategory category, int userRole)
        {
            List <RoomInfo> rooms = InstanceManager.Game.Rooms.GetRoomListByCategory(category.CategoryID);
            StringBuilder   sb    = new StringBuilder();

            if (category.IsVisible || (category.SystemCategory && InstanceManager.Game.Roles.HasRight(userRole, "fuse_see_system_categories")))

            {
                sb.Append(ArgumentEncoding.encodeInt(category.CategoryID));
                sb.Append(ArgumentEncoding.encodeInt(0));
                sb.Append(category.CategoryName);
                sb.Append(Convert.ToChar(2));

                int maxUsers     = 0;
                int currentUsers = 0;

                if (rooms.Count > 0)
                {
                    foreach (RoomInfo room in rooms)
                    {
                        maxUsers     += room.MaxUsers;
                        currentUsers += room.CurrentUsers;
                    }
                }
                sb.Append(ArgumentEncoding.encodeInt(currentUsers));
                sb.Append(ArgumentEncoding.encodeInt(maxUsers));
                sb.Append(ArgumentEncoding.encodeInt(category.ParentCategory));
            }
            return(sb.ToString());
        }
Ejemplo n.º 3
0
        public string BuildPrivateCategoryResponse()
        {
            StringBuilder sb       = new StringBuilder();
            int           catCount = 0;

            List <RoomCategory> subcategories = InstanceManager.Game.Rooms.GetSubCategoryList(4);

            if (subcategories.Count > 0)
            {
                foreach (RoomCategory subcat in subcategories)
                {
                    if (subcat.PlayerCategory)
                    {
                        catCount++;
                        sb.Append(ArgumentEncoding.encodeInt(subcat.CategoryID));
                        sb.Append(subcat.CategoryName);
                        sb.Append(Convert.ToChar(2));
                    }
                }
            }

            StringBuilder result = new StringBuilder(ArgumentEncoding.encodeInt(catCount));

            result.Append(sb.ToString());
            return(result.ToString());
        }
Ejemplo n.º 4
0
 private void btnArgEncode_Click(object sender, EventArgs e)
 {
     try
     {
         txtArgOutput.Text = ArgumentEncoding.encodeInt(int.Parse(txtArgInput.Text)).ToString();
     }
     catch
     {
         MessageBox.Show("Invalid input.");
     }
 }
Ejemplo n.º 5
0
        private string BuildRoomResponse(RoomInfo room, UserInfo user, int hideFull)
        {
            int categoryType = InstanceManager.Game.Rooms.GetCategory(room.RoomCategory).RoomCategoryType;

            StringBuilder sb = new StringBuilder();

            if (hideFull == 1 && room.CurrentUsers >= room.MaxUsers)
            {
                return("");
            }

            if (categoryType == 2) // Guest
            {
                sb.Append(ArgumentEncoding.encodeInt(room.RoomID));
                sb.Append(room.RoomName);
                sb.Append(Convert.ToChar(2));
                if (room.ShowOwner == 1 || InstanceManager.Game.Roles.HasRight(user.iRole, "fuse_see_all_roomowners"))
                {
                    sb.Append(InstanceManager.Game.Users.GetUser(room.RoomOwner).sUsername);
                }
                else
                {
                    sb.Append("-");
                }
                sb.Append(Convert.ToChar(2));
                sb.Append(room.RoomStatus);
                sb.Append(Convert.ToChar(2));
                sb.Append(ArgumentEncoding.encodeInt(room.CurrentUsers));
                sb.Append(ArgumentEncoding.encodeInt(room.MaxUsers));
                sb.Append(room.RoomDescription);
                sb.Append(Convert.ToChar(2));
            }

            if (categoryType == 0) //Public
            {
                sb.Append(ArgumentEncoding.encodeInt(room.RoomID));
                sb.Append(ArgumentEncoding.encodeInt(1));
                sb.Append(room.RoomName);
                sb.Append(Convert.ToChar(2));
                sb.Append(ArgumentEncoding.encodeInt(room.CurrentUsers));
                sb.Append(ArgumentEncoding.encodeInt(room.MaxUsers));
                sb.Append(ArgumentEncoding.encodeInt(room.RoomCategory));
                sb.Append(room.RoomDescription);
                sb.Append(Convert.ToChar(2));
                sb.Append(ArgumentEncoding.encodeInt(room.RoomID));
                sb.Append(ArgumentEncoding.encodeInt(0));
                sb.Append(room.CCTs);
                sb.Append(Convert.ToChar(2));
                sb.Append(ArgumentEncoding.encodeInt(0));
                sb.Append(ArgumentEncoding.encodeInt(1));
            }
            return(sb.ToString());
        }
Ejemplo n.º 6
0
        //152 - "GETFLATCAT": "BX"
        public void Listener152()
        {
            int      roomId = ArgumentEncoding.decodeInt(mPacketBody);
            RoomInfo info   = InstanceManager.Game.Rooms.GetRoom(roomId);

            if (info != null)
            {
                mMessage.Init(222); //C^
                mMessage.appendString(ArgumentEncoding.encodeInt(info.RoomID));
                mMessage.appendString(ArgumentEncoding.encodeInt(info.RoomCategory));
                SendMessage(mMessage);
            }
        }
Ejemplo n.º 7
0
        public string BuildFloorFurniList()
        {
            int           furniCount = 0;
            StringBuilder sb         = new StringBuilder();

            foreach (FurniInfo info in mFloorFurni)
            {
                if (!info.PublicFurni && !info.Flags.InvisibleToClient)
                {
                    furniCount++;
                    sb.Append(ProcessFloorFurniDefinition(info));
                }
            }

            return(ArgumentEncoding.encodeInt(furniCount) + sb.ToString());
        }
Ejemplo n.º 8
0
 private void WhisperResponse(string response, long sessionid)
 {
     if (sessionid > 0)
     {
         int roomId = InstanceManager.Sessions.GetSession(sessionid).mRoomID;
         if (roomId > 0)
         {
             int           roomUser = InstanceManager.Game.Rooms.GetRoomInstance(roomId).GetUser(sessionid).RoomUserID;
             ClientMessage mMessage = new ClientMessage();
             mMessage.Init(25); //@Y
             mMessage.appendString(ArgumentEncoding.encodeInt(roomUser));
             mMessage.appendString(response);
             mMessage.appendChar(2);
             InstanceManager.Game.Rooms.GetRoomInstance(roomId).SendMessage(mMessage, sessionid);
         }
     }
 }
Ejemplo n.º 9
0
        //55 - "SHOUT": "@w"
        public void Listener55()
        {
            string message = FuseMessage.getArgument(1, mPacketBody);

            InstanceManager.Game.Misc.ChatFilter.FilterText(ref message, mSessionID, mRoomInstance.RoomInfo.RoomID, false, "shout");

            if (message != null && !mRoomInstance.GetUser(mSessionID).SpecialStates.ContainsKey("mute"))
            {
                ApplyEmotes(message);
                mMessage.Init(26); //@Z
                mMessage.appendString(ArgumentEncoding.encodeInt(mRoomInstance.GetUser(mSessionID).RoomUserID));
                mMessage.appendString(message);
                mMessage.appendChar(2);
                mRoomInstance.RoomBroadcast(mMessage);
                mRoomInstance.MakeTalk(mSessionID, message);
            }
        }
Ejemplo n.º 10
0
        private string BuildCategoryResponse(RoomCategory category, int hideFull, int roomCount)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(ArgumentEncoding.encodeInt(hideFull));
            sb.Append(ArgumentEncoding.encodeInt(category.CategoryID));
            sb.Append(ArgumentEncoding.encodeInt(category.RoomCategoryType));
            sb.Append(category.CategoryName);     // Name
            sb.Append(Convert.ToChar(2));
            sb.Append(ArgumentEncoding.encodeInt(0));
            sb.Append(ArgumentEncoding.encodeInt(10000));
            sb.Append(ArgumentEncoding.encodeInt(category.ParentCategory));
            if (category.RoomCategoryType == 2)     //Guest
            {
                sb.Append(ArgumentEncoding.encodeInt(roomCount));
            }
            return(sb.ToString());
        }
Ejemplo n.º 11
0
        public string GetFavouriteSearchResult(int userId, int roleId)
        {
            List <int> favouriteRooms = InstanceManager.Game.Users.GetFavouriteRooms(userId);
            UserInfo   userInfo       = InstanceManager.Game.Users.GetUser(userId);
            int        gRooms         = 0;

            StringBuilder sbGuest  = new StringBuilder();
            StringBuilder sbPublic = new StringBuilder();



            foreach (int roomId in favouriteRooms)
            {
                if (InstanceManager.Game.Rooms.RoomExists(roomId))
                {
                    RoomInfo info         = InstanceManager.Game.Rooms.GetRoom(roomId);
                    int      categoryType = InstanceManager.Game.Rooms.GetCategory(info.RoomCategory).RoomCategoryType;
                    if (categoryType == 2)
                    {
                        sbGuest.Append(BuildRoomResponse(info, userInfo, 0));
                    }
                    if (categoryType == 0)
                    {
                        sbPublic.Append(BuildRoomResponse(info, userInfo, 0));
                    }
                    if (categoryType == 2)
                    {
                        gRooms++;
                    }
                }
                else
                {
                    InstanceManager.Game.Users.DeleteFavouriteRoom(userId, roomId);
                }
            }
            StringBuilder final = new StringBuilder();

            final.Append("H" + "H" + "J" + Convert.ToChar(2) + "HHH");
            final.Append(ArgumentEncoding.encodeInt(gRooms));
            final.Append(sbGuest.ToString());
            final.Append(sbPublic.ToString());
            return(final.ToString());
        }
Ejemplo n.º 12
0
        //157 - "GETAVAILABLEBADGES": "B]"
        public void Listener157()
        {
            int badgeCount = InstanceManager.Game.Roles.GetBadgeCount(mUserInfo.iRole);

            mMessage.Init(229); //Ce
            mMessage.appendString(ArgumentEncoding.encodeInt(badgeCount));

            int currentBadge = 0;
            int currentIt    = 0;

            if (badgeCount > 0)
            {
                mUserInfo.Badges = InstanceManager.Game.Roles.GetBadges(mUserInfo.iRole);

                foreach (string badge in mUserInfo.Badges)
                {
                    mMessage.appendString(badge);
                    mMessage.appendChar(2);

                    if (badge == mUserInfo.sBadge)
                    {
                        currentBadge = currentIt;
                    }

                    currentIt++;
                }
            }

            mMessage.appendArgumentInt(currentBadge);

            if (currentBadge > 0)
            {
                mMessage.appendArgumentInt(1);
            }
            else
            {
                mMessage.appendArgumentInt(0);
            }

            SendMessage(mMessage);
        }
Ejemplo n.º 13
0
        private string ProcessFloorFurniDefinition(FurniInfo info)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(info.FurniID);
            sb.Append(Convert.ToChar(2));
            sb.Append(info.FurniSprite);
            sb.Append(Convert.ToChar(2));
            sb.Append(ArgumentEncoding.encodeInt(info.PosX));
            sb.Append(ArgumentEncoding.encodeInt(info.PosY));
            sb.Append(ArgumentEncoding.encodeInt(info.W));
            sb.Append(ArgumentEncoding.encodeInt(info.L));
            sb.Append(ArgumentEncoding.encodeInt(info.PosRotation));
            sb.Append(info.PosZ.ToString().Replace(',', '.'));
            sb.Append(Convert.ToChar(2));
            sb.Append(info.Col);
            sb.Append(Convert.ToChar(2));
            sb.Append(Convert.ToChar(2));
            sb.Append(ArgumentEncoding.encodeInt(info.TeleportId));
            sb.Append(info.FurniVar);
            sb.Append(Convert.ToChar(2));
            return(sb.ToString());
        }
Ejemplo n.º 14
0
        //56 - "WHISPER": "@x"
        public void Listener56()
        {
            string message = FuseMessage.getArgument(1, mPacketBody);
            int    tSpace  = message.IndexOf(" ");
            string user    = message.Substring(0, tSpace);
            string chat    = message.Substring(tSpace + 1);

            InstanceManager.Game.Misc.ChatFilter.FilterText(ref chat, mSessionID, mRoomInstance.RoomInfo.RoomID, false, "whisper to " + user);

            if (chat != null && !mRoomInstance.GetUser(mSessionID).SpecialStates.ContainsKey("mute"))
            {
                ApplyEmotes(chat);
                long sender   = mRoomInstance.GetUser(mSessionID).SessionID;
                long receiver = mRoomInstance.GetUser(user).SessionID;
                mMessage.Init(25); //@Y
                mMessage.appendString(ArgumentEncoding.encodeInt(mRoomInstance.GetUser(mSessionID).RoomUserID));
                mMessage.appendString(chat);
                mMessage.appendChar(2);
                mRoomInstance.SendMessage(mMessage, sender);
                mRoomInstance.SendMessage(mMessage, receiver);
                mRoomInstance.MakeTalk(mSessionID, chat);
            }
        }
Ejemplo n.º 15
0
        //190 - "SCR_BUY": "B~"
        public void Listener190()
        {
            if (FuseMessage.getArgument(1, mPacketBody) == "club_habbo")
            {
                int months       = 0;
                int deduct       = 9999;
                int purchaseType = ArgumentEncoding.decodeInt(mPacketBody.Substring(12));
                if (purchaseType == 1)
                {
                    deduct = 25;
                    months = 1;
                }
                if (purchaseType == 2)
                {
                    deduct = 60;
                    months = 3;
                }
                if (purchaseType == 3)
                {
                    deduct = 105;
                    months = 6;
                }

                if (mUserInfo.iCredits - deduct >= 0)
                {
                    mUserInfo.iCredits -= deduct;
                    for (int i = 1; i <= months; i++)
                    {
                        if (mUserInfo.ClubDaysRemaining == 0)
                        {
                            mUserInfo.ClubDaysRemaining = 31;
                        }
                        else
                        {
                            mUserInfo.ClubMonthsRemaining++;
                        }
                        if (mUserInfo.iRole == int.Parse(Users.UserSettings.DefaultRole))
                        {
                            mUserInfo.iRole = int.Parse(Users.UserSettings.ClubRole);
                        }
                    }
                    mUserInfo.ClubLastUpdate = DateTime.Now;

                    InstanceManager.Game.Users.UpdateUser(mUserInfo);
                    mUserInfo = InstanceManager.Game.Users.GetUser(mUserInfo.userId);

                    mMessage.Init(2); //@B
                    mMessage.appendString(InstanceManager.Game.Roles.GenerateRightsList(mUserInfo.iRole));
                    SendMessage(mMessage);

                    mMessage.Init(8); //@H
                    mMessage.appendString(Settings.ClientClubAllowedSets);
                    SendMessage(mMessage);

                    mMessage.Init(6); //@F
                    mMessage.appendString(mUserInfo.iCredits.ToString() + ".0");
                    SendMessage(mMessage);

                    mMessage.Init(7); //@G
                    mMessage.appendString("club_habbo");
                    mMessage.appendChar(2);
                    mMessage.appendArgumentInt(mUserInfo.ClubDaysRemaining);
                    mMessage.appendArgumentInt(mUserInfo.ClubMonthsPassed);
                    mMessage.appendArgumentInt(mUserInfo.ClubMonthsRemaining);
                    mMessage.appendArgumentInt(1);
                    SendMessage(mMessage);

                    mMessage.Init(229); //Ce
                    int badgeCount = InstanceManager.Game.Roles.GetBadgeCount(mUserInfo.iRole);
                    mMessage.appendString(ArgumentEncoding.encodeInt(badgeCount));
                    if (badgeCount > 0)
                    {
                        mMessage.appendString(InstanceManager.Game.Roles.GenerateBadgeList(mUserInfo.iRole));
                        mUserInfo.Badges = InstanceManager.Game.Roles.GetBadges(mUserInfo.iRole);
                    }
                    mMessage.appendString("HH");
                    SendMessage(mMessage);
                }
            }
        }