本文整理汇总了C#中PacketReader.ReadUInt16方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.ReadUInt16方法的具体用法?C# PacketReader.ReadUInt16怎么用?C# PacketReader.ReadUInt16使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketReader
的用法示例。
在下文中一共展示了PacketReader.ReadUInt16方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnicodeSpeechRequest
public UnicodeSpeechRequest(byte[] data)
: base(data)
{
PacketReader reader = new PacketReader(data);
byte id = reader.ReadByte();
ushort blockSize = reader.ReadUInt16();
byte type = reader.ReadByte();
this.type = (byte)(type & 0x0F);
color = reader.ReadUInt16();
font = reader.ReadUInt16();
language = reader.ReadAnsiString(4);
if ((type & 0xC0) != 0)
{
int numKeywords = (Data[12] << 4) + (Data[13] >> 4);
reader.Skip(((numKeywords * 12 + 12) + 7) / 8);
text = reader.ReadAnsiString(Lenght - reader.Offset);
}
else
{
text = reader.ReadUnicodeString(Lenght - reader.Offset);
}
}
示例2: OnFilter
public override void OnFilter( PacketReader p, PacketHandlerEventArgs args )
{
uint serial = p.ReadUInt32();
ushort itemID = p.ReadUInt16();
if ( (serial & 0x80000000) != 0 )
p.ReadUInt16(); // amount
if ( (itemID & 0x8000) != 0 )
itemID = (ushort)((itemID&0x7FFF) + p.ReadSByte()); // itemID offset
ushort x = p.ReadUInt16();
ushort y = p.ReadUInt16();
if ( (x & 0x8000) != 0 )
p.ReadByte(); // direction
short z = p.ReadSByte();
if ( ( y & 0x8000 ) != 0 )
p.ReadUInt16(); // hue
bool visable = true;
if ( ( y & 0x4000 ) != 0 )
{
int flags = p.ReadByte();
visable = ( (flags&0x80) == 0 );
}
if ( IsStaffItem( itemID ) || !visable )
args.Block = true;
}
示例3: Menu
public Menu(byte[] data)
: base(data)
{
PacketReader reader = new PacketReader(data);
byte id = reader.ReadByte();
ushort blockSize = reader.ReadUInt16();
dialogSerial = reader.ReadUInt32();
menuSerial = reader.ReadUInt16();
byte titleLen = reader.ReadByte();
title = reader.ReadAnsiString(titleLen);
byte optionCount = reader.ReadByte();
MenuOption[] optionList = new MenuOption[optionCount];
for (int i = 0; i < optionCount; i++) {
optionList[i].Artwork = reader.ReadUInt16();
optionList[i].Hue = reader.ReadUInt16();
byte textLen = reader.ReadByte();
optionList[i].Text = reader.ReadAnsiString(textLen);
}
options = Array.AsReadOnly<MenuOption>(optionList);
// if (reader.Offset == reader.Length)
// System.Diagnostics.Debug.WriteLine("Menu packet resolved succesfully.", "Communication");
}
示例4: OnFilter
public override void OnFilter( PacketReader p, PacketHandlerEventArgs args )
{
if ( args.Block )
return;
// 0, 1, 2
Serial serial = p.ReadUInt32(); // 3, 4, 5, 6
ushort body = p.ReadUInt16(); // 7, 8
MessageType type = (MessageType)p.ReadByte(); // 9
if ( type != m_Type )
return;
ushort hue = p.ReadUInt16(); // 10, 11
ushort font = p.ReadUInt16();
string name = p.ReadStringSafe( 30 );
string text = p.ReadStringSafe();
for(int i=0;i<m_Strings.Length;i++)
{
if ( text.IndexOf( m_Strings[i] ) != -1 )
{
args.Block = true;
return;
}
}
}
示例5: RealmList
public RealmList(PacketReader reader)
{
Type = reader.ReadByte();
locked = reader.ReadByte();
Flags = reader.ReadByte();
Name = reader.ReadCString();
string address = reader.ReadCString();
string[] tokens = address.Split(':');
Address = tokens[0];
Port = tokens.Length > 1 ? int.Parse(tokens[1]) : 8085;
Population = reader.ReadSingle();
load = reader.ReadByte();
timezone = reader.ReadByte();
unk1 = reader.ReadByte();
if ((Flags & 4) != 0)
{
major = reader.ReadByte();
minor = reader.ReadByte();
bugfix = reader.ReadByte();
build = reader.ReadUInt16();
}
unk2 = reader.ReadUInt16();
}
示例6: NodeLap
/// <summary>
/// Creates a new NodeLap sub-packet.
/// </summary>
/// <param name="reader">A <see cref="PacketReader"/> contaning the packet data.</param>
public NodeLap(PacketReader reader) {
if (reader == null) {
throw new ArgumentNullException("reader");
}
Node = reader.ReadUInt16();
Lap = reader.ReadUInt16();
PLID = reader.ReadByte();
Position = reader.ReadByte();
}
示例7: Packet
public Packet(byte[] buffer)
{
m_ReadStream = new PacketReader(buffer, buffer.Length, true);
m_Size = m_ReadStream.ReadUInt16();
m_Flag = m_ReadStream.ReadUInt16();
m_Opcode = m_ReadStream.ReadUInt16();
m_Request = true;
}
示例8: Read
/// <summary>
/// The read.
/// </summary>
/// <param name="client">
/// </param>
/// <param name="packet">
/// </param>
public void Read(Client client, byte[] packet)
{
PacketReader reader = new PacketReader(ref packet);
reader.ReadUInt16(); // Packet ID
reader.ReadUInt16(); // Data length
this.playerId = reader.ReadUInt32();
client.Server.Debug(
client, "{0} >> PrivGrpKickPlayer: PlayerID: {1}", client.Character.characterName, this.playerId);
reader.Finish();
}
示例9: IS_CON
/// <summary>
/// Creates a new instance of the <see cref="IS_CON"/> packet.
/// </summary>
/// <param name="buffer">A buffer containing the packet data.</param>
public IS_CON(byte[] buffer) {
PacketReader reader = new PacketReader(buffer);
Size = reader.ReadByte();
Type = (PacketType)reader.ReadByte();
ReqI = reader.ReadByte();
reader.Skip(1);
SpClose = reader.ReadUInt16();
Time = TimeSpan.FromMilliseconds(reader.ReadUInt16() * 10);
A = new CarContact(reader);
B = new CarContact(reader);
}
示例10: OnASCIIMessage
private static void OnASCIIMessage(PacketReader p, PacketHandlerEventArgs args)
{
Serial serial = p.ReadUInt32();
ItemID graphic = p.ReadUInt16();
byte type = p.ReadByte();
ushort hue = p.ReadUInt16();
ushort font = p.ReadUInt16();
string name = p.ReadStringSafe(30);
string msg = p.ReadStringSafe().Trim();
Handle(asciiMessage, args, serial, graphic, type, hue, font, string.Empty, name, msg);
}
示例11: OnLocalizedMessage
private static void OnLocalizedMessage(PacketReader p, PacketHandlerEventArgs args)
{
Serial serial = p.ReadUInt32();
ItemID graphic = p.ReadUInt16();
byte type = p.ReadByte();
ushort hue = p.ReadUInt16();
ushort font = p.ReadUInt16();
int num = p.ReadInt32();
string name = p.ReadStringSafe(30);
string arguments = p.ReadUnicodeStringBE(((p.Length - 1) - p.Position) / 2);
Handle(localizedMessage, args, serial, graphic, type, hue, font, num, name, arguments);
}
示例12: Read
/// <summary>
/// The read.
/// </summary>
/// <param name="client">
/// </param>
/// <param name="packet">
/// </param>
public static void Read(Client client, byte[] packet)
{
PacketReader reader = new PacketReader(ref packet);
reader.ReadUInt16(); // Packet ID
reader.ReadUInt16(); // Data length
uint unknown = reader.ReadUInt32(); // ?
string username = reader.ReadString();
string password = reader.ReadString();
reader.Finish();
}
示例13: IS_OBH
/// <summary>
/// Creates a new <see cref="IS_OBH"/> object.
/// </summary>
/// <param name="buffer">The packet data.</param>
public IS_OBH(byte[] buffer) {
PacketReader reader = new PacketReader(buffer);
Size = reader.ReadByte();
Type = (PacketType)reader.ReadByte();
ReqI = reader.ReadByte();
PLID = reader.ReadByte();
SpClose = reader.ReadUInt16();
Time = TimeSpan.FromMilliseconds(reader.ReadUInt16() * 10);
C = new CarContOBJ(reader);
X = reader.ReadInt16();
Y = reader.ReadInt16();
reader.Skip(2);
Index = reader.ReadByte();
OBHFlags = (ObjectFlags)reader.ReadByte();
}
示例14: IS_LAP
/// <summary>
/// Creates a new lap time packet.
/// </summary>
/// <param name="buffer">A buffer contaning the packet data.</param>
public IS_LAP(byte[] buffer)
: this() {
PacketReader reader = new PacketReader(buffer);
Size = reader.ReadByte();
Type = (PacketType)reader.ReadByte();
ReqI = reader.ReadByte();
PLID = reader.ReadByte();
LTime = TimeSpan.FromMilliseconds(reader.ReadUInt32()); ;
ETime = TimeSpan.FromMilliseconds(reader.ReadUInt32());
LapsDone = reader.ReadUInt16();
Flags = (PlayerFlags)reader.ReadUInt16();
reader.Skip(1);
Penalty = (PenaltyValue)reader.ReadByte();
NumStops = reader.ReadByte();
}
示例15: Read
/// <summary>
/// The read.
/// </summary>
/// <param name="client">
/// </param>
/// <param name="packet">
/// </param>
public static void Read(Client client, byte[] packet)
{
byte[] senderId = BitConverter.GetBytes(client.Character.CharacterId);
Array.Reverse(senderId);
ChannelBase channel = client.ChatServer().GetChannel(packet);
PacketReader reader = new PacketReader(ref packet);
reader.ReadUInt16();
reader.ReadUInt16();
reader.ReadUInt16();
reader.ReadUInt16();
reader.ReadByte();
string text = reader.ReadString();
string channelName = channel.ChannelName;
// Check if it is a Chat Command (starting with a dot)
if (!ProcessServerCommand(text, client))
{
byte[] newpacket = new byte[packet.Length + 4];
Array.Copy(packet, 0, newpacket, 0, 9);
Array.Copy(senderId, 0, newpacket, 9, 4);
Array.Copy(packet, 9, newpacket, 13, packet.Length - 9);
newpacket[2] = (byte)(packet.Length >> 8);
newpacket[3] = (byte)packet.Length;
foreach (Client recipient in client.ChatServer().ConnectedClients.Values)
{
if (recipient.Channels.Contains(channel))
{
if (!recipient.KnownClients.Contains(client.Character.CharacterId)
&& (recipient.Character.CharacterId != client.Character.CharacterId))
{
byte[] pname = PlayerName.Create(client, client.Character.CharacterId);
recipient.Send(pname);
recipient.KnownClients.Add(client.Character.CharacterId);
}
recipient.Send(newpacket);
}
}
client.ChannelMessageReceived(channel, client.Character.characterName, text);
}
ChatLogger.WriteString(channelName, text, client.Character.characterName);
}