コード例 #1
0
        /*public static void OpenChatWindowRequest( NetState state, PacketReader pvSrc )
         * {
         *      Mobile from = state.Mobile;
         *
         *      if ( !m_Enabled )
         *      {
         *              from.SendMessage( "The chat system has been disabled." );
         *              return;
         *      }
         *
         *      //pvSrc.Seek( 2, System.IO.SeekOrigin.Begin );
         *      //string chatName = pvSrc.ReadUnicodeStringSafe( ( 0x40 - 2 ) >> 1 ).Trim();
         * string chatName = "";
         *
         *      Account acct = state.Account as Account;
         *
         *      string accountChatName = null;
         *
         *      if ( acct != null )
         *              accountChatName = acct.GetTag( "ChatName" );
         *
         *      if ( accountChatName != null )
         *              accountChatName = accountChatName.Trim();
         *
         *      if ( accountChatName != null && accountChatName.Length > 0 )
         *      {
         *              if ( chatName.Length > 0 && chatName != accountChatName )
         *                      from.SendMessage( "You cannot change chat nickname once it has been set." );
         *      }
         *      else
         *      {
         *              if ( chatName == null || chatName.Length == 0 )
         *              {
         *                      SendCommandTo( from, ChatCommand.AskNewNickname );
         *                      return;
         *              }
         *
         *              if ( NameVerification.Validate( chatName, 2, 31, true, true, true, 0, NameVerification.SpaceDashPeriodQuote ) && chatName.ToLower().IndexOf( "system" ) == -1 )
         *              {
         *                      // TODO: Optimize this search
         *
         *                      foreach ( Account checkAccount in Accounts.GetAccounts() )
         *                      {
         *                              string existingName = checkAccount.GetTag( "ChatName" );
         *
         *                              if ( existingName != null )
         *                              {
         *                                      existingName = existingName.Trim();
         *
         *                                      if ( Insensitive.Equals( existingName, chatName ) )
         *                                      {
         *                                              from.SendMessage( "Nickname already in use." );
         *                                              SendCommandTo( from, ChatCommand.AskNewNickname );
         *                                              return;
         *                                      }
         *                              }
         *                      }
         *
         *                      accountChatName = chatName;
         *
         *                      if ( acct != null )
         *                              acct.AddTag( "ChatName", chatName );
         *              }
         *              else
         *              {
         *                      from.SendLocalizedMessage( 501173 ); // That name is disallowed.
         *                      SendCommandTo( from, ChatCommand.AskNewNickname );
         *                      return;
         *              }
         *      }
         *
         *      SendCommandTo( from, ChatCommand.OpenChatWindow, accountChatName );
         *      ChatUser.AddChatUser( from );
         * } */

        public static void EventSink_Login(LoginEventArgs e)
        {
            Mobile from = e.Mobile;

            if (!m_Enabled)
            {
                return;
            }

            else if (from.RawName == "Generic Player")
            {
                return;
            }

            var user = ChatUser.GetChatUser(from);

            if (user != null)
            {
                Channel.SendChannelsTo(user);
            }

            else
            {
                ChatUser.AddChatUser(from);
            }
        }
コード例 #2
0
        private static void DisplayChatTo(Mobile player)
        {
            if (player.Account == null)
            {
                return;
            }

            Account account         = player.Account as Account;
            string  accountChatName = account.GetTag("ChatName");

            ChatSystem.SendCommandTo(player, ChatCommand.OpenChatWindow, accountChatName);
            ChatUser.AddChatUser(player);
        }
コード例 #3
0
ファイル: ChatSystem.cs プロジェクト: tflynt91/TrueUO
        public static void OpenChatWindowRequest(NetState state, PacketReader pvSrc)
        {
            Mobile from = state.Mobile;

            if (!Enabled)
            {
                from.SendMessage("The chat system has been disabled.");
                return;
            }

            string chatName = from.Name;

            SendCommandTo(from, ChatCommand.OpenChatWindow, chatName);
            ChatUser.AddChatUser(from);
        }
