ReadStringSafe() public méthode

public ReadStringSafe ( ) : string
Résultat string
Exemple #1
0
        public static void ChatAction( NetState state, PacketReader pvSrc )
        {
            if ( !m_Enabled )
                return;

            try
            {
                Mobile from = state.Mobile;
                ChatUser user = ChatUser.GetChatUser( from );

                if ( user == null )
                    return;

                /*string lang = */pvSrc.ReadStringSafe( 4 );
                int actionID = pvSrc.ReadInt16();
                string param = pvSrc.ReadUnicodeString();

                ChatActionHandler handler = ChatActionHandlers.GetHandler( actionID );

                if ( handler != null )
                {
                    Channel channel = user.CurrentChannel;

                    if ( handler.RequireConference && channel == null )
                    {
                        user.SendMessage( 31 ); /* You must be in a conference to do this.
                                                 * To join a conference, select one from the Conference menu.
                                                 */
                    }
                    else if ( handler.RequireModerator && !user.IsModerator )
                    {
                        user.SendMessage( 29 ); // You must have operator status to do this.
                    }
                    else
                    {
                        handler.Callback( user, channel, param );
                    }
                }
                else
                {
                    log.Warn(String.Format("Client: {0}: Unknown chat action 0x{1:X}: {2}",
                                           state, actionID, param));
                }
            }
            catch ( Exception e )
            {
                log.Error( e );
            }
        }
		public static void ChatAction( NetState state, PacketReader pvSrc )
		{
			if ( !Enabled )
				return;

			try
			{
				Mobile from = state.Mobile;
				ChatUser user = ChatUser.GetChatUser( from );

				if ( user == null )
					return;

				string lang = pvSrc.ReadStringSafe( 4 );
				int actionId = pvSrc.ReadInt16();
				string param = pvSrc.ReadUnicodeString();

				ChatActionHandler handler = ChatActionHandlers.GetHandler( actionId );

				if ( handler != null )
				{
					Channel channel = user.CurrentChannel;

					if ( handler.RequireConference && channel == null )
					{
						/* You must be in a conference to do this.
						 * To join a conference, select one from the Conference menu.
						 */
						user.SendMessage( 31 );
					}
					else
					{
						handler.Callback( user, channel, param );
					}
				}
				else
				{
					Console.WriteLine( "Client: {0}: Unknown chat action 0x{1:X}: {2}", state, actionId, param );
				}
			}
			catch ( Exception e )
			{
                Console.WriteLine(e.ToString());
			}
		}
        public static void AsciiSpeechChat3(NetState state, PacketReader pvSrc)
        {
            Mobile from = state.Mobile;

            MessageType type = (MessageType)pvSrc.ReadByte();
            int hue = pvSrc.ReadInt16();
            pvSrc.ReadInt16(); // font
            string text = pvSrc.ReadStringSafe().Trim();

            if (text.Length <= 0 || text.Length > 128)
                return;

            if (!Enum.IsDefined(typeof(MessageType), type))
                type = MessageType.Regular;

            Channel c = Channel.GetByType(typeof(Guild));
            if (RUOVersion.GuildChat(type) && c != null)
                c.OnChat(from, text);
            else
                from.DoSpeech(text, c_EmptyInts, type, Utility.ClipDyedHue(hue));
        }
