当前位置: 首页>>代码示例>>C#>>正文


C# PacketReader.ReadString方法代码示例

本文整理汇总了C#中Server.Network.PacketReader.ReadString方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.ReadString方法的具体用法?C# PacketReader.ReadString怎么用?C# PacketReader.ReadString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server.Network.PacketReader的用法示例。


在下文中一共展示了PacketReader.ReadString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BountyEntryResponse

        private static void BountyEntryResponse( NetState ns, PacketReader pvSrc )
        {
            Mobile from = ns.Mobile;
            if ( from == null )
                return;
            Mobile killer = World.FindMobile( (Serial)pvSrc.ReadInt32() );
            byte typeid = pvSrc.ReadByte();
            byte index = pvSrc.ReadByte();
            bool cancel = pvSrc.ReadByte() == 0;
            short responseLen = pvSrc.ReadInt16();
            string resp = pvSrc.ReadString();

            if ( killer != null && !cancel )
            {
                int bounty = Utility.ToInt32( resp );
                if ( bounty > 5000 )
                    bounty = 5000;
                bounty = from.BankBox.ConsumeUpTo( typeof( Gold ), bounty, true );

                killer.Kills++;
                if ( killer is PlayerMobile && bounty > 0 )
                {
                    PlayerMobile kpm = (PlayerMobile)killer;
                    kpm.Bounty += bounty;
                    killer.SendAsciiMessage( "{0} has placed a bounty of {1}gp on your head!", from.Name, bounty );
                    if ( kpm.Bounty >= 5000 && kpm.Kills > 1 && kpm.BankBox.Items.Count > 0 && kpm.Karma <= (int)Noto.Dark )
                    {
                        killer.SayTo( killer, true, "A bounty hath been issued for thee, and thy worldly goods are hereby confiscated!" );
                        kpm.Bounty += EmptyAndGetGold( killer.BankBox.Items );
                    }
                }
            }

            SendNext( from );
        }
开发者ID:FreeReign,项目名称:Rebirth-Repack,代码行数:35,代码来源:ReportMurderer.cs

示例2: Authenticate

        public static void Authenticate( NetState state, PacketReader pvSrc )
        {
            string user = pvSrc.ReadString( 30 );
            string pw = pvSrc.ReadString( 30 );

            Account a = Accounts.GetAccount( user );
            if ( a == null )
            {
                state.Send( new Login( LoginResponse.NoUser ) );
                log.Warn(String.Format("ADMIN: Invalid username '{0}' from {1}",
                                       user, state));
                DelayedDisconnect( state );
            }
            else if ( !a.HasAccess( state ) )
            {
                state.Send( new Login( LoginResponse.BadIP ) );
                log.Warn(String.Format("ADMIN: Access to '{0}' from {1} denied.",
                                       user, state));
                DelayedDisconnect( state );
            }
            else if ( !a.CheckPassword( pw ) )
            {
                state.Send( new Login( LoginResponse.BadPass ) );
                log.Warn(String.Format("ADMIN: Invalid password '{0}' for user '{1}' from {2}",
                                       pw, user, state));
                DelayedDisconnect( state );
            }
            else if ( a.AccessLevel != AccessLevel.Administrator || a.Banned )
            {
                log.Warn(String.Format("ADMIN: Account '{0}' does not have admin access. Connection Denied.",
                                       user));
                state.Send( new Login( LoginResponse.NoAccess ) );
                DelayedDisconnect( state );
            }
            else
            {
                log.Warn(String.Format("ADMIN: Access granted to '{0}' from {1}",
                                       user, state));
                state.Account = a;
                a.LogAccess( state );
                a.LastLogin = DateTime.Now;

                state.Send( new Login( LoginResponse.OK ) );
                state.Send( Compress( new ConsoleData( m_ConsoleData.ToString() ) ) );
                m_Auth.Add( state );
            }
        }
开发者ID:BackupTheBerlios,项目名称:sunuo-svn,代码行数:47,代码来源:Network.cs

