本文整理汇总了C#中Packet.Seek方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.Seek方法的具体用法?C# Packet.Seek怎么用?C# Packet.Seek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.Seek方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AsciiSpeech
public static void AsciiSpeech( Packet p, PacketHandlerEventArgs args )
{
// 0, 1, 2
Serial serial = p.ReadUInt32(); // 3, 4, 5, 6
ushort body = p.ReadUInt16(); // 7, 8
MessageType type = (MessageType)p.ReadByte(); // 9
ushort hue = p.ReadUInt16(); // 10, 11
ushort font = p.ReadUInt16();
string name = p.ReadStringSafe( 30 );
string text = p.ReadStringSafe();
if ( World.Player != null && serial == Serial.Zero && body == 0 && type == MessageType.Regular && hue == 0xFFFF && font == 0xFFFF && name == "SYSTEM" )
{
args.Block = true;
p.Seek( 3, SeekOrigin.Begin );
p.WriteAsciiFixed( "", (int)p.Length-3 );
ClientCommunication.DoFeatures( World.Player.Features ) ;
}
else
{
HandleSpeech( p, args, serial, body, type, hue, font, "A", name, text );
if ( !serial.IsValid )
BandageTimer.OnAsciiMessage( text );
}
}
示例2: OnGumpResponse
private static void OnGumpResponse(Packet p, PacketHandlerEventArgs args)
{
p.ReadUInt32();
if (p.ReadUInt32() != gumpID)
return;
uint buttonID = p.ReadUInt32();
if ((buttonID - 2) % 6 == 0)
{
p.Seek(-4, SeekOrigin.Current);
p.Write(buttonID + (uint)ConfigEx.GetElement(TeleportType.Default, "RuneBook"));
}
}
示例3: ContainerContent
private static void ContainerContent(Packet p, PacketHandlerEventArgs args)
{
int count = p.ReadUInt16();
for (int i = 0; i < count; i++)
{
Item item = World.FindItem(p.ReadUInt32());
Item container = item.Container as Item;
if (container != null && container.ItemID == 0x2006)
foreach (LootItem loot in items)
if (item.ItemID == loot.Graphic && (item.Hue == loot.Color || loot.Color == 0xFFFF))
{
if (Fixes.LootBag.Bag != 0)
DragDrop.Move(item, Fixes.LootBag.Bag);
WorldEx.OverHeadMessage(loot.Name, container);
}
p.Seek(15, System.IO.SeekOrigin.Current);
}
}
示例4: ContainerContent
private static void ContainerContent(Packet p, PacketHandlerEventArgs args)
{
List<Serial> toRemove = new List<Serial>();
for (ushort count = p.ReadUInt16(); count > 0; count--)
{
Item item = World.FindItem(p.ReadUInt32());
if (item != null && item.Container == World.Player.Backpack)
foreach (FakeItem fake in items.Values)
if (item.ItemID == fake.OrigID && item.Hue == fake.OrigHue)
{
if (!fake.List.Contains(item.Serial))
fake.List.Add(item.Serial);
toRemove.Add(item.Serial);
}
p.Seek(15, SeekOrigin.Current);
}
if (toRemove.Count > 0)
Resend();
toRemove.ForEach(s => WorldEx.SendToClient(new RemoveObject(s)));
}
示例5: EquipmentUpdate
private static void EquipmentUpdate( Packet p, PacketHandlerEventArgs args )
{
Serial serial = p.ReadUInt32();
Item i = World.FindItem( serial );
bool isNew = false;
if ( i == null )
{
World.AddItem( i=new Item( serial ) );
isNew = true;
Item.UpdateContainers();
}
else
{
i.CancelRemove();
}
if ( !DragDropManager.EndHolding( serial ) )
return;
ushort iid = p.ReadUInt16();
i.ItemID = (ushort)(iid + p.ReadSByte()); // signed, itemID offset
i.Layer = (Layer)p.ReadByte();
Serial ser = p.ReadUInt32();// cont must be set after hue (for counters)
i.Hue = p.ReadUInt16();
i.Container = ser;
int ltHue = Config.GetInt( "LTHilight" );
if ( ltHue != 0 && Targeting.IsLastTarget( i.Container as Mobile ) )
{
p.Seek( -2, SeekOrigin.Current );
p.Write( (ushort)(ltHue&0x3FFF) );
}
if ( i.Layer == Layer.Backpack && isNew && Config.GetBool( "AutoSearch" ) && ser == World.Player.Serial )
{
m_IgnoreGumps.Add( i );
PlayerData.DoubleClick( i );
}
}
示例6: HandleRPVContainerContent
public static byte[] HandleRPVContainerContent( Packet p )
{
bool isPostKR = false, decided = false;;
int count = p.ReadUInt16();
ArrayList list = new ArrayList();
for (int i=0;i<count;i++)
{
Serial serial = p.ReadUInt32();
// serial is purposely not checked to be valid, sometimes buy lists dont have "valid" item serials (and we are okay with that).
Item item = World.FindItem( serial );
if ( item == null )
{
World.AddItem( item = new Item( serial ) );
item.IsNew = true;
item.AutoStack = false;
}
else
{
item.CancelRemove();
}
//if ( !DragDropManager.EndHolding( serial ) )
// continue;
item.ItemID = p.ReadUInt16();
item.ItemID = (ushort)(item.ItemID + p.ReadSByte());// signed, itemID offset
item.Amount = p.ReadUInt16();
if ( item.Amount == 0 )
item.Amount = 1;
item.Position = new Point3D( p.ReadUInt16(), p.ReadUInt16(), 0 );
if ( !decided )
{
byte nextByte = p.ReadByte();
isPostKR = ( (nextByte & 0x40) == 0 );
decided = true;
if ( isPostKR == Engine.UsePostKRPackets )
return p.Compile(); // not need to change anything
p.Seek( -1, SeekOrigin.Current );
}
if ( isPostKR )
item.GridNum = p.ReadByte();
Serial cont = p.ReadUInt32();
item.Hue = p.ReadUInt16();
if ( SearchExemptionAgent.Contains( item ) )
{
p.Seek( -2, System.IO.SeekOrigin.Current );
p.Write( (short)Config.GetInt( "ExemptColor" ) );
}
item.Container = cont; // must be done after hue is set (for counters)
if ( !SearchExemptionAgent.IsExempt( item ) && ( item.IsChildOf( World.Player.Backpack ) || item.IsChildOf( World.Player.Quiver ) ) )
Counter.Count( item );
list.Add( item );
}
Item.UpdateContainers();
return new ContainerContent( list, Engine.UsePostKRPackets ).Compile();
}
示例7: ContainerContentUpdate
private static void ContainerContentUpdate( Packet p, PacketHandlerEventArgs args )
{
// This function will ignore the item if the container item has not been sent to the client yet.
// We can do this because we can't really count on getting all of the container info anyway.
// (So we'd need to request the container be updated, so why bother with the extra stuff required to find the container once its been sent?)
Serial serial = p.ReadUInt32();
ushort itemid = p.ReadUInt16();
itemid = (ushort)(itemid + p.ReadSByte()); // signed, itemID offset
ushort amount = p.ReadUInt16();
if ( amount == 0 )
amount = 1;
Point3D pos = new Point3D( p.ReadUInt16(), p.ReadUInt16(), 0 );
byte gridPos = 0;
if ( Engine.UsePostKRPackets )
gridPos = p.ReadByte();
Serial cser = p.ReadUInt32();
ushort hue = p.ReadUInt16();
Item i = World.FindItem( serial );
if ( i == null )
{
if ( !serial.IsItem )
return;
World.AddItem( i = new Item( serial ) );
i.IsNew = i.AutoStack = true;
}
else
{
i.CancelRemove();
}
if ( serial != DragDropManager.Pending )
{
if ( !DragDropManager.EndHolding( serial ) )
return;
}
i.ItemID = itemid;
i.Amount = amount;
i.Position = pos;
i.GridNum = gridPos;
i.Hue = hue;
if ( SearchExemptionAgent.Contains( i ) )
{
p.Seek( -2, System.IO.SeekOrigin.Current );
p.Write( (short)Config.GetInt( "ExemptColor" ) );
}
i.Container = cser;
if ( i.IsNew )
Item.UpdateContainers();
if ( !SearchExemptionAgent.IsExempt( i ) && ( i.IsChildOf( World.Player.Backpack ) || i.IsChildOf( World.Player.Quiver ) ) )
Counter.Count( i );
}
示例8: ContainerContent
private static void ContainerContent( Packet p, PacketHandlerEventArgs args )
{
int count = p.ReadUInt16();
for (int i=0;i<count;i++)
{
Serial serial = p.ReadUInt32();
// serial is purposely not checked to be valid, sometimes buy lists dont have "valid" item serials (and we are okay with that).
Item item = World.FindItem( serial );
if ( item == null )
{
World.AddItem( item = new Item( serial ) );
item.IsNew = true;
item.AutoStack = false;
}
else
{
item.CancelRemove();
}
if ( !DragDropManager.EndHolding( serial ) )
continue;
item.ItemID = p.ReadUInt16();
item.ItemID = (ushort)(item.ItemID + p.ReadSByte());// signed, itemID offset
item.Amount = p.ReadUInt16();
if ( item.Amount == 0 )
item.Amount = 1;
item.Position = new Point3D( p.ReadUInt16(), p.ReadUInt16(), 0 );
if ( Engine.UsePostKRPackets )
item.GridNum = p.ReadByte();
Serial cont = p.ReadUInt32();
item.Hue = p.ReadUInt16();
if ( SearchExemptionAgent.Contains( item ) )
{
p.Seek( -2, System.IO.SeekOrigin.Current );
p.Write( (short)Config.GetInt( "ExemptColor" ) );
}
item.Container = cont; // must be done after hue is set (for counters)
if ( !SearchExemptionAgent.IsExempt( item ) && ( item.IsChildOf( World.Player.Backpack ) || item.IsChildOf( World.Player.Quiver ) ) )
Counter.Count( item );
}
Item.UpdateContainers();
}
示例9: ServerListLogin
private static void ServerListLogin( Packet p, PacketHandlerEventArgs args )
{
m_LastPW = "";
if ( !Config.GetBool( "RememberPwds" ) )
return;
World.AccountName = p.ReadStringSafe( 30 );
string pass = p.ReadStringSafe( 30 );
if ( pass == "" )
{
pass = PasswordMemory.Find( World.AccountName, ClientCommunication.LastConnection );
if ( pass != null && pass != "" )
{
p.Seek( 31, SeekOrigin.Begin );
p.WriteAsciiFixed( pass, 30 );
m_LastPW = pass;
}
}
else
{
PasswordMemory.Add( World.AccountName, pass, ClientCommunication.LastConnection );
}
}
示例10: MobileUpdate
private static void MobileUpdate( Packet p, PacketHandlerEventArgs args )
{
if ( World.Player == null )
return;
Serial serial = p.ReadUInt32();
Mobile m = World.FindMobile( serial );
if ( m == null )
World.AddMobile( m = new Mobile( serial ) );
bool wasHidden = !m.Visible;
m.Body = (ushort)(p.ReadUInt16() + p.ReadSByte());
m.Hue = p.ReadUInt16();
int ltHue = Config.GetInt( "LTHilight" );
if ( ltHue != 0 && Targeting.IsLastTarget( m ) )
{
p.Seek( -2, SeekOrigin.Current );
p.Write( (ushort)(ltHue|0x8000) );
}
bool wasPoisoned = m.Poisoned;
m.ProcessPacketFlags( p.ReadByte() );
if ( m == World.Player )
{
ClientCommunication.BeginCalibratePosition();
World.Player.Resync();
if ( !wasHidden && !m.Visible )
{
if ( Config.GetBool( "AlwaysStealth" ) )
StealthSteps.Hide();
}
else if ( wasHidden && m.Visible )
{
StealthSteps.Unhide();
}
if ( wasPoisoned != m.Poisoned )
ClientCommunication.RequestTitlebarUpdate();
}
ushort x = p.ReadUInt16();
ushort y = p.ReadUInt16();
p.ReadUInt16(); //always 0?
m.Direction = (Direction)p.ReadByte();
m.Position = new Point3D( x, y, p.ReadSByte() );
Item.UpdateContainers();
}
示例11: MobileMoving
private static void MobileMoving( Packet p, PacketHandlerEventArgs args )
{
Mobile m = World.FindMobile( p.ReadUInt32() );
if ( m != null )
{
m.Body = p.ReadUInt16();
m.Position = new Point3D( p.ReadUInt16(), p.ReadUInt16(), p.ReadSByte() );
if ( World.Player != null && !Utility.InRange( World.Player.Position, m.Position, World.Player.VisRange ) )
{
m.Remove();
return;
}
Targeting.CheckLastTargetRange( m );
m.Direction = (Direction)p.ReadByte();
m.Hue = p.ReadUInt16();
int ltHue = Config.GetInt( "LTHilight" );
if ( ltHue != 0 && Targeting.IsLastTarget( m ) )
{
p.Seek( -2, SeekOrigin.Current );
p.Write( (short)(ltHue|0x8000) );
}
bool wasPoisoned = m.Poisoned;
m.ProcessPacketFlags( p.ReadByte() );
byte oldNoto = m.Notoriety;
m.Notoriety = p.ReadByte();
if ( m == World.Player )
{
ClientCommunication.BeginCalibratePosition();
if ( wasPoisoned != m.Poisoned || ( oldNoto != m.Notoriety && Config.GetBool( "ShowNotoHue" ) ) )
ClientCommunication.RequestTitlebarUpdate();
}
}
}
示例12: HandleRPVContainerContentUpdate
public static byte[] HandleRPVContainerContentUpdate( Packet p )
{
// This function will ignore the item if the container item has not been sent to the client yet.
// We can do this because we can't really count on getting all of the container info anyway.
// (So we'd need to request the container be updated, so why bother with the extra stuff required to find the container once its been sent?)
bool isPostKR = false, decided = false;
Serial serial = p.ReadUInt32();
ushort itemid = p.ReadUInt16();
itemid = (ushort)(itemid + p.ReadSByte()); // signed, itemID offset
ushort amount = p.ReadUInt16();
if ( amount == 0 )
amount = 1;
Point3D pos = new Point3D( p.ReadUInt16(), p.ReadUInt16(), 0 );
byte gridPos = 0;
if ( !decided )
{
byte nextByte = p.ReadByte();
isPostKR = ( (nextByte & 0x40) == 0 );
decided = true;
if ( isPostKR == Engine.UsePostKRPackets )
return p.Compile(); // not need to change anything
p.Seek( -1, SeekOrigin.Current );
}
if ( isPostKR )
gridPos = p.ReadByte();
Serial cser = p.ReadUInt32();
ushort hue = p.ReadUInt16();
Item i = World.FindItem( serial );
if ( i == null )
{
if ( !serial.IsItem )
return p.Compile();
World.AddItem( i = new Item( serial ) );
i.IsNew = i.AutoStack = true;
}
i.ItemID = itemid;
i.Amount = amount;
i.Position = pos;
i.GridNum = gridPos;
i.Hue = hue;
i.Container = cser;
if ( i.IsNew )
Item.UpdateContainers();
if ( !SearchExemptionAgent.IsExempt( i ) && ( i.IsChildOf( World.Player.Backpack ) || i.IsChildOf( World.Player.Quiver ) ) )
Counter.Count( i );
return new ContainerItem( i, Engine.UsePostKRPackets ).Compile();
}
示例13: MobileIncoming
private static void MobileIncoming( Packet p, PacketHandlerEventArgs args )
{
if ( World.Player == null )
return;
Serial serial = p.ReadUInt32();
ushort body = p.ReadUInt16();
Point3D position = new Point3D( p.ReadUInt16(), p.ReadUInt16(), p.ReadSByte() );
if ( World.Player.Position != Point3D.Zero && !Utility.InRange( World.Player.Position, position, World.Player.VisRange ) )
return;
Mobile m = World.FindMobile( serial );
if ( m == null )
World.AddMobile( m = new Mobile( serial ) );
bool wasHidden = !m.Visible;
if ( m != World.Player && Config.GetBool( "ShowMobNames" ) )
ClientCommunication.SendToServer( new SingleClick( m ) );
if ( Config.GetBool( "LastTargTextFlags" ) )
Targeting.CheckTextFlags( m );
int ltHue = Config.GetInt( "LTHilight" );
bool isLT;
if ( ltHue != 0 )
isLT = Targeting.IsLastTarget( m );
else
isLT = false;
m.Body = body;
if ( m != World.Player || World.Player.OutstandingMoveReqs == 0 )
m.Position = position;
m.Direction = (Direction)p.ReadByte();
m.Hue = p.ReadUInt16();
if ( isLT )
{
p.Seek( -2, SeekOrigin.Current );
p.Write( (short)(ltHue|0x8000) );
}
bool wasPoisoned = m.Poisoned;
m.ProcessPacketFlags( p.ReadByte() );
byte oldNoto = m.Notoriety;
m.Notoriety = p.ReadByte();
if ( m == World.Player )
{
ClientCommunication.BeginCalibratePosition();
if ( !wasHidden && !m.Visible )
{
if ( Config.GetBool( "AlwaysStealth" ) )
StealthSteps.Hide();
}
else if ( wasHidden && m.Visible )
{
StealthSteps.Unhide();
}
if ( wasPoisoned != m.Poisoned || ( oldNoto != m.Notoriety && Config.GetBool( "ShowNotoHue" ) ) )
ClientCommunication.RequestTitlebarUpdate();
}
while ( true )
{
serial = p.ReadUInt32();
if ( !serial.IsItem )
break;
Item item = World.FindItem( serial );
bool isNew = false;
if ( item == null )
{
isNew = true;
World.AddItem( item = new Item( serial ) );
}
if ( !DragDropManager.EndHolding( serial ) )
continue;
item.Container = m;
ushort id = p.ReadUInt16();
if (Engine.UseNewMobileIncoming)
item.ItemID = (ushort)(id & 0xFFFF);
else if (Engine.UsePostSAChanges)
item.ItemID = (ushort)(id & 0x7FFF);
else
item.ItemID = (ushort)(id & 0x3FFF);
item.Layer = (Layer)p.ReadByte();
if (Engine.UseNewMobileIncoming)
{
item.Hue = p.ReadUInt16();
if (isLT)
{
p.Seek(-2, SeekOrigin.Current);
//.........这里部分代码省略.........
示例14: GameLogin
private static void GameLogin( Packet p, PacketHandlerEventArgs args )
{
int authID = p.ReadInt32();
World.AccountName = p.ReadString( 30 );
string password = p.ReadString( 30 );
if ( password == "" && m_LastPW != "" && Config.GetBool( "RememberPwds" ) )
{
p.Seek( 35, SeekOrigin.Begin );
p.WriteAsciiFixed( m_LastPW, 30 );
m_LastPW = "";
}
}
示例15: ExtendedClientCommand
private static void ExtendedClientCommand( Packet p, PacketHandlerEventArgs args )
{
ushort ext = p.ReadUInt16();
switch ( ext )
{
case 0x10: // query object properties
{
break;
}
case 0x15: // context menu response
{
UOEntity ent = null;
Serial ser = p.ReadUInt32();
ushort idx = p.ReadUInt16();
if ( ser.IsMobile )
ent = World.FindMobile( ser );
else if ( ser.IsItem )
ent = World.FindItem( ser );
if ( ent != null && ent.ContextMenu != null && ent.ContextMenu.ContainsKey( idx ) )
{
ushort menu = (ushort)ent.ContextMenu[idx];
if ( menu != 0 && MacroManager.AcceptActions )
MacroManager.Action( new ContextMenuAction( ent, idx, menu ) );
}
break;
}
case 0x1C:// cast spell
{
Serial ser = Serial.MinusOne;
if ( p.ReadUInt16() == 1 )
ser = p.ReadUInt32();
ushort sid = p.ReadUInt16();
Spell s = Spell.Get( sid );
if ( s != null )
{
s.OnCast( p );
args.Block = true;
if ( Macros.MacroManager.AcceptActions )
MacroManager.Action( new ExtCastSpellAction( s, ser ) );
}
break;
}
case 0x24:
{
// for the cheatx0r part 2... anything outside this range indicates some haxing, just hide it with 0x30s
byte b = p.ReadByte();
if ( b < 0x25 || b >= 0x5E+0x25 )
{
p.Seek( -1, SeekOrigin.Current );
p.Write( (byte)0x30 );
}
//using ( StreamWriter w = new StreamWriter( "bf24.txt", true ) )
// w.WriteLine( "{0} : 0x{1:X2}", DateTime.Now.ToString( "HH:mm:ss.ffff" ), b );
break;
}
}
}