Exemple #4
0
        public static void OnReceive(NetState state, PacketReader pvSrc)
        {
            pvSrc.ReadByte(); // 1: <4.0.1a, 2>=4.0.1a

            HardwareInfo info = new HardwareInfo();

            info.m_InstanceID = pvSrc.ReadInt32();
            info.m_OSMajor = pvSrc.ReadInt32();
            info.m_OSMinor = pvSrc.ReadInt32();
            info.m_OSRevision = pvSrc.ReadInt32();
            info.m_CpuManufacturer = pvSrc.ReadByte();
            info.m_CpuFamily = pvSrc.ReadInt32();
            info.m_CpuModel = pvSrc.ReadInt32();
            info.m_CpuClockSpeed = pvSrc.ReadInt32();
            info.m_CpuQuantity = pvSrc.ReadByte();
            info.m_PhysicalMemory = pvSrc.ReadInt32();
            info.m_ScreenWidth = pvSrc.ReadInt32();
            info.m_ScreenHeight = pvSrc.ReadInt32();
            info.m_ScreenDepth = pvSrc.ReadInt32();
            info.m_DXMajor = pvSrc.ReadInt16();
            info.m_DXMinor = pvSrc.ReadInt16();
            info.m_VCDescription = pvSrc.ReadUnicodeStringLESafe(64);
            info.m_VCVendorID = pvSrc.ReadInt32();
            info.m_VCDeviceID = pvSrc.ReadInt32();
            info.m_VCMemory = pvSrc.ReadInt32();
            info.m_Distribution = pvSrc.ReadByte();
            info.m_ClientsRunning = pvSrc.ReadByte();
            info.m_ClientsInstalled = pvSrc.ReadByte();
            info.m_PartialInstalled = pvSrc.ReadByte();
            info.m_Language = pvSrc.ReadUnicodeStringLESafe(4);
            info.m_Unknown = pvSrc.ReadStringSafe(64);

            info.m_TimeReceived = DateTime.Now;

            Account acct = state.Account as Account;

            if (acct != null)
                acct.HardwareInfo = info;
        }
		public static void AsciiPromptResponse( NetState state, PacketReader pvSrc )
		{
			int serial = pvSrc.ReadInt32();
			int prompt = pvSrc.ReadInt32();
			int type = pvSrc.ReadInt32();
			string text = pvSrc.ReadStringSafe();

			if ( text.Length > 128 )
				return;

			Mobile from = state.Mobile;
			Prompt p = from.Prompt;

			if ( p != null && p.Serial == serial && p.Serial == prompt )
			{
				from.Prompt = null;

				if ( type == 0 )
					p.OnCancel( from );
				else
					p.OnResponse( from, text );
			}
		}
		public static void RenameRequest( NetState state, PacketReader pvSrc )
		{
			Mobile from = state.Mobile;
			Mobile targ = World.FindMobile( pvSrc.ReadInt32() );

			if ( targ != null )
				EventSink.InvokeRenameRequest( new RenameRequestEventArgs( from, targ, pvSrc.ReadStringSafe() ) );
		}
		public static void AsciiSpeech( NetState state, PacketReader pvSrc )
		{
			Mobile from = state.Mobile;

			MessageType type = (MessageType)pvSrc.ReadByte();
			int hue = pvSrc.ReadInt16();
			pvSrc.ReadInt16(); // font
			string text = pvSrc.ReadStringSafe().Trim();

			if ( text.Length <= 0 || text.Length > 128 )
				return;

			if ( !Enum.IsDefined( typeof( MessageType ), type ) )
				type = MessageType.Regular;

			from.DoSpeech( text, m_EmptyInts, type, Utility.ClipDyedHue( hue ) );
		}
Exemple #8
0
        public static void OldHeaderChange(NetState state, PacketReader pvSrc)
        {
            Mobile from = state.Mobile;
            BaseBook book = World.FindItem(pvSrc.ReadInt32()) as BaseBook;

            if (book == null || !book.Writable || !from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from))
                return;

            pvSrc.Seek(4, SeekOrigin.Current); // Skip flags and page count

            string title = pvSrc.ReadStringSafe(60);
            string author = pvSrc.ReadStringSafe(30);

            book.Title = Utility.FixHtml(title);
            book.Author = Utility.FixHtml(author);
        }
		public static void AsciiPromptResponse( NetState state, PacketReader pvSrc )
		{
			int serial = pvSrc.ReadInt32();
			int prompt = pvSrc.ReadInt32();
			int type = pvSrc.ReadInt32();
			string text = pvSrc.ReadStringSafe();

			if ( text.Length > 128 )
				return;

			Mobile from = state.Mobile;
			Prompt p = from.Prompt;

			if ( p != null && p.Serial == serial && p.Serial == prompt )
			{
				from.Prompt = null;

				try {
					if ( type == 0 )
						p.OnCancel( from );
					else
						p.OnResponse( from, text );
				} catch (Exception e) {
					log.Fatal(String.Format("Exception disarmed in AsciiPrompt response {0}, type {1}",
											state.Mobile, type), e);
				}
			}
		}
        public static void AsciiPromptResponse(NetState state, PacketReader pvSrc)
        {
            Mobile from = state.Mobile;
            Prompt p = from.Prompt;

            int senderSerial = pvSrc.ReadInt32();
            int promptId = pvSrc.ReadInt32();
            int type = pvSrc.ReadInt32();
            string text = pvSrc.ReadStringSafe();

            if (text.Length > 128)
                return;

            if (p != null && p.Sender.Serial == senderSerial && p.TypeId == promptId)
            {
                from.Prompt = null;

                try
                {
                    if (type == 0)
                        p.OnCancel(from);
                    else
                        p.OnResponse(from, text);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Exception disarmed in AsciiPrompt response {0}, type {1}: {2}", state.Mobile, type, e);
                }
            }
        }