コード例 #4
0
ファイル: ChatSystem.cs プロジェクト: pallop/Servuo
        public static void OpenChatWindowRequest(NetState state, PacketReader pvSrc)
        {
            var from = state.Mobile;

            if (!Enabled)
            {
                from.SendMessage("The chat system has been disabled.");
                return;
            }

            pvSrc.Seek(2, SeekOrigin.Begin);
            /*string chatName = */ pvSrc.ReadUnicodeStringSafe((0x40 - 2) >> 1).Trim();

            var chatName = from.Name;

            SendCommandTo(from, ChatCommand.OpenChatWindow, chatName);
            ChatUser.AddChatUser(from);
        }
コード例 #5
0
        public static void OpenChatWindowRequest(NetState state, CircularBufferReader reader, int packetLength)
        {
            var from = state.Mobile;

            if (!ChatSystem.Enabled)
            {
                from.SendMessage("The chat system has been disabled.");
                return;
            }

            // Newer clients don't send chat username anymore so we are ignoring the rest of this packet.

            // TODO: How does OSI handle incognito/disguise kits?
            // TODO: Does OSI still allow duplicate names?
            // For now we assume they should use their raw name.
            var chatName = from.RawName ?? $"Unknown User {Utility.RandomMinMax(1000000, 9999999)}";

            ChatSystem.SendCommandTo(from, ChatCommand.OpenChatWindow, chatName);
            ChatUser.AddChatUser(from, chatName);
        }
コード例 #6
0
ファイル: Chat.cs プロジェクト: StoryOfTheBard/UOLegends
        public static void OpenChatWindowRequest(NetState state, PacketReader pvSrc)
        {
            Mobile from = state.Mobile;

            if (!m_Enabled)
            {
                from.SendMessage("The chat system has been disabled.");
                return;
            }

            pvSrc.Seek(2, System.IO.SeekOrigin.Begin);
            string chatName = pvSrc.ReadUnicodeStringSafe((0x40 - 2) >> 1).Trim();

            Account acct = state.Account as Account;

            string accountChatName = null;

            if (acct != null)
            {
                accountChatName = acct.GetTag("ChatName");
            }

            if (accountChatName != null)
            {
                accountChatName = accountChatName.Trim();
            }

            if (accountChatName != null && accountChatName.Length > 0)
            {
                if (chatName.Length > 0 && chatName != accountChatName)
                {
                    from.SendMessage("You cannot change chat nickname once it has been set.");
                }
            }
            else
            {
                if (chatName == null || chatName.Length == 0)
                {
                    SendCommandTo(from, ChatCommand.AskNewNickname);
                    return;
                }

                if (NameVerification.Validate(chatName, 2, 31, true, true, true, 0, NameVerification.SpaceDashPeriodQuote) && chatName.ToLower().IndexOf("system") == -1)
                {
                    // TODO: Optimize this search

                    foreach (Account checkAccount in Accounts.Table.Values)
                    {
                        string existingName = checkAccount.GetTag("ChatName");

                        if (existingName != null)
                        {
                            existingName = existingName.Trim();

                            if (Insensitive.Equals(existingName, chatName))
                            {
                                from.SendMessage("Nickname already in use.");
                                SendCommandTo(from, ChatCommand.AskNewNickname);
                                return;
                            }
                        }
                    }

                    accountChatName = chatName;

                    if (acct != null)
                    {
                        acct.AddTag("ChatName", chatName);
                    }
                }
                else
                {
                    from.SendAsciiMessage("That name is disallowed.");
                    SendCommandTo(from, ChatCommand.AskNewNickname);
                    return;
                }
            }

            SendCommandTo(from, ChatCommand.OpenChatWindow, accountChatName);
            ChatUser.AddChatUser(from);
        }