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


C# PacketReader.Seek方法代码示例

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


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

示例1: OnFilter

        public override void OnFilter( PacketReader p, PacketHandlerEventArgs args )
        {
            // completely skip this filter if we've been connected for more thn 1 minute
            if ( ClientCommunication.ConnectionStart + TimeSpan.FromMinutes( 1.0 ) < DateTime.Now )
                return;

            try
            {
                p.Seek( 0, System.IO.SeekOrigin.Begin );
                byte packetID = p.ReadByte();

                p.MoveToData();

                uint ser = p.ReadUInt32();
                uint tid = p.ReadUInt32();
                int x = p.ReadInt32();
                int y = p.ReadInt32();
                string layout = null;

                if ( packetID == 0xDD )
                {
                    layout = p.GetCompressedReader().ReadString();
                }
                else
                {
                    ushort layoutLength = p.ReadUInt16();
                    layout = p.ReadString( layoutLength );
                }

                if ( layout != null && layout.IndexOf( m_VetRewardStr ) != -1 )
                    args.Block = true;
            }
            catch
            {
            }
        }
开发者ID:WildGenie,项目名称:Razor,代码行数:36,代码来源:VetRewardGump.cs

示例2: CharNameRequest

		/// Requesting unit's name
		/// 0094 14: <dont_know>.? Position 10 <object id>.L
		public static void CharNameRequest(NetState state, PacketReader reader) {
			if (state.IsValid(EAccountState.World) == false) {
				state.Disconnect();
				return;
			}

			reader.Seek(10, System.IO.SeekOrigin.Begin);
			int id = reader.ReadInt32();
			// Disguises using -ID..
			if (id < 0 && -id == state.Account.ID) {
				id = (int)state.Account.ID;
			}

			// First option - a character
			WorldObject obj = World.Objects[EDatabaseType.Char, id];
			if (obj == null) {
				// 2nd - a monster
				obj = World.Objects[EDatabaseType.Mob, id];
				if (obj == null) {
					// 3rd - a item (?)
					obj = World.Objects[EDatabaseType.Item, id];
					if (obj == null) {
						// Lagged clients could request names of already gone mobs/players..
						// so no disconnect on invalid requests..
						//state.Disconnect();
						return;
					}
				}
			}

			// Fix: we send the accountID as unique ID for chars (its working because no account could connect twice)
			//		this leads to this situation, we will get the account object from World.Objects
			//		instead of the character
			if (obj is Account) {
				obj = (obj as Account).ActiveChar;
			}

			// Moveable unit?
			if (
				(obj is WorldObjectUnit) && (
					(obj as WorldObjectUnit).Location.Map != state.Account.ActiveChar.Location.Map ||
					(obj as WorldObjectUnit).InRange(state.ActiveChar, Global.AREA_SIZE) == false
				)
			) {
				return; // Block namerequests past view range
			}

			// 'see people in GM hide' cheat detection
			/* disabled due to false positives (network lag + request name of char that's about to hide = race condition)
			sc = status_get_sc(bl);
			if (sc && sc->option&OPTION_INVISIBLE && !disguised(bl) &&
				bl->type != BL_NPC && //Skip hidden NPCs which can be seen using Maya Purple
				pc_isGM(sd) < battle_config.hack_info_GM_level
			) {
				char gm_msg[256];
				sprintf(gm_msg, "Hack on NameRequest: character '%s' (account: %d) requested the name of an invisible target (id: %d).\n", sd->status.name, sd->status.account_id, id);
				ShowWarning(gm_msg);
				// information is sent to all online GMs
				intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, gm_msg);
				return;
			}
			*/

			state.Send(new WorldResponseCharNameAck(obj));
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:67,代码来源:WorldHandler.cs

示例3: Read

        public void Read( PacketReader p )
        {
            m_Content.Clear();

            p.Seek( 5, System.IO.SeekOrigin.Begin ); // seek to packet data

            p.ReadUInt32(); // serial
            p.ReadByte(); // 0
            p.ReadByte(); // 0
            m_Hash = p.ReadInt32();

            m_StringNums.Clear();
            m_StringNums.AddRange( m_DefaultStringNums );

            while ( p.Position < p.Length )
            {
                int num = p.ReadInt32();
                if ( num == 0 )
                    break;

                m_StringNums.Remove( num );

                short bytes = p.ReadInt16();
                string args = null;
                if ( bytes > 0 )
                    args = p.ReadUnicodeStringBE( bytes >> 1 );

                m_Content.Add( new OPLEntry( num, args ) );
            }

            for(int i=0;i<m_CustomContent.Count;i++)
            {
                OPLEntry ent = (OPLEntry)m_CustomContent[i];
                if ( m_StringNums.Contains( ent.Number ) )
                {
                    m_StringNums.Remove( ent.Number );
                }
                else
                {
                    for (int s=0;s<m_DefaultStringNums.Length;s++)
                    {
                        if ( ent.Number == m_DefaultStringNums[s] )
                        {
                            ent.Number = GetStringNumber();
                            break;
                        }
                    }
                }
            }
        }
开发者ID:WildGenie,项目名称:Razor,代码行数:50,代码来源:ObjectPropertyList.cs


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