Exemple #11
0
        public static void ChatAction(NetState state, PacketReader pvSrc)
        {
            /*if ( !m_Enabled )
                return;
             */

            if (state == null || state.Mobile == null || state.Account == null)
                return;

            try
            {

                /*
                ChatUser user = ChatUser.GetChatUser( from );

                if ( user == null )
                    return;
                 */

                string lang = pvSrc.ReadStringSafe(4);
                int actionID = pvSrc.ReadInt16();
                string param = pvSrc.ReadUnicodeString();

                /*
				ChatActionHandler handler = ChatActionHandlers.GetHandler( actionID );

				if ( handler != null )
				{
					Channel channel = user.CurrentChannel;

					if ( handler.RequireConference && channel == null )
					{
						user.SendMessage( 31 ); // You must be in a conference to do this.
												// To join a conference, select one from the Conference menu.
					}
					else if ( handler.RequireModerator && !user.IsModerator )
					{
						user.SendMessage( 29 ); // You must have operator status to do this.
					}
					else
					{
						handler.Callback( user, channel, param );
					}
				}
				else
				{
					Console.WriteLine( "Client: {0}: Unknown chat action 0x{1:X}: {2}", state, actionID, param );
				}*/

                // CUSTOM CODE for uoforever--Chat b/w mobs with the same teamflags
                
                
                Mobile from = state.Mobile;
                List<XmlTeam> fromTeams = XmlAttach.GetTeams(from);
                if (fromTeams != null)
                {
                    List<NetState> states = NetState.Instances;
                    foreach (NetState nextstate in states)
                    {
                        if (nextstate.Mobile == null) continue;
                        if (nextstate.Mobile.AccessLevel >= AccessLevel.GameMaster)
                        {
                            // just get the first team
                            nextstate.Mobile.SendMessage(101, "[" + fromTeams[0].TeamVal + "] " + from.Name + ": " + param);
                        }
                        else
                        {
                            if (nextstate.Mobile.CustomTeam)
                            {
                                List<XmlTeam> toTeams = XmlAttach.GetTeams(nextstate.Mobile);
                                if (XmlTeam.SameTeam(fromTeams, toTeams))
                                {
                                    nextstate.Mobile.SendMessage(101, from.Name + ": " + param);
                                }
                            }
                        }
                    }
                }
                else if (from.AccessLevel >= AccessLevel.Counselor 
                    || CreaturePossession.HasAnyPossessPermissions(from))
                {
                    List<NetState> states = NetState.Instances;
                    Mobile sourceMobile = from;
                    if (from is BaseCreature)
                    {
                        sourceMobile = state.Account.GetPseudoSeerLastCharacter();
                    }
                    if (sourceMobile != null)
                    {
                        foreach (NetState nextstate in states)
                        {
                            if (nextstate.Mobile == null) continue;
                            if (nextstate.Mobile.AccessLevel >= AccessLevel.Counselor
                                || CreaturePossession.HasAnyPossessPermissions(nextstate.Mobile))
                            {
                                // just get the first team
                                nextstate.Mobile.SendMessage(101, sourceMobile.Name + ": " + param);
                            }
                            else if (nextstate.Mobile is BaseCreature)
                            {
                                if (nextstate.Account == null) continue;
                                Mobile controllingMobile = nextstate.Account.GetPseudoSeerLastCharacter();
                                if (controllingMobile == null) continue;
                                nextstate.Mobile.SendMessage(101, sourceMobile.Name + ": " + param);
                            }
                        }
                    }
                }
                else if (from is BaseCreature)
                {
                    List<NetState> states = NetState.Instances;
                    Mobile controllingMobile = state.Account.GetPseudoSeerLastCharacter();
                    if (controllingMobile != null)
                    {
                        foreach (NetState nextstate in states)
                        {
                            if (nextstate.Mobile == null) continue;
                            if (nextstate.Mobile.AccessLevel >= AccessLevel.Counselor
                                || CreaturePossession.HasAnyPossessPermissions(nextstate.Mobile))
                            {
                                // just get the first team
                                nextstate.Mobile.SendMessage(101, controllingMobile.Name + ": " + param);
                            }
                            else if (nextstate.Mobile is BaseCreature)
                            {
                                nextstate.Mobile.SendMessage(101, controllingMobile.Name + ": " + param);
                            }
                        }
                    }
                }
                else
                {
                    from.SendMessage("You are not on a team!");
                }
                
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #12
0
		public static void OldHeaderChange( NetState state, PacketReader pvSrc )
		{
			Mobile from = state.Mobile;
			BaseBook book = World.FindItem( pvSrc.ReadInt32() ) as BaseBook;

			if ( book == null || !book.Writable || !from.InRange( book.GetWorldLocation(), 1 ) || !book.IsAccessibleTo( from ) )
				return;

			pvSrc.Seek( 4, SeekOrigin.Current ); // Skip flags and page count

			string title = pvSrc.ReadStringSafe( 60 );
			string author = pvSrc.ReadStringSafe( 30 );

			title = Utility.FixHtml(title);
			author = Utility.FixHtml(author);

			#region AntiAdverts
			if (!String.IsNullOrWhiteSpace(title))
			{
				int exit = 100;
				string detected;

				while (AntiAdverts.Detect(title, out detected) && !String.IsNullOrWhiteSpace(detected) && --exit >= 0)
				{
					title = title.Replace(detected, new String('*', detected.Length));
				}
			}

			if (!String.IsNullOrWhiteSpace(author))
			{
				int exit = 100;
				string detected;

				while (AntiAdverts.Detect(author, out detected) && !String.IsNullOrWhiteSpace(detected) && --exit >= 0)
				{
					author = author.Replace(detected, new String('*', detected.Length));
				}
			}
			#endregion

			book.Title = title;
			book.Author = author;
		}