示例3: AccountSearch

        private static void AccountSearch(NetState state, PacketReader pvSrc)
        {
            AcctSearchType type = (AcctSearchType)pvSrc.ReadByte();
            string term = pvSrc.ReadString();

            if (type == AcctSearchType.IP && !Utility.IsValidIP(term))
            {
                state.Send(new MessageBoxMessage("Invalid search term.\nThe IP sent was not valid.", "Invalid IP"));
                return;
            }
            else
            {
                term = term.ToUpper();
            }

            ArrayList list = new ArrayList();

            foreach (Account a in Accounts.GetAccounts())
            {
                if (!CanAccessAccount(state.Account, a))
                    continue;

                switch ( type )
                {
                    case AcctSearchType.Username:
                        {
                            if (a.Username.ToUpper().IndexOf(term) != -1)
                                list.Add(a);
                            break;
                        }
                    case AcctSearchType.IP:
                        {
                            for (int i = 0; i < a.LoginIPs.Length; i++)
                            {
                                if (Utility.IPMatch(term, a.LoginIPs[i]))
                                {
                                    list.Add(a);
                                    break;
                                }
                            }
                            break;
                        }
                }
            }

            if (list.Count > 0)
            {
                if (list.Count <= 25)
                    state.Send(AdminNetwork.Compress(new AccountSearchResults(list)));
                else
                    state.Send(new MessageBoxMessage("There were more than 25 matches to your search.\nNarrow the search parameters and try again.", "Too Many Results"));
            }
            else
            {
                state.Send(new MessageBoxMessage("There were no results to your search.\nPlease try again.", "No Matches"));
            }
        }
开发者ID:Crome696,项目名称:ServUO,代码行数:57,代码来源:PacketHandlers.cs

示例4: AssistVersion

		public static void AssistVersion( NetState state, PacketReader pvSrc )
		{
			int unk = pvSrc.ReadInt32();
			string av = pvSrc.ReadString();
		}
开发者ID:Grimoric,项目名称:RunUO.2.3.r1083,代码行数:5,代码来源:PacketHandlers.cs

示例5: ClientVersion

		public static void ClientVersion( NetState state, PacketReader pvSrc )
		{
			CV version = state.Version = new CV( pvSrc.ReadString() );

			EventSink.InvokeClientVersionReceived( new ClientVersionReceivedArgs( state, version ) );
		}
开发者ID:Grimoric,项目名称:RunUO.2.3.r1083,代码行数:6,代码来源:PacketHandlers.cs

示例6: AccountLogin

		public static void AccountLogin( NetState state, PacketReader pvSrc )
		{
			if ( state.SentFirstPacket )
			{
				state.Dispose();
				return;
			}

			state.SentFirstPacket = true;

			string username = pvSrc.ReadString( 30 );
			string password = pvSrc.ReadString( 30 );

			AccountLoginEventArgs e = new AccountLoginEventArgs( state, username, password );

			try {
				EventSink.InvokeAccountLogin(e);
			} catch (Exception ex) {
				log.Fatal(String.Format("Exception disarmed in AccountLogin {0}",
										username), ex);
			}

			if (e.Accepted && Core.Config.Features["quick-local-connect"]) {
				/* we have to remember username+password, because it
				   is required to emulate a GameLogin packet */
				state.Username = username;
				state.Password = password;
			}

			if ( e.Accepted )
				AccountLogin_ReplyAck( state );
			else
				AccountLogin_ReplyRej( state, e.RejectReason );
		}
开发者ID:kamronbatman,项目名称:DefianceUO-Pre1.10,代码行数:34,代码来源:PacketHandlers.cs

