本文整理汇总了C#中Framework.Network.Packets.PacketReader.Read方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.Read方法的具体用法?C# PacketReader.Read怎么用?C# PacketReader.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Framework.Network.Packets.PacketReader
的用法示例。
在下文中一共展示了PacketReader.Read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadAddonData
public static void ReadAddonData(byte[] buffer, int size, WorldClass session)
{
// Clean possible addon data
session.Addons.Clear();
string addonName;
byte addonEnabled;
uint addonCRC, UrlStringCRC;
// Decompress received Addon Data
PacketReader addonData = new PacketReader(ZLib.ZLibDecompress(buffer, true, size), false);
// Get Addon number
int ctr, numAddons = addonData.Read<int>();
// For each addon, read data from decoded packet and store into session for later use if needed
for (ctr = 0; ctr < numAddons; ctr++)
{
addonName = addonData.ReadCString();
addonEnabled = addonData.Read<byte>();
addonCRC = addonData.Read<uint>();
UrlStringCRC = addonData.Read<uint>();
// Get the addon with same properties
var Addon = AddonMgr.GetAddon(addonName, addonEnabled, addonCRC, UrlStringCRC);
// Add if found, add default one if not.
if (Addon != null)
session.Addons.Add(Addon);
else
// Note: This can be skipped for those with no addon data.
// TODO: Test that!
session.Addons.Add(new Framework.ObjectDefines.Addon()
{
AuthType = 2,
Enabled = addonEnabled,
CRC = addonCRC,
HasPUBData = 0,
PUBData = null,
Version = 1, // Fixed value
HasUrlString = 0,
UrlString = addonName,
UrlStringCRC = UrlStringCRC
});
}
int addonEnd = addonData.Read<int>(); // Unknown
}
示例2: HandleLearnTalents
public static void HandleLearnTalents(ref PacketReader packet, ref WorldClass session)
{
var pChar = session.Character;
var talentSpells = new List<uint>();
BitUnpack BitUnpack = new BitUnpack(packet);
uint talentCount = BitUnpack.GetBits<uint>(23);
for (int i = 0; i < talentCount; i++)
{
var talentId = packet.Read<ushort>();
SpecializationMgr.AddTalent(pChar, pChar.ActiveSpecGroup, talentId, true);
talentSpells.Add(CliDB.Talent.Single(talent => talent.Id == talentId).SpellId);
}
HandleUpdateTalentData(ref session);
pChar.SetUpdateField<Int32>((int)PlayerFields.SpellCritPercentage + 0, SpecializationMgr.GetUnspentTalentRowCount(pChar), 0);
ObjectHandler.HandleUpdateObjectValues(ref session);
foreach (var talentSpell in talentSpells)
SpellHandler.HandleLearnedSpells(ref session, new List<uint>(1) { talentSpell });
Log.Message(LogType.Debug, "Character (Guid: {0}) learned {1} talents.", pChar.Guid, talentCount);
}
示例3: HandleCliSetSpecialization
public static void HandleCliSetSpecialization(ref PacketReader packet, ref WorldClass session)
{
var pChar = session.Character;
uint specGroupId = packet.Read<uint>();
uint specId = SpecializationMgr.GetSpecIdByGroup(pChar, (byte)specGroupId);
// check if new spec is primary or secondary
if (pChar.SpecGroupCount == 1 && pChar.PrimarySpec == 0)
{
pChar.ActiveSpecGroup = 0;
pChar.PrimarySpec = (ushort)specId;
}
else
{
pChar.ActiveSpecGroup = 1;
pChar.SecondarySpec = (ushort)specId;
pChar.SpecGroupCount = (byte)(pChar.SpecGroupCount + 1);
}
SpecializationMgr.SaveSpecInfo(pChar);
SendSpecializationSpells(ref session);
HandleUpdateTalentData(ref session);
pChar.SetUpdateField<Int32>((int)PlayerFields.CurrentSpecID, (int)pChar.GetActiveSpecId());
ObjectHandler.HandleUpdateObjectValues(ref session);
Log.Message(LogType.Debug, "Character (Guid: {0}) choosed specialization {1} for spec group {2}.", pChar.Guid, pChar.GetActiveSpecId(), pChar.ActiveSpecGroup);
}
示例4: HandleLoadingScreenNotify
public static void HandleLoadingScreenNotify(ref PacketReader packet, WorldClass session)
{
BitUnpack BitUnpack = new BitUnpack(packet);
uint mapId = packet.Read<uint>();
bool loadingScreenState = BitUnpack.GetBit();
Log.Message(LogType.Debug, "Loading screen for map '{0}' is {1}.", mapId, loadingScreenState ? "enabled" : "disabled");
}
示例5: HandleDisconnectReason
public static void HandleDisconnectReason(ref PacketReader packet, WorldClass session)
{
var pChar = session.Character;
uint disconnectReason = packet.Read<uint>();
if (pChar != null)
WorldMgr.DeleteSession(pChar.Guid);
DB.Realms.Execute("UPDATE accounts SET online = 0 WHERE id = ?", session.Account.Id);
Log.Message(LogType.Debug, "Account with Id {0} disconnected. Reason: {1}", session.Account.Id, disconnectReason);
}
示例6: HandleChatMessageYell
public static void HandleChatMessageYell(ref PacketReader packet, WorldClass session)
{
BitUnpack BitUnpack = new BitUnpack(packet);
var language = packet.Read<int>();
var messageLength = packet.ReadByte();
var message = packet.ReadString(messageLength);
ChatMessageValues chatMessage = new ChatMessageValues(MessageType.ChatMessageYell, message, true, true);
chatMessage.Language = (byte)language;
SendMessage(ref session, chatMessage);
}
示例7: HandleChatMessageSay
public static void HandleChatMessageSay(ref PacketReader packet, WorldClass session)
{
BitUnpack BitUnpack = new BitUnpack(packet);
var language = packet.Read<int>();
var messageLength = BitUnpack.GetBits<byte>(8);
var message = packet.ReadString(messageLength);
ChatMessageValues chatMessage = new ChatMessageValues(MessageType.ChatMessageSay, message, true, true);
chatMessage.Language = (byte)language;
if (ChatCommandParser.CheckForCommand(message))
ChatCommandParser.ExecuteChatHandler(message, session);
else
SendMessage(ref session, chatMessage);
}
示例8: HandleCharDelete
public static void HandleCharDelete(ref PacketReader packet, ref WorldClass session)
{
bool[] guidMask = new bool[8];
byte[] guidBytes = new byte[8];
BitUnpack BitUnpack = new BitUnpack(packet);
guidMask[2] = BitUnpack.GetBit();
guidMask[1] = BitUnpack.GetBit();
guidMask[5] = BitUnpack.GetBit();
guidMask[7] = BitUnpack.GetBit();
guidMask[6] = BitUnpack.GetBit();
var unknown = BitUnpack.GetBit();
guidMask[3] = BitUnpack.GetBit();
guidMask[0] = BitUnpack.GetBit();
guidMask[4] = BitUnpack.GetBit();
if (guidMask[1]) guidBytes[1] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[3]) guidBytes[3] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[4]) guidBytes[4] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[0]) guidBytes[0] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[7]) guidBytes[7] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[2]) guidBytes[2] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[5]) guidBytes[5] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[6]) guidBytes[6] = (byte)(packet.Read<byte>() ^ 1);
var guid = BitConverter.ToUInt64(guidBytes, 0);
PacketWriter deleteChar = new PacketWriter(ServerMessage.DeleteChar);
deleteChar.WriteUInt8(0x47);
session.Send(ref deleteChar);
DB.Characters.Execute("DELETE FROM characters WHERE guid = ?", guid);
DB.Characters.Execute("DELETE FROM character_spells WHERE guid = ?", guid);
DB.Characters.Execute("DELETE FROM character_skills WHERE guid = ?", guid);
}
示例9: HandleRealmSplit
public static void HandleRealmSplit(ref PacketReader packet, ref WorldClass session)
{
uint realmSplitState = 0;
var date = "01/01/01";
PacketWriter realmSplit = new PacketWriter(ServerMessage.RealmSplit);
BitPack BitPack = new BitPack(realmSplit);
BitPack.Write(date.Length, 7);
realmSplit.WriteString(date);
realmSplit.WriteUInt32(packet.Read<uint>());
realmSplit.WriteUInt32(realmSplitState);
session.Send(ref realmSplit);
// Crash!!!
// Wrong data sent...
// AddonMgr.WriteAddonData(ref session);
}
示例10: HandleRealmSplit
public static void HandleRealmSplit(ref PacketReader packet, WorldClass session)
{
uint realmSplitState = 0;
var date = "01/01/01";
PacketWriter realmSplit = new PacketWriter(ServerMessage.RealmSplit);
BitPack BitPack = new BitPack(realmSplit);
realmSplit.WriteUInt32(packet.Read<uint>());
realmSplit.WriteUInt32(realmSplitState);
BitPack.Write(date.Length, 7);
BitPack.Flush();
realmSplit.WriteString(date);
session.Send(ref realmSplit);
AddonHandler.WriteAddonData(session);
}
示例11: HandleChatMessageWhisper
public static void HandleChatMessageWhisper(ref PacketReader packet, WorldClass session)
{
BitUnpack BitUnpack = new BitUnpack(packet);
var language = packet.Read<int>();
var nameLength = BitUnpack.GetBits<byte>(9);
var messageLength = BitUnpack.GetBits<byte>(8);
string receiverName = packet.ReadString(nameLength);
string message = packet.ReadString(messageLength);
WorldClass rSession = WorldMgr.GetSession(receiverName);
if (rSession == null)
return;
ChatMessageValues chatMessage = new ChatMessageValues(MessageType.ChatMessageWhisperInform, message, false, true);
SendMessage(ref session, chatMessage, rSession);
chatMessage = new ChatMessageValues(MessageType.ChatMessageWhisper, message, false, true);
SendMessage(ref rSession, chatMessage, session);
}
示例12: HandleQueryCreature
public static void HandleQueryCreature(ref PacketReader packet, ref WorldClass session)
{
var hasData = false;
var id = packet.Read<int>();
PacketWriter queryCreatureResponse = new PacketWriter(ServerMessage.QueryCreatureResponse);
BitPack BitPack = new BitPack(queryCreatureResponse);
queryCreatureResponse.WriteInt32(id);
Creature creature = DataMgr.FindCreature(id);
if (hasData = (creature != null))
{
CreatureStats stats = creature.Stats;
BitPack.Write(hasData);
BitPack.Write(stats.QuestItemId.Count, 22);
BitPack.Write(0, 11);
BitPack.Write(stats.RacialLeader);
BitPack.Write(stats.IconName.Length + 1, 6);
for (int i = 0; i < 8; i++)
{
if (i == 1)
BitPack.Write(stats.Name.Length + 1, 11);
else
BitPack.Write(0, 11);
}
BitPack.Write(stats.SubName.Length != 0 ? stats.SubName.Length + 1 : 0, 11);
BitPack.Flush();
queryCreatureResponse.WriteInt32(stats.Rank);
queryCreatureResponse.WriteInt32(stats.DisplayInfoId[2]);
queryCreatureResponse.WriteInt32(stats.Type);
foreach (var v in stats.Flag)
queryCreatureResponse.WriteInt32(v);
queryCreatureResponse.WriteFloat(stats.PowerModifier);
queryCreatureResponse.WriteInt32(stats.DisplayInfoId[0]);
queryCreatureResponse.WriteFloat(1);
queryCreatureResponse.WriteCString(stats.Name);
if (stats.IconName != "")
queryCreatureResponse.WriteCString(stats.IconName);
queryCreatureResponse.WriteInt32(stats.Family);
queryCreatureResponse.WriteInt32(stats.QuestKillNpcId[0]);
if (stats.SubName != "")
queryCreatureResponse.WriteCString(stats.SubName);
queryCreatureResponse.WriteInt32(stats.MovementInfoId);
queryCreatureResponse.WriteInt32(stats.DisplayInfoId[1]);
queryCreatureResponse.WriteFloat(1);
queryCreatureResponse.WriteFloat(stats.HealthModifier);
queryCreatureResponse.WriteInt32(0);
foreach (var v in stats.QuestItemId)
queryCreatureResponse.WriteInt32(v);
queryCreatureResponse.WriteInt32(stats.DisplayInfoId[3]);
queryCreatureResponse.WriteInt32(stats.QuestKillNpcId[1]);
queryCreatureResponse.WriteInt32(stats.ExpansionRequired);
session.Send(ref queryCreatureResponse);
}
else
{
BitPack.Write(hasData);
Log.Message(LogType.DEBUG, "Creature (Id: {0}) not found.", id);
}
}
示例13: HandleDBQueryBulk
public static void HandleDBQueryBulk(ref PacketReader packet, ref WorldClass session)
{
List<int> IdList = new List<int>();
BitUnpack BitUnpack = new BitUnpack(packet);
var type = (DBTypes)packet.Read<uint>();
var count = BitUnpack.GetBits<uint>(21);
bool[][] Mask = new bool[count][];
byte[][] Bytes = new byte[count][];
for (int i = 0; i < count; i++)
{
Mask[i] = new bool[8];
Bytes[i] = new byte[8];
}
for (int i = 0; i < count; i++)
{
Mask[i][7] = BitUnpack.GetBit();
Mask[i][2] = BitUnpack.GetBit();
Mask[i][3] = BitUnpack.GetBit();
Mask[i][5] = BitUnpack.GetBit();
Mask[i][4] = BitUnpack.GetBit();
Mask[i][6] = BitUnpack.GetBit();
Mask[i][0] = BitUnpack.GetBit();
Mask[i][1] = BitUnpack.GetBit();
}
for (int i = 0; i < count; i++)
{
if (Mask[i][5])
Bytes[i][5] = (byte)(packet.Read<byte>() ^ 1);
IdList.Add(packet.Read<int>());
if (Mask[i][7])
Bytes[i][7] = (byte)(packet.ReadByte() ^ 1);
if (Mask[i][3])
Bytes[i][3] = (byte)(packet.ReadByte() ^ 1);
if (Mask[i][0])
Bytes[i][0] = (byte)(packet.ReadByte() ^ 1);
if (Mask[i][1])
Bytes[i][1] = (byte)(packet.ReadByte() ^ 1);
if (Mask[i][6])
Bytes[i][6] = (byte)(packet.ReadByte() ^ 1);
if (Mask[i][2])
Bytes[i][2] = (byte)(packet.ReadByte() ^ 1);
if (Mask[i][4])
Bytes[i][4] = (byte)(packet.ReadByte() ^ 1);
}
switch (type)
{
case DBTypes.BroadcastText:
{
foreach (var id in IdList)
HandleBroadcastText(ref session, id);
break;
}
default:
break;
}
}
示例14: HandleMoveSetFly
public static void HandleMoveSetFly(ref PacketReader packet, WorldClass session)
{
ObjectMovementValues movementValues = new ObjectMovementValues();
BitUnpack BitUnpack = new BitUnpack(packet);
var guidMask = new bool[8];
var guidBytes = new byte[8];
Vector4 vector = new Vector4()
{
Y = packet.Read<float>(),
X = packet.Read<float>(),
Z = packet.Read<float>(),
};
movementValues.IsFallingOrJumping = BitUnpack.GetBit();
guidMask[0] = BitUnpack.GetBit();
movementValues.HasMovementFlags2 = !BitUnpack.GetBit();
guidMask[6] = BitUnpack.GetBit();
movementValues.HasMovementFlags = !BitUnpack.GetBit();
var Unknown = BitUnpack.GetBit();
guidMask[2] = BitUnpack.GetBit();
movementValues.HasRotation = !BitUnpack.GetBit();
var Unknown2 = !BitUnpack.GetBit();
var HasSplineElevation = !BitUnpack.GetBit();
movementValues.IsTransport = BitUnpack.GetBit();
guidMask[1] = BitUnpack.GetBit();
guidMask[5] = BitUnpack.GetBit();
var HasPitch = !BitUnpack.GetBit();
var Unknown4 = BitUnpack.GetBit();
guidMask[4] = BitUnpack.GetBit();
var HasTime = !BitUnpack.GetBit();
var counter = BitUnpack.GetBits<uint>(22);
var Unknown3 = BitUnpack.GetBit();
guidMask[7] = BitUnpack.GetBit();
guidMask[3] = BitUnpack.GetBit();
if (movementValues.IsFallingOrJumping)
movementValues.HasJumpData = BitUnpack.GetBit();
if (movementValues.HasMovementFlags)
movementValues.MovementFlags = (MovementFlag)BitUnpack.GetBits<uint>(30);
if (movementValues.HasMovementFlags2)
movementValues.MovementFlags2 = (MovementFlag2)BitUnpack.GetBits<uint>(13);
for (int i = 0; i < counter; i++)
packet.Read<uint>();
if (guidMask[4])
guidBytes[4] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[2])
guidBytes[2] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[6])
guidBytes[6] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[3])
guidBytes[3] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[0])
guidBytes[0] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[7])
guidBytes[7] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[1])
guidBytes[1] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[5])
guidBytes[5] = (byte)(packet.Read<byte>() ^ 1);
if (Unknown2)
packet.Read<uint>();
if (movementValues.IsFallingOrJumping)
{
if (movementValues.HasJumpData)
{
//.........这里部分代码省略.........
示例15: HandleQueryPlayerName
public static void HandleQueryPlayerName(ref PacketReader packet, WorldClass session)
{
BitUnpack BitUnpack = new BitUnpack(packet);
var guidMask = new bool[8];
var guidBytes = new byte[8];
guidMask[1] = BitUnpack.GetBit();
guidMask[3] = BitUnpack.GetBit();
guidMask[6] = BitUnpack.GetBit();
guidMask[7] = BitUnpack.GetBit();
guidMask[2] = BitUnpack.GetBit();
guidMask[5] = BitUnpack.GetBit();
var hasUnknown = BitUnpack.GetBit();
guidMask[0] = BitUnpack.GetBit();
var hasUnknown2 = BitUnpack.GetBit();
guidMask[4] = BitUnpack.GetBit();
if (guidMask[4]) guidBytes[4] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[6]) guidBytes[6] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[7]) guidBytes[7] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[1]) guidBytes[1] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[2]) guidBytes[2] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[5]) guidBytes[5] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[0]) guidBytes[0] = (byte)(packet.Read<byte>() ^ 1);
if (guidMask[3]) guidBytes[3] = (byte)(packet.Read<byte>() ^ 1);
if (hasUnknown)
packet.Read<uint>();
if (hasUnknown2)
packet.Read<uint>();
var guid = BitConverter.ToUInt64(guidBytes, 0);
var pSession = WorldMgr.GetSession(guid);
if (pSession != null)
{
var pChar = pSession.Character;
if (pChar != null)
{
PacketWriter queryPlayerNameResponse = new PacketWriter(ServerMessage.QueryPlayerNameResponse);
BitPack BitPack = new BitPack(queryPlayerNameResponse, guid);
BitPack.WriteGuidMask(3, 2, 6, 0, 4, 1, 5, 7);
BitPack.Flush();
BitPack.WriteGuidBytes(7, 1, 2, 6, 3, 5);
queryPlayerNameResponse.WriteUInt8(0);
queryPlayerNameResponse.WriteUInt8(pChar.Gender);
queryPlayerNameResponse.WriteUInt8(pChar.Class);
queryPlayerNameResponse.WriteUInt8(pChar.Level);
queryPlayerNameResponse.WriteUInt32(1);
queryPlayerNameResponse.WriteUInt8(pChar.Race);
queryPlayerNameResponse.WriteUInt32(0);
BitPack.WriteGuidBytes(4, 0);
BitPack.WriteGuidMask(5);
BitPack.Write(0);
BitPack.Write(0);
BitPack.Write(0);
BitPack.WriteGuidMask(3, 7, 0, 6);
BitPack.Write(0);
BitPack.Write(0);
BitPack.WriteGuidMask(1);
BitPack.Write(0);
for (int i = 0; i < 5; i++)
BitPack.Write(0, 7);
BitPack.WriteGuidMask(2);
BitPack.Write(0);
BitPack.WriteGuidMask(4);
BitPack.Write(0);
BitPack.Write(pChar.Name.Length, 6);
BitPack.Write(0);
BitPack.Flush();
BitPack.WriteGuidBytes(0, 7, 5, 2);
queryPlayerNameResponse.WriteString(pChar.Name);
BitPack.WriteGuidBytes(4, 1, 3, 6);
session.Send(ref queryPlayerNameResponse);
}
}
}