本文整理汇总了C#中Packet.ReadUInt32方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.ReadUInt32方法的具体用法?C# Packet.ReadUInt32怎么用?C# Packet.ReadUInt32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.ReadUInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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"));
}
}
示例2: 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 );
}
}
示例3: WriteReadByteDataTest
public void WriteReadByteDataTest()
{
Packet writePacket = new Packet(packetOpcode);
writePacket.Write(uint32Value);
writePacket.Write(uint16Value);
writePacket.Write(byteValue);
writePacket.Write(int32Value);
writePacket.Write(int16Value);
writePacket.Write(sbyteValue);
writePacket.Write(stringValue);
writePacket.Write(byteArrayValue);
Packet readPacket = new Packet(writePacket.Data);
Assert.AreEqual(writePacket.OpcodeNumber, readPacket.OpcodeNumber);
Assert.AreEqual(uint32Value, readPacket.ReadUInt32());
Assert.AreEqual(uint16Value, readPacket.ReadUInt16());
Assert.AreEqual(byteValue, readPacket.ReadByte());
Assert.AreEqual(int32Value, readPacket.ReadInt32());
Assert.AreEqual(int16Value, readPacket.ReadInt16());
Assert.AreEqual(sbyteValue, readPacket.ReadSByte());
Assert.AreEqual(stringValue, readPacket.ReadString());
var packetBytes = readPacket.ReadBytes();
for (int i = 0; i < byteArrayValue.Length; i++)
Assert.AreEqual(byteArrayValue[i], packetBytes[i]);
readPacket.Dispose();
writePacket.Dispose();
}
示例4: ContainerContentUpdate2
private static void ContainerContentUpdate2(Packet p, PacketHandlerEventArgs args)
{
Serial serial = p.ReadUInt32();
Item item = World.FindItem(serial);
if (item != null && item.Container == World.Player.Backpack && item.IsContainer)
{
if (containers.ContainsKey(serial))
containers[serial] = item;
else
containers.Add(serial, item);
}
}
示例5: 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);
}
}
示例6: 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)));
}
示例7: ServerPacket
public static bool ServerPacket( Packet p )
{
if ( Playing )
{
return false; // dont allow the client to recv server packets.
}
else if ( m_Recording && p != null )
{
if ( World.Player == null )
{
Stop();
return true;
}
switch ( p.PacketID )
{
case 0x21: // Movement Reject
case 0x27: // Lift Reject
case 0x6C: // Target
case 0x7C: // Menu
case 0x88: // Display paper doll
case 0xB2: // Chat Message
case 0xBA: // Quest Arrow
return true;
case 0x22: // Movement Ack
{
// replace movement ack with a force walk
byte seq = p.ReadByte();
if ( World.Player.HasWalkEntry( seq ) )
{
WritePacket( new ForceWalk( World.Player.GetMoveEntry( seq ).Dir&Direction.Mask ) );
//WritePacket( new MobileUpdate( World.Player ) );
}
return true;
}
case 0xBF:
{
short type = p.ReadInt16();
switch ( type )
{
case 0x06:// party stuff
{
byte subType = p.ReadByte();
if ( subType == 0x03 || subType == 0x04 )
{
Mobile from = World.FindMobile( p.ReadUInt32() );
string msg = p.ReadUnicodeStringSafe();
string send = String.Format( "[{0}]: {1}", from != null && from.Name != null && from.Name.Length > 0 ? from.Name : "Party", msg );
WritePacket( new UnicodeMessage( Serial.MinusOne, 0, MessageType.System, 0x3b2, 3, "ENU", "Party", send ) );
}
return true;
}
case 0x1D: // House Revision info
{
Item i = World.FindItem( p.ReadUInt32() );
if ( i != null )
{
i.HouseRevision = p.ReadInt32();
if ( m_HouseDataWritten[i.Serial] == null )
{
if ( i.HousePacket == null )
i.MakeHousePacket();
if ( i.HousePacket != null )
{
m_HouseDataWritten[i.Serial] = true;
// WritePacket( p );
WritePacket( new Packet( i.HousePacket, i.HousePacket.Length, true ) );
return true;
}
}
}
break;
}
}
break;
}
case 0xD8: // Custom House data
{
p.ReadByte(); // Compression
p.ReadByte(); // Unknown
Serial s = p.ReadUInt32();
m_HouseDataWritten[s] = true;
break;
}
}
WritePacket( p );
return true;
}
else
{
return true;
//.........这里部分代码省略.........
示例8: 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 );
}
}
示例9: 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 );
}
示例10: OnLocalizedMessageAffix
private static void OnLocalizedMessageAffix( Packet p, PacketHandlerEventArgs phea )
{
// 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();
int num = p.ReadInt32();
byte affixType = p.ReadByte();
string name = p.ReadStringSafe( 30 );
string affix = p.ReadStringSafe();
string args = p.ReadUnicodeStringSafe();
if (( num >= 3002011 && num < 3002011+64 ) || // reg spells
( num >= 1060509 && num < 1060509+16 ) || // necro
( num >= 1060585 && num < 1060585+10 ) || // chiv
( num >= 1060493 && num < 1060493+10 ) || // chiv
( num >= 1060595 && num < 1060595+6 ) || // bush
( num >= 1060610 && num < 1060610+8 ) // ninj
)
{
type = MessageType.Spell;
}
string text;
if ( (affixType&1)!=0 ) // prepend
text = String.Format( "{0}{1}", affix, Language.ClilocFormat( num, args ) );
else // 0 == append, 2 = system
text = String.Format( "{0}{1}", Language.ClilocFormat( num, args ), affix );
HandleSpeech( p, phea, serial, body, type, hue, font, Language.CliLocName.ToUpper(), name, text );
}
示例11: 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();
}
示例12: HandleChannelEnter
async private void HandleChannelEnter(TcpSession session, Packet p)
{
var id = p.ReadUInt32();
//_logger.Debug("-C_CHAN_ENTER_REQ- ID: {0}", id);
Player plr;
if (!Players.TryGetValue(session.Guid, out plr))
{
session.StopListening();
return;
}
Channel channel;
if (!Channels.TryGetValue((ushort)id, out channel))
return;
channel.Join(plr);
var ack = new Packet(EGamePacket.SResultAck);
ack.Write((uint)5);
session.Send(ack);
ack = new Packet(EGamePacket.SCashUpdateAck);
ack.Write(plr.PEN);
ack.Write(plr.AP);
session.Send(ack);
//if (plr.ConnectionType == 0x06)
// Alice.SendMessageTo(plr.AccountID, "Mit deinem Router ist es leider nicht möglich hier zu spielen :(");
//else if (plr.ConnectionType == 0x04)
// Alice.SendMessageTo(plr.AccountID, "Mit deinem Router kannst du leider nur einen Raum erstellen :(");
await Task.Delay(1000);
SendRoomList(session);
}
示例13: HandleTimeSync
private void HandleTimeSync(TcpSession session, Packet p)
{
var time = p.ReadUInt32();
var ts = DateTime.Now - Process.GetCurrentProcess().StartTime;
var ack = new Packet(EGamePacket.STimeSyncAck);
ack.Write(time);
ack.Write((uint)ts.TotalMilliseconds);
session.Send(ack);
Player plr;
if (!Players.TryGetValue(session.Guid, out plr)) return;
plr.Ping = time - plr.LastSyncTime - 3000;
plr.LastSyncTime = time;
}
示例14: HandleCreateCharacter
private void HandleCreateCharacter(TcpSession session, Packet p)
{
var slot = p.ReadByte();
var avatar = p.ReadUInt32();
//_logger.Debug("-C_CREATE_CHARACTER_REQ- Slot: {0} Avatar: {1}", slot, avatar);
Player plr;
if (!Players.TryGetValue(session.Guid, out plr))
{
session.StopListening();
return;
}
if (plr.Characters.Count >= 3) // no cheating my friend!
{
session.StopListening();
return;
}
var character = new Character {Slot = slot, Avatar = avatar};
plr.Characters.Add(character);
GameDatabase.Instance.CreateCharacter(plr.AccountID, slot, avatar);
var ack = new Packet(EGamePacket.SCreateCharacterAck);
ack.Write(slot);
ack.Write(avatar);
ack.Write((byte)1); // SKILL COUNT
ack.Write((byte)3); // WEAPON COUNT
session.Send(ack);
}
示例15: HandleNATInfo
private void HandleNATInfo(TcpSession session, Packet p)
{
var ip = (IPEndPoint) session.Client.Client.RemoteEndPoint;
Player plr;
if (!Players.TryGetValue(session.Guid, out plr))
{
session.StopListening();
return;
}
plr.PrivateIP = p.ReadUInt32();
plr.PrivatePort = p.ReadUInt16();
plr.PublicIP = p.ReadUInt32();
plr.PublicPort = p.ReadUInt16();
// ignore public stuff from client
plr.PublicIP = (uint)ip.Address.Address;
plr.PublicPort = plr.PrivatePort;
plr.NATUnk = p.ReadUInt16();
plr.ConnectionType = p.ReadByte();
if (ip.Address.ToString() == "127.0.0.1")
plr.ConnectionType = 1;
if (plr.ConnectionType == 6)
plr.ConnectionType = 4;
Logger.Info("-CNATInfoReq- NATUnk: {0} Type: {1}", plr.NATUnk, plr.ConnectionType);
}