本文整理汇总了C#中Packet.ReadByte方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.ReadByte方法的具体用法?C# Packet.ReadByte怎么用?C# Packet.ReadByte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.ReadByte方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandlePacket
public void HandlePacket(Packet p, NetworkPlayer player)
{
byte num = p.ReadByte();
switch (num)
{
case 0:
string name = p.ReadString();
player.PlayerName = name;
Packet255SCConnectionFirmed packet2 = new Packet255SCConnectionFirmed(player.PlayerID);
SendPacket(packet2, player.NetConnection);
foreach (NetworkPlayer pl in GameServer.NetworkPlayers)
{
var packet = new Packet0SCPlayerConnect(pl.PlayerName, pl.PlayerID, pl.EntityPosition);
SendPacket(packet, player.NetConnection);
if (pl == player) continue;
packet = new Packet0SCPlayerConnect(player.PlayerName,
player.PlayerID, player.EntityPosition);
SendPacket(packet, pl.NetConnection);
}
ServerConsole.Log("New player \"" + name + "\" connected.");
break;
//A game event, JC!
case 1:
byte eventID = p.ReadByte();
GameServer.HandleGameEvent(eventID, p, player);
break;
case 2:
int pX = p.ReadInt();
int pY = p.ReadInt();
GameServer.SetBlock(pX, pY, 0, true, 0);
break;
case 4:
byte flags = p.ReadByte();
if (player.MovementFlags != flags)
{
player.UpdateMask |= (int)PlayerUpdateFlags.Player_Update;
player.UpdateMask |= (int)PlayerUpdateFlags.Player_Movement_Flags;
}
player.MovementFlags = flags;
break;
case 5:
flags = p.ReadByte();
float angle = p.ReadShort().DToR();
if (player.MovementFlags != flags || angle != player.PlayerAimAngle)
{
player.UpdateMask |= (int)PlayerUpdateFlags.Player_Update;
player.UpdateMask |= (int)PlayerUpdateFlags.Player_Movement_Flags;
}
player.MovementFlags = flags;
player.PlayerAimAngle = angle;
break;
}
}
示例2: FromPacket
/// <summary>
/// Reads <see cref="RemoteServiceSettings"/> from provided <see cref="Packet"/> struct.
/// </summary>
/// <param name="p"><see cref="Packet"/> to read <see cref="RemoteServiceSettings"/> from.</param>
/// <param name="t">Remote <see cref="ServiceType"/>.</param>
/// <returns>><see cref="RemoteServiceSettings"/> readed from provided <see cref="Packet"/>.</returns>
public static RemoteServiceSettings FromPacket( Packet p, ServiceType t )
{
switch ( t )
{
case ServiceType.LoginService:
return new LoginServiceSettings(p.ReadByte(), p.InternalReadBool(), p.ReadByte());
default:
return null;
}
}
示例3: ChangeSlot
public static void ChangeSlot(Packet packet, Player player)
{
uint ItmID1 = packet.ReadUInt( );
uint ItmID2 = packet.ReadUInt( );
byte Slot = packet.ReadByte( );
byte Check = packet.ReadByte( );
byte Error = 1;
if (Check == 0x01)
{
#region Parse
if (ItmID2 != 0)
{
CharItem Itm1 = player.CharData.GeneralItems.FindID(ItmID1);
CharItem Itm2 = player.CharData.GeneralItems.FindID(ItmID2);
if (Itm1.Slot == -1 || Itm2.Slot == -1)
{
Error = 0;
}
else
{
Itm1.Slot += Itm2.Slot;
Itm2.Slot = Itm1.Slot - Itm2.Slot;
Itm1.Slot -= Itm2.Slot;
}
}
else
{
CharItem Itm1 = player.CharData.GeneralItems.FindID(ItmID1);
if (Itm1.Slot == -1)
{
Error = 0;
}
else
{
Itm1.Slot = Slot;
}
}
#endregion
#region Response
Packet Response = new Packet(0x0454);
Response.WriteUInt(ItmID1);
Response.WriteUInt(ItmID2);
Response.WriteByte(Slot);
Response.WriteByte(1);
Response.WriteByte(Error);
player.Sock.Send(Response);
#endregion
}
}
示例4: ParseMovement
public static List<LifeMovementFragment> ParseMovement(Packet pPacket, int pKind)
{
List<LifeMovementFragment> Res = new List<LifeMovementFragment>();
byte CommandCount = pPacket.ReadByte();
for (byte i = 0; i < CommandCount; i++)
{
byte Command = pPacket.ReadByte();
switch (Command)
{
case 0:
case 7:
case 14:
case 16:
case 44:
case 45:
case 46:
{
short X = pPacket.ReadShort();
short Y = pPacket.ReadShort();
short XWobble = pPacket.ReadShort();
short YWobble = pPacket.ReadShort();
short Unknown = pPacket.ReadShort();
short Foothold = 0, XOffset = 0, YOffset = 0;
if (Command == 14)
Foothold = pPacket.ReadShort();
if (Command != 44)
{
XOffset = pPacket.ReadShort();
YOffset = pPacket.ReadShort();
}
byte NewState = pPacket.ReadByte();
short Duration = pPacket.ReadShort();
AbsoluteLifeMovement ALM = new AbsoluteLifeMovement(Command, new Pos(X, Y), Duration, NewState);
//ALM.Unknown = Unknown;
//ALM.Foothold = Foothold;
//ALM.PixelsPerSecond = new Pos(XWobble, YWobble);
//ALM.Offset = new Pos(XOffset, YOffset);
Res.Add(ALM);
break;
}
}
}
return Res;
}
示例5: HandleChannelList
public static void HandleChannelList(Packet packet)
{
packet.ReadByte("Channel Type");
packet.ReadCString("Channel Name");
packet.ReadByte("Channel Flags");
var listSize = packet.ReadInt32("List Size");
for (int i = 0; i < listSize; i++)
{
packet.ReadGuid("Player GUID");
packet.ReadByte("Player Flags");
}
}
示例6: ReqRoleLogin
public ReqRoleLogin(Packet packet)
{
this._uid = packet.ReadUint();
this._uuid = packet.ReadUint();
this._sid = packet.ReadUshort();
this._cid = packet.ReadUshort();
this._login_time = packet.ReadUint();
this._pwd = packet.ReadString();
this._relink = packet.ReadByte();
this._debug = packet.ReadByte();
this._os = packet.ReadString();
this._version = packet.ReadString();
}
示例7: MsgTestXX
public MsgTestXX(Packet packet)
{
this._id_u8 = packet.ReadByte();
this._id_f32 = new List<float>();
ushort id_f32_count = packet.ReadUshort();
for (ushort i = 0; i < id_f32_count; i++)
{
this._id_f32.Add(packet.ReadFloat());
}
this. id_op_u8_flag = packet.ReadByte();
if (this.id_op_u8_flag == 1)
{
this._id_op_u8 = packet.ReadByte();
}
}
示例8: HandleCheckUserLimit
public static void HandleCheckUserLimit(Client pClient, Packet pPacket)
{
if (pClient.Account.LoggedIn != 1) return;
byte WorldId = pPacket.ReadByte();
if (Master.Instance.Worlds[WorldId] == null)
{
pClient.Session.Disconnect();
return;
}
int CurrentLoad = Master.Instance.Worlds[WorldId].CurrentLoad;
if (CurrentLoad >= 100)
{ // TODO: Max players.
pClient.SendPacket(LoginPacket.UserLimitResult(2));
}
else if (CurrentLoad * 2 >= 100)
{
pClient.SendPacket(LoginPacket.UserLimitResult(1));
}
else
{
pClient.SendPacket(LoginPacket.UserLimitResult(0));
}
}
示例9: 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 );
}
}
示例10: HandlePlayerChat
public static void HandlePlayerChat(Client pClient, Packet pPacket)
{
int Tick = pPacket.ReadInt();
string Message = pPacket.ReadMapleString();
byte Unknown = pPacket.ReadByte();
if (Message.Length >= 80)
return;
if (Message.StartsWith("!"))
{
string[] Sub = Message.Split(' ');
switch (Sub[0].ToLower())
{
case "!map":
int Id = int.Parse(Sub[1]);
pClient.Character.ChangeMap(Id);
break;
}
}
else
{
pClient.Character.CurrentMap.SendPacket(MapPacket.PlayerChat(pClient.Character.Id, Message, false, 1));
}
}
示例11: AckChatSendOk
public AckChatSendOk(Packet packet)
{
this._channel = packet.ReadByte();
this._uid = packet.ReadUint();
this._uname = packet.ReadString();
this._content = packet.ReadString();
}
示例12: Expressing
public static void Expressing(Packet packet, Player player)
{
byte Type = packet.ReadByte( );
#region Response
Packet Response = new Packet(0x0230);
Response.WriteUInt(1); // Char ID ( if the char is the same it will be 1)
Response.WriteByte(Type);
player.Sock.Send(Response);
#endregion
#region Others
Packet Others = new Packet(0x0230);
Others.WriteUInt(player.ID);
Others.WriteByte(Type);
int MapIndex = Maps.MapsData.Find(player.CharData.Map);
if (MapIndex != -1)
{
foreach (Player x in Maps.MapsData[MapIndex].Players)
{
if (x.ID != player.ID)
x.Sock.Send(Others);
}
}
#endregion
}
示例13: 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();
}
示例14: HandleGameObjectQueryResponse
public static void HandleGameObjectQueryResponse(Packet packet)
{
var entry = packet.ReadEntry();
Console.WriteLine("Entry: " + entry.Key);
if (entry.Value)
return;
var unkInt = packet.ReadInt32();
Console.WriteLine("unkInt: " + unkInt);
var type = (GameObjectType)packet.ReadInt32();
Console.WriteLine("Type: " + type);
var dispId = packet.ReadInt32();
Console.WriteLine("Display ID: " + dispId);
var name = new string[4];
for (var i = 0; i < 4; i++)
{
name[i] = packet.ReadCString();
Console.WriteLine("Name " + i + ": " + name[i]);
}
var iconName = packet.ReadCString();
Console.WriteLine("Icon Name: " + iconName);
var castCaption = packet.ReadCString();
Console.WriteLine("Cast Caption: " + castCaption);
var unkStr = packet.ReadCString();
Console.WriteLine("Unk String: " + unkStr);
var data = new int[32];
for (var i = 0; i < 32; i++)
{
data[i] = packet.ReadInt32();
Console.WriteLine("Data " + i + ": " + data[i]);
}
var size = packet.ReadSingle();
Console.WriteLine("Size: " + size);
var qItemCount = packet.ReadByte();
Console.WriteLine("Quest Item Count: " + qItemCount);
var qItem = new int[qItemCount];
for (var i = 0; i < qItemCount; i++)
{
qItem[i] = packet.ReadInt32();
Console.WriteLine("Quest Item " + i + ": " + qItem[i]);
}
var expansion = packet.ReadInt32();
Console.WriteLine("Expansion: " + expansion);
SQLOutput.SQLOutput.WriteData(SQLOutput.SQLOutput.GameObjects.GetCommand(entry.Key, type, dispId, name[0], iconName,
castCaption, unkStr, data, size, qItem));
}
示例15: AckTestXX
public AckTestXX(Packet packet)
{
this._id_u8 = packet.ReadByte();
this._id_u16 = packet.ReadUshort();
this._id_u32 = packet.ReadUint();
this._repeat_id_u8 = new List<byte>();
ushort repeat_id_u8_count = packet.ReadUshort();
for (ushort i = 0; i < repeat_id_u8_count; i++)
{
this._repeat_id_u8.Add(packet.ReadByte());
}
this. optional_id_u8_flag = packet.ReadByte();
if (this.optional_id_u8_flag == 1)
{
this._optional_id_u8 = packet.ReadByte();
}
}