本文整理汇总了C#中BitUnpack类的典型用法代码示例。如果您正苦于以下问题:C# BitUnpack类的具体用法?C# BitUnpack怎么用?C# BitUnpack使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BitUnpack类属于命名空间,在下文中一共展示了BitUnpack类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleLearnTalents
//[Opcode(ClientMessage.LearnTalents, "16357")]
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>(25);
for (int i = 0; i < talentCount; i++)
{
var talentId = packet.ReadUInt16();
SpecializationMgr.AddTalent(pChar, pChar.ActiveSpecGroup, talentId, true);
talentSpells.Add(DBCStorage.TalentStorage.LookupByKey(talentId).SpellId);
}
HandleTalentUpdate(ref session);
pChar.SetUpdateField<Int32>((int)PlayerFields.SpellCritPercentage + 0, SpecializationMgr.GetUnspentTalentRowCount(pChar), 0);
ObjectHandler.HandleUpdateObjectValues(ref session);
// we need to send a single packet for every talent spell - stupid blizz
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);
}
示例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: HandleCreateCharacter
public static void HandleCreateCharacter(ref PacketReader packet, WorldClass session)
{
BitUnpack BitUnpack = new BitUnpack(packet);
packet.Skip(1);
var facialHair = packet.ReadByte();
var skin = packet.ReadByte();
var race = packet.ReadByte();
var hairStyle = packet.ReadByte();
var pClass = packet.ReadByte();
var face = packet.ReadByte();
var gender = packet.ReadByte();
var hairColor = packet.ReadByte();
var nameLength = BitUnpack.GetBits<uint>(6);
var hasUnknown = BitUnpack.GetBit();
var name = Character.NormalizeName(packet.ReadString(nameLength));
if (hasUnknown)
packet.ReadUInt32();
var result = DB.Characters.Select("SELECT * from characters WHERE name = ?", name);
var createChar = new PacketWriter(ServerMessage.CreateChar);
if (result.Count != 0)
{
// Name already in use
createChar.WriteUInt8(0x32);
session.Send(ref createChar);
return;
}
result = DB.Characters.Select("SELECT map, zone, posX, posY, posZ, posO FROM character_creation_data WHERE race = ? AND class = ?", race, pClass);
if (result.Count == 0)
{
createChar.WriteUInt8(0x31);
session.Send(ref createChar);
return;
}
var map = result.Read<uint>(0, "map");
var zone = result.Read<uint>(0, "zone");
var posX = result.Read<float>(0, "posX");
var posY = result.Read<float>(0, "posY");
var posZ = result.Read<float>(0, "posZ");
var posO = result.Read<float>(0, "posO");
// Allow declined names for now
var characterFlags = CharacterFlag.Decline;
DB.Characters.Execute("INSERT INTO characters (name, accountid, realmId, race, class, gender, skin, zone, map, x, y, z, o, face, hairstyle, haircolor, facialhair, characterFlags) VALUES (" +
"?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
name, session.Account.Id, WorldConfig.RealmId, race, pClass, gender, skin, zone, map, posX, posY, posZ, posO, face, hairStyle, hairColor, facialHair, characterFlags);
// Success
createChar.WriteUInt8(0x2F);
session.Send(ref createChar);
}
示例4: HandleChatMessageYell
public static void HandleChatMessageYell(ref PacketReader packet, ref WorldClass session)
{
BitUnpack BitUnpack = new BitUnpack(packet);
int language = packet.ReadInt32();
uint messageLength = BitUnpack.GetBits<uint>(9);
string chatMessage = packet.ReadString(messageLength);
SendMessageByType(ref session, MessageType.ChatMessageYell, language, chatMessage);
}
示例5: 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");
}
示例6: HandleObjectUpdateFailed
public static void HandleObjectUpdateFailed(ref PacketReader packet, ref WorldClass session)
{
byte[] guidMask = { 6, 1, 7, 5, 0, 4, 2, 3 };
byte[] guidBytes = { 2, 3, 7, 4, 5, 1, 0, 6 };
BitUnpack GuidUnpacker = new BitUnpack(packet);
ulong guid = GuidUnpacker.GetGuid(guidMask, guidBytes);
Log.Message(LogType.DEBUG, "ObjectUpdate failed for object with Guid {0}", guid);
}
示例7: HandleObjectUpdateFailed
public static void HandleObjectUpdateFailed(ref PacketReader packet, WorldClass session)
{
byte[] guidMask = { 7, 0, 2, 3, 1, 4, 6, 5 };
byte[] guidBytes = { 1, 2, 5, 0, 3, 4, 6, 7 };
BitUnpack GuidUnpacker = new BitUnpack(packet);
ulong guid = GuidUnpacker.GetPackedValue(guidMask, guidBytes);
Log.Message(LogType.Debug, "ObjectUpdate failed for object with Guid {0}", guid);
}
示例8: HandleTalkToGossip
public static void HandleTalkToGossip(ref PacketReader packet, ref WorldClass session)
{
BitUnpack BitUnpack = new BitUnpack(packet);
byte[] guidMask = { 3, 1, 7, 4, 6, 0, 2, 5 };
byte[] guidBytes = { 0, 1, 7, 6, 5, 2, 4, 3 };
var guid = BitUnpack.GetPackedValue(guidMask, guidBytes);
var gossipData = GossipMgr.GetGossip<Creature>(SmartGuid.GetGuid(guid));
if (gossipData != null)
{
PacketWriter gossipMessage = new PacketWriter(ServerMessage.GossipMessage);
BitPack BitPack = new BitPack(gossipMessage, guid);
BitPack.WriteGuidMask(0, 1);
BitPack.Write(0, 19); // gossipData.QuestsCount
BitPack.WriteGuidMask(2);
BitPack.Write(0, 20); // gossipData.OptionsCount
// QuestsCount not supported.
// for (int i = 0; i < gossipData.QuestsCount; i++)
BitPack.WriteGuidMask(3);
// OptionsCount not supported.
// for (int i = 0; i < gossipData.OptionsCount; i++)
BitPack.WriteGuidMask(5, 4, 6, 7);
BitPack.Flush();
BitPack.WriteGuidBytes(6);
// OptionsCount not supported.
// for (int i = 0; i < gossipData.OptionsCount; i++)
BitPack.WriteGuidBytes(0);
// QuestsCount not supported.
// for (int i = 0; i < gossipData.QuestsCount; i++)
gossipMessage.WriteInt32(gossipData.Id);
BitPack.WriteGuidBytes(4, 3);
gossipMessage.WriteInt32(gossipData.FriendshipFactionID);
gossipMessage.WriteInt32(gossipData.TextID);
BitPack.WriteGuidBytes(7, 1, 5, 1);
session.Send(ref gossipMessage);
}
}
示例9: HandleChatMessageSay
public static void HandleChatMessageSay(ref PacketReader packet, ref WorldClass session)
{
BitUnpack BitUnpack = new BitUnpack(packet);
int language = packet.ReadInt32();
uint messageLength = BitUnpack.GetBits<uint>(9);
string chatMessage = packet.ReadString(messageLength);
if (ChatCommandParser.CheckForCommand(chatMessage))
ChatCommandParser.ExecuteChatHandler(chatMessage, ref session);
else
SendMessageByType(ref session, MessageType.ChatMessageSay, language, chatMessage);
}
示例10: 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);
}
示例11: HandleChatMessageWhisper
public static void HandleChatMessageWhisper(ref PacketReader packet, ref WorldClass session)
{
BitUnpack BitUnpack = new BitUnpack(packet);
int language = packet.ReadInt32();
uint messageLength = BitUnpack.GetBits<uint>(9);
uint nameLength = BitUnpack.GetNameLength<uint>(9);
string chatMessage = packet.ReadString(messageLength);
string receiverName = packet.ReadString(nameLength);
WorldClass rSession = WorldMgr.GetSession(receiverName);
SendMessageByType(ref rSession, MessageType.ChatMessageWhisper, language, chatMessage);
SendMessageByType(ref session, MessageType.ChatMessageWhisperInform, language, chatMessage);
}
示例12: 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);
}
示例13: HandleCharDelete
public static void HandleCharDelete(ref PacketReader packet, WorldClass session)
{
byte[] guidMask = { 7, 0, 4, 1, 6, 5, 3, 2 };
byte[] guidBytes = { 6, 7, 5, 0, 4, 2, 3, 1 };
var GuidUnpacker = new BitUnpack(packet);
var guid = GuidUnpacker.GetPackedValue(guidMask, guidBytes);
PacketWriter deleteChar = new PacketWriter(ServerMessage.DeleteChar);
deleteChar.WriteUInt8(0x48);
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);
}
示例14: 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);
}
示例15: HandleCliQueryNPCText
public static void HandleCliQueryNPCText(ref PacketReader packet, WorldClass session)
{
BitUnpack BitUnpack = new BitUnpack(packet);
byte[] guidMask = { 5, 1, 4, 3, 2, 0, 7, 6 };
byte[] guidBytes = { 3, 1, 4, 6, 2, 0, 5, 7 };
var gossipTextId = packet.Read<int>();
var guid = BitUnpack.GetPackedValue(guidMask, guidBytes);
var gossipData = GossipMgr.GetGossip<Creature>(SmartGuid.GetGuid(guid));
if (gossipData != null)
{
PacketWriter queryNPCTextResponse = new PacketWriter(ServerMessage.QueryNPCTextResponse);
BitPack BitPack = new BitPack(queryNPCTextResponse);
queryNPCTextResponse.WriteInt32(0);
queryNPCTextResponse.WriteFloat(1);
for (int i = 0; i < 7; i++)
queryNPCTextResponse.WriteUInt32(0);
queryNPCTextResponse.WriteInt32(gossipData.BroadCastText.Id);
for (int i = 0; i < 7; i++)
queryNPCTextResponse.WriteUInt32(0);
var size = (uint)queryNPCTextResponse.BaseStream.Length - 8;
queryNPCTextResponse.WriteUInt32Pos(size, 4);
queryNPCTextResponse.WriteInt8(0);
queryNPCTextResponse.WriteInt32(gossipTextId);
BitPack.Write(1);
BitPack.Flush();
session.Send(ref queryNPCTextResponse);
}
}