示例7: CreateCharacter

		public static void CreateCharacter( NetState state, PacketReader pvSrc )
		{
			/*int unk1 = */pvSrc.ReadInt32();
			/*int unk2 = */pvSrc.ReadInt32();
			/*int unk3 = */pvSrc.ReadByte();
			string name = pvSrc.ReadString( 30 );

			pvSrc.Seek( 2, SeekOrigin.Current );
			int flags = pvSrc.ReadInt32();
			pvSrc.Seek( 8, SeekOrigin.Current );
			int prof = pvSrc.ReadByte();
			pvSrc.Seek( 15, SeekOrigin.Current );

			bool female = pvSrc.ReadByte() > 0 ? true : false;
			/*int genderRace = pvSrc.ReadByte();*/
			int str = pvSrc.ReadByte();
			int dex = pvSrc.ReadByte();
			int intl= pvSrc.ReadByte();
			int is1 = pvSrc.ReadByte();
			int vs1 = pvSrc.ReadByte();
			int is2 = pvSrc.ReadByte();
			int vs2 = pvSrc.ReadByte();
			int is3 = pvSrc.ReadByte();
			int vs3 = pvSrc.ReadByte();
			int hue = pvSrc.ReadUInt16();
			int hairVal = pvSrc.ReadInt16();
			int hairHue = pvSrc.ReadInt16();
			int hairValf= pvSrc.ReadInt16();
			int hairHuef= pvSrc.ReadInt16();
			pvSrc.ReadByte();
			int cityIndex = pvSrc.ReadByte();
			/*int charSlot = */pvSrc.ReadInt32();
			/*int clientIP = */pvSrc.ReadInt32();
			int shirtHue = pvSrc.ReadInt16();
			int pantsHue = pvSrc.ReadInt16();

			CityInfo[] info = state.CityInfo;
			IAccount a = state.Account;

			if ( info == null || a == null || cityIndex < 0 || cityIndex >= info.Length )
			{
				state.Dispose();
			}
			else
			{
				// Check if anyone is using this account
				for ( int i = 0; i < a.Length; ++i )
				{
					Mobile check = a[i];

					if ( check != null && check.Map != Map.Internal )
					{
						log.InfoFormat("Login: {0}: Account in use", state);
						state.Send( new PopupMessage( PMMessage.CharInWorld ) );
						return;
					}
				}

				state.Flags = flags;

				CharacterCreatedEventArgs args = new CharacterCreatedEventArgs(
					state, a,
					name, female, hue,
					str, dex, intl,
					info[cityIndex],
					new SkillNameValue[3]
					{
						new SkillNameValue( (SkillName)is1, vs1 ),
						new SkillNameValue( (SkillName)is2, vs2 ),
						new SkillNameValue( (SkillName)is3, vs3 ),
					},
					shirtHue, pantsHue,
					hairVal, hairHue,
					hairValf, hairHuef,
					prof );

				state.Send( new ClientVersionReq() );

				state.BlockAllPackets = true;

				try {
					EventSink.InvokeCharacterCreated(args);
				} catch (Exception ex) {
					log.Fatal(String.Format("Exception disarmed in CharacterCreated {0}",
											name), ex);
				}

				Mobile m = args.Mobile;

				if ( m != null )
				{
					state.Mobile = m;
					m.NetState = state;
					new LoginTimer( state, m ).Start();
				}
				else
				{
					state.BlockAllPackets = false;
					state.Dispose();
				}
//.........这里部分代码省略.........
开发者ID:kamronbatman,项目名称:DefianceUO-Pre1.10,代码行数:101,代码来源:PacketHandlers.cs

示例8: AccountLogin

		public static void AccountLogin( NetState state, PacketReader pvSrc )
		{
			if ( state.SentFirstPacket )
			{
				state.Dispose();
				return;
			}

			state.SentFirstPacket = true;

			string username = pvSrc.ReadString( 30 );
			string password = pvSrc.ReadString( 30 );

			AccountLoginEventArgs e = new AccountLoginEventArgs( state, username, password );

			EventSink.InvokeAccountLogin( e );

			if ( e.Accepted )
				AccountLogin_ReplyAck( state );
			else
				AccountLogin_ReplyRej( state, e.RejectReason );
		}
开发者ID:Grimoric,项目名称:RunUO.2.3.r1083,代码行数:22,代码来源:PacketHandlers.cs

示例9: SystemInfo

		public static void SystemInfo( NetState state, PacketReader pvSrc )
		{
			int v1 = pvSrc.ReadByte();
			int v2 = pvSrc.ReadUInt16();
			int v3 = pvSrc.ReadByte();
			string s1 = pvSrc.ReadString( 32 );
			string s2 = pvSrc.ReadString( 32 );
			string s3 = pvSrc.ReadString( 32 );
			string s4 = pvSrc.ReadString( 32 );
			int v4 = pvSrc.ReadUInt16();
			int v5 = pvSrc.ReadUInt16();
			int v6 = pvSrc.ReadInt32();
			int v7 = pvSrc.ReadInt32();
			int v8 = pvSrc.ReadInt32();
		}
开发者ID:Grimoric,项目名称:RunUO.2.3.r1083,代码行数:15,代码来源:PacketHandlers.cs

示例10: StringQueryResponse

		public static void StringQueryResponse( NetState state, PacketReader pvSrc )
		{
			int serial = pvSrc.ReadInt32();
			pvSrc.ReadUInt16(); // unknown
			bool ok = pvSrc.ReadBoolean();
			int length = pvSrc.ReadUInt16();
			string str = null;
			if ( length > 0 )
				str = pvSrc.ReadString(length - 1);

			StringQueryCollection stringqueries = state.StringQueries;

			for ( int i = 0; i < stringqueries.Count; ++i )
			{
				StringQuery stringquery = stringqueries[i];

				if ( stringquery.Serial == serial )
				{
					stringquery.OnResponse( state, ok, str );

					state.RemoveStringQuery( i );
					return;
				}
			}
		}
开发者ID:kamronbatman,项目名称:DefianceUO-Pre1.10,代码行数:25,代码来源:PacketHandlers.cs

示例11: CreateCharacter70160

		public static void CreateCharacter70160( NetState state, PacketReader pvSrc )
		{
			int unk1 = pvSrc.ReadInt32();
			int unk2 = pvSrc.ReadInt32();
			int unk3 = pvSrc.ReadByte();
			string name = pvSrc.ReadString( 30 );

			pvSrc.Seek( 2, SeekOrigin.Current );
			int flags = pvSrc.ReadInt32();
			pvSrc.Seek( 8, SeekOrigin.Current );
			int prof = pvSrc.ReadByte();
			pvSrc.Seek( 15, SeekOrigin.Current );

			int genderRace = pvSrc.ReadByte();

			int str = pvSrc.ReadByte();
			int dex = pvSrc.ReadByte();
			int intl= pvSrc.ReadByte();
			int is1 = pvSrc.ReadByte();
			int vs1 = pvSrc.ReadByte();
			int is2 = pvSrc.ReadByte();
			int vs2 = pvSrc.ReadByte();
			int is3 = pvSrc.ReadByte();
			int vs3 = pvSrc.ReadByte();
			int is4 = pvSrc.ReadByte();
			int vs4 = pvSrc.ReadByte();

			int hue = pvSrc.ReadUInt16();
			int hairVal = pvSrc.ReadInt16();
			int hairHue = pvSrc.ReadInt16();
			int hairValf= pvSrc.ReadInt16();
			int hairHuef= pvSrc.ReadInt16();
			pvSrc.ReadByte();
			int cityIndex = pvSrc.ReadByte();
			int charSlot = pvSrc.ReadInt32();
			int clientIP = pvSrc.ReadInt32();
			int shirtHue = pvSrc.ReadInt16();
			int pantsHue = pvSrc.ReadInt16();

			/*
			0x00, 0x01
			0x02, 0x03 -> Human Male, Human Female
			0x04, 0x05 -> Elf Male, Elf Female
			0x05, 0x06 -> Gargoyle Male, Gargoyle Female
			*/

			bool female = ((genderRace % 2) != 0);

			Race race = null;

			byte raceID = (byte)(genderRace < 4 ? 0 : ((genderRace / 2) - 1));
			race = Race.Races[raceID];
		
			if( race == null )
				race = Race.DefaultRace;

			CityInfo[] info = state.CityInfo;
			IAccount a = state.Account;

			if ( info == null || a == null || cityIndex < 0 || cityIndex >= info.Length )
			{
				state.Dispose();
			}
			else
			{
				// Check if anyone is using this account
				for ( int i = 0; i < a.Length; ++i )
				{
					Mobile check = a[i];

					if ( check != null && check.Map != Map.Internal )
					{
						Console.WriteLine( "Login: {0}: Account in use", state );
						state.Send( new PopupMessage( PMMessage.CharInWorld ) );
						return;
					}
				}

				state.Flags = (ClientFlags)flags;

				CharacterCreatedEventArgs args = new CharacterCreatedEventArgs(
					state, a,
					name, female, hue,
					str, dex, intl,
					info[cityIndex],
					new SkillNameValue[4]
					{
						new SkillNameValue( (SkillName)is1, vs1 ),
						new SkillNameValue( (SkillName)is2, vs2 ),
						new SkillNameValue( (SkillName)is3, vs3 ),
						new SkillNameValue( (SkillName)is4, vs4 ),
					},
					shirtHue, pantsHue,
					hairVal, hairHue,
					hairValf, hairHuef,
					prof,
					race
					);

				state.Send( new ClientVersionReq() );
//.........这里部分代码省略.........
开发者ID:Grimoric,项目名称:RunUO.2.3.r1083,代码行数:101,代码来源:PacketHandlers.cs

示例12: TextCommand

		public static void TextCommand( NetState state, PacketReader pvSrc )
		{
			int type = pvSrc.ReadByte();
			string command = pvSrc.ReadString();

			Mobile m = state.Mobile;

			switch ( type )
			{
				case 0x00: // Go
				{
					if ( VerifyGC( state ) )
					{
						try
						{
							string[] split = command.Split( ' ' );

							int x = Utility.ToInt32( split[0] );
							int y = Utility.ToInt32( split[1] );

							int z;

							if ( split.Length >= 3 )
								z = Utility.ToInt32( split[2] );
							else if ( m.Map != null )
								z = m.Map.GetAverageZ( x, y );
							else
								z = 0;

							m.Location = new Point3D( x, y, z );
						}
						catch
						{
						}
					}

					break;
				}
				case 0xC7: // Animate
				{
					EventSink.InvokeAnimateRequest( new AnimateRequestEventArgs( m, command ) );

					break;
				}
				case 0x24: // Use skill
				{
					int skillIndex;

					try{ skillIndex = Convert.ToInt32( command.Split( ' ' )[0] ); }
					catch{ break; }

					try {
						Skills.UseSkill( m, skillIndex );
					} catch (Exception e) {
						log.Fatal(String.Format("Exception disarmed in UseSkill {0} > {1}",
												state.Mobile, skillIndex), e);
					}

					break;
				}
				case 0x43: // Open spellbook
				{
					int booktype;

					try{ booktype = Convert.ToInt32( command ); }
					catch{ booktype = 1; }

					EventSink.InvokeOpenSpellbookRequest( new OpenSpellbookRequestEventArgs( m, booktype ) );

					break;
				}
				case 0x27: // Cast spell from book
				{
					string[] split = command.Split( ' ' );

					if ( split.Length > 0 )
					{
						int spellID = Utility.ToInt32( split[0] ) - 1;
						int serial = split.Length > 1 ? Utility.ToInt32( split[1] ) : -1;

						try {
							EventSink.InvokeCastSpellRequest( new CastSpellRequestEventArgs( m, spellID, World.FindItem( serial ) ) );
						} catch (Exception e) {
							log.Fatal(String.Format("Exception disarmed in CastSpell I {0}, spell {1}",
													state.Mobile, spellID), e);
						}
					}

					break;
				}
				case 0x58: // Open door
				{
					try {
						EventSink.InvokeOpenDoorMacroUsed( new OpenDoorMacroEventArgs( m ) );
					} catch (Exception e) {
						log.Fatal(String.Format("Exception disarmed in OpenDoor {0}",
												state.Mobile), e);
					}

					break;
//.........这里部分代码省略.........
开发者ID:kamronbatman,项目名称:DefianceUO-Pre1.10,代码行数:101,代码来源:PacketHandlers.cs

示例13: UnicodePromptResponse

		public static void UnicodePromptResponse( NetState state, PacketReader pvSrc )
		{
			int serial = pvSrc.ReadInt32();
			int prompt = pvSrc.ReadInt32();
			int type = pvSrc.ReadInt32();
			/*string lang = */pvSrc.ReadString( 4 );
			string text = pvSrc.ReadUnicodeStringLESafe();

			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 UnicodePrompt response {0}, type {1}",
											state.Mobile, type), e);
				}
			}
		}
开发者ID:kamronbatman,项目名称:DefianceUO-Pre1.10,代码行数:29,代码来源:PacketHandlers.cs

示例14: NewRegion

		public static void NewRegion( NetState state, PacketReader pvSrc )
		{
			if ( VerifyGC( state ) )
			{
				string name = pvSrc.ReadString( 40 );
				/*int unk = */pvSrc.ReadInt32();
				/*int x = */pvSrc.ReadInt16();
				/*int y = */pvSrc.ReadInt16();
				/*int width = */pvSrc.ReadInt16();
				/*int height = */pvSrc.ReadInt16();
				/*int zStart = */pvSrc.ReadInt16();
				/*int zEnd = */pvSrc.ReadInt16();
				string desc = pvSrc.ReadString( 40 );
				/*int soundFX = */pvSrc.ReadInt16();
				/*int music = */pvSrc.ReadInt16();
				/*int nightFX = */pvSrc.ReadInt16();
				/*int dungeon = */pvSrc.ReadByte();
				/*int light = */pvSrc.ReadInt16();

				log.InfoFormat("God Client: {0}: New Region '{1}' ('{2}')",
							   state, name, desc);
			}
		}
开发者ID:kamronbatman,项目名称:DefianceUO-Pre1.10,代码行数:23,代码来源:PacketHandlers.cs

示例15: SystemInfo

		public static void SystemInfo( NetState state, PacketReader pvSrc )
		{
			/*int v1 = */pvSrc.ReadByte();
			/*int v2 = */pvSrc.ReadUInt16();
			/*int v3 = */pvSrc.ReadByte();
			/*string s1 = */pvSrc.ReadString( 32 );
			/*string s2 = */pvSrc.ReadString( 32 );
			/*string s3 = */pvSrc.ReadString( 32 );
			/*string s4 = */pvSrc.ReadString( 32 );
			/*int v4 = */pvSrc.ReadUInt16();
			/*int v5 = */pvSrc.ReadUInt16();
			/*int v6 = */pvSrc.ReadInt32();
			/*int v7 = */pvSrc.ReadInt32();
			/*int v8 = */pvSrc.ReadInt32();
		}
开发者ID:kamronbatman,项目名称:DefianceUO-Pre1.10,代码行数:15,代码来源:PacketHandlers.cs


注:本文中的Server.Network.PacketReader.ReadString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。