本文整理汇总了C#中Framework.Network.Packets.PacketWriter.WriteInt32方法的典型用法代码示例。如果您正苦于以下问题:C# PacketWriter.WriteInt32方法的具体用法?C# PacketWriter.WriteInt32怎么用?C# PacketWriter.WriteInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Framework.Network.Packets.PacketWriter
的用法示例。
在下文中一共展示了PacketWriter.WriteInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: HandleSendNewTimeSpeed
public static void HandleSendNewTimeSpeed(ref WorldClass session)
{
PacketWriter newTimeSpeed = new PacketWriter(LegacyMessage.SendNewTimeSpeed);
newTimeSpeed.WritePackedTime();
newTimeSpeed.WritePackedTime();
newTimeSpeed.WriteFloat(0.01666667f);
newTimeSpeed.WriteInt32(0);
newTimeSpeed.WriteInt32(0);
session.Send(ref newTimeSpeed);
}
示例3: HandleLoginSetTimeSpeed
public static void HandleLoginSetTimeSpeed(ref WorldClass session)
{
PacketWriter loginSetTimeSpeed = new PacketWriter(ServerMessage.LoginSetTimeSpeed);
loginSetTimeSpeed.WriteInt32(1);
loginSetTimeSpeed.WriteInt32(1);
loginSetTimeSpeed.WriteFloat(0.01666667f);
loginSetTimeSpeed.WritePackedTime();
loginSetTimeSpeed.WritePackedTime();
session.Send(ref loginSetTimeSpeed);
}
示例4: HandleCreatureStats
public static void HandleCreatureStats(ref PacketReader packet, ref WorldClass session)
{
int id = packet.ReadInt32();
ulong guid = packet.ReadUInt64();
Creature creature = DataMgr.FindCreature(id);
if (creature != null)
{
CreatureStats stats = creature.Stats;
PacketWriter creatureStats = new PacketWriter(LegacyMessage.CreatureStats);
creatureStats.WriteInt32(stats.Id);
creatureStats.WriteCString(stats.Name);
for (int i = 0; i < 7; i++)
creatureStats.WriteCString("");
creatureStats.WriteCString(stats.SubName);
creatureStats.WriteCString("");
creatureStats.WriteCString(stats.IconName);
foreach (var v in stats.Flag)
creatureStats.WriteInt32(v);
creatureStats.WriteInt32(stats.Type);
creatureStats.WriteInt32(stats.Family);
creatureStats.WriteInt32(stats.Rank);
foreach (var v in stats.QuestKillNpcId)
creatureStats.WriteInt32(v);
foreach (var v in stats.DisplayInfoId)
creatureStats.WriteInt32(v);
creatureStats.WriteFloat(stats.HealthModifier);
creatureStats.WriteFloat(stats.PowerModifier);
creatureStats.WriteUInt8(stats.RacialLeader);
foreach (var v in stats.QuestItemId)
creatureStats.WriteInt32(v);
creatureStats.WriteInt32(stats.MovementInfoId);
creatureStats.WriteInt32(stats.ExpansionRequired);
session.Send(ref creatureStats);
}
else
Log.Message(LogType.DEBUG, "Creature (Id: {0}) not found.", id);
}
示例5: HandleDBQueryBulk
public static void HandleDBQueryBulk(ref PacketReader packet, ref WorldClass session)
{
var type = (DBTypes)packet.ReadUInt32();
var unknown = packet.ReadInt32();
var id = packet.ReadInt32();
switch (type)
{
case DBTypes.BroadcastText:
{
var broadCastText = GossipMgr.GetBroadCastText<Creature>(id);
PacketWriter dbReply = new PacketWriter(JAMCMessage.DBReply);
BitPack BitPack = new BitPack(dbReply);
var textLength = broadCastText.Text.Length;
var alternativeTextLength = broadCastText.AlternativeText.Length;
var size = 48;
if (textLength == 0 || alternativeTextLength == 0)
size += 1;
size += textLength + alternativeTextLength;
dbReply.WriteUInt32((uint)size);
dbReply.WriteInt32(broadCastText.Id);
dbReply.WriteInt32(broadCastText.Language);
dbReply.WriteUInt16((ushort)broadCastText.Text.Length);
dbReply.WriteString(broadCastText.Text);
dbReply.WriteUInt16((ushort)broadCastText.AlternativeText.Length);
dbReply.WriteString(broadCastText.AlternativeText);
broadCastText.Emotes.ForEach(emote => dbReply.WriteInt32(emote));
dbReply.WriteUInt32(1);
dbReply.WriteUInt32(0); // UnixTime, last change server side
dbReply.WriteUInt32((uint)DBTypes.BroadcastText);
dbReply.WriteInt32(broadCastText.Id);
session.Send(ref dbReply);
break;
}
}
}
示例6: HandleTalkToGossip
public static void HandleTalkToGossip(ref PacketReader packet, WorldClass session)
{
BitUnpack BitUnpack = new BitUnpack(packet);
byte[] guidMask = { 7, 3, 6, 5, 2, 1, 4, 0 };
byte[] guidBytes = { 3, 4, 6, 1, 0, 2, 7, 5 };
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(7, 6, 0);
BitPack.Write(0, 19); // gossipData.QuestsCount
BitPack.WriteGuidMask(4, 3, 2);
BitPack.Write(0, 20); // gossipData.OptionsCount
BitPack.WriteGuidMask(1, 5);
BitPack.Flush();
BitPack.WriteGuidBytes(2, 7);
gossipMessage.WriteInt32(gossipData.FriendshipFactionID);
BitPack.WriteGuidBytes(3, 1);
gossipMessage.WriteInt32(gossipData.TextID);
BitPack.WriteGuidBytes(5);
gossipMessage.WriteInt32(gossipData.Id);
BitPack.WriteGuidBytes(6, 4, 0);
session.Send(ref gossipMessage);
}
}
示例7: HandleBroadcastText
public static void HandleBroadcastText(ref WorldClass session, int id)
{
var broadCastText = GossipMgr.GetBroadCastText<Creature>(id);
PacketWriter dbReply = new PacketWriter(ServerMessage.DBReply);
BitPack BitPack = new BitPack(dbReply);
var textLength = broadCastText.Text.Length;
var alternativeTextLength = broadCastText.AlternativeText.Length;
var size = 48;
if (textLength == 0 || alternativeTextLength == 0)
size += 1;
size += textLength + alternativeTextLength;
dbReply.WriteUInt32(0); // UnixTime, last change server side
dbReply.WriteUInt32((uint)DBTypes.BroadcastText);
dbReply.WriteUInt32((uint)size);
dbReply.WriteInt32(broadCastText.Id);
dbReply.WriteInt32(broadCastText.Language);
dbReply.WriteUInt16((ushort)broadCastText.Text.Length);
dbReply.WriteString(broadCastText.Text);
dbReply.WriteUInt16((ushort)broadCastText.AlternativeText.Length);
dbReply.WriteString(broadCastText.AlternativeText);
broadCastText.Emotes.ForEach(emote => dbReply.WriteInt32(emote));
dbReply.WriteUInt32(1);
dbReply.WriteInt32(broadCastText.Id);
session.Send(ref dbReply);
}
示例8: SendMessageByType
public static void SendMessageByType(ref WorldClass session, MessageType type, int language, string chatMessage)
{
PacketWriter messageChat = new PacketWriter(LegacyMessage.MessageChat);
ulong guid = session.Character.Guid;
messageChat.WriteUInt8((byte)type);
messageChat.WriteInt32(language);
messageChat.WriteUInt64(guid);
messageChat.WriteUInt32(0);
messageChat.WriteUInt64(guid);
messageChat.WriteUInt32((uint)chatMessage.Length + 1);
messageChat.WriteCString(chatMessage);
messageChat.WriteUInt16(0);
session.Send(ref messageChat);
}
示例9: SendMessageByType
public static void SendMessageByType(ref WorldClass session, MessageType type, int language, string chatMessage, bool Broadcast = false)
{
PacketWriter messageChat = new PacketWriter(LegacyMessage.MessageChat);
ulong guid = session.Character.Guid;
messageChat.WriteUInt8((byte)type);
messageChat.WriteInt32(language);
messageChat.WriteUInt64(guid);
messageChat.WriteUInt32(0);
messageChat.WriteUInt64(guid);
messageChat.WriteUInt32((uint)chatMessage.Length + 1);
messageChat.WriteCString(chatMessage);
messageChat.WriteUInt16(0);
if (Broadcast)
{
Globals.WorldMgr.SendToInRangeCharacter(session.Character, messageChat);
session.Send(ref messageChat);
}
else
session.Send(ref messageChat);
}
示例10: 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);
PacketWriter messageChat = new PacketWriter(LegacyMessage.MessageChat);
ulong guid = WorldMgr.Session.Character.Guid;
messageChat.WriteUInt8(1);
messageChat.WriteInt32(language);
messageChat.WriteUInt64(guid);
messageChat.WriteUInt32(0);
messageChat.WriteUInt64(guid);
messageChat.WriteUInt32(messageLength + 1);
messageChat.WriteCString(chatMessage);
messageChat.WriteUInt16(0);
session.Send(messageChat);
}
示例11: SendMessage
public static void SendMessage(ref WorldClass session, ChatMessageValues chatMessage, WorldClass pSession = null)
{
byte[] GuidMask = { 4, 1, 3, 6, 2, 5, 0, 7 };
byte[] GuidMask3 = { 6, 1, 3, 5, 4, 2, 7, 0 };
byte[] GuidBytes = { 7, 4, 0, 6, 3, 2, 5, 1 };
byte[] GuidBytes3 = { 7, 4, 1, 3, 0, 6, 5, 2 };
var pChar = session.Character;
var guid = pChar.Guid;
if (pSession != null)
guid = pSession.Character.Guid;
PacketWriter chat = new PacketWriter(ServerMessage.Chat);
BitPack BitPack = new BitPack(chat, guid);
BitPack.Write(!chatMessage.HasLanguage);
BitPack.Write(1);
BitPack.Write(1);
BitPack.Write(0, 8);
BitPack.Write(1);
BitPack.Write(0);
BitPack.Write(1);
BitPack.Write(1);
BitPack.Write(1);
BitPack.Write(0, 8);
BitPack.Write(0);
BitPack.WriteGuidMask(GuidMask3);
BitPack.Write(1);
BitPack.Write(0);
BitPack.Write(1);
BitPack.Write(!chatMessage.HasRealmId);
BitPack.Write(0);
BitPack.WriteStringLength(chatMessage.Message, 12);
BitPack.Write(0);
BitPack.WriteGuidMask(GuidMask);
BitPack.Write(0);
BitPack.Write(8, 9);
BitPack.Flush();
BitPack.WriteGuidBytes(GuidBytes3);
if (chatMessage.HasLanguage)
chat.WriteUInt8(chatMessage.Language);
BitPack.WriteGuidBytes(GuidBytes);
chat.WriteString(chatMessage.Message, false);
chat.WriteUInt8((byte)chatMessage.ChatType);
chat.WriteInt32(0);
if (chatMessage.HasRealmId)
chat.WriteInt32(chatMessage.RealmId);
switch (chatMessage.ChatType)
{
case MessageType.ChatMessageSay:
WorldMgr.SendByDist(pChar, chat, 625);
break;
case MessageType.ChatMessageYell:
WorldMgr.SendByDist(pChar, chat, 90000);
break;
default:
session.Send(ref chat);
break;
}
}
示例12: HandleTalkToGossip
public static void HandleTalkToGossip(ref PacketReader packet, ref WorldClass session)
{
var guid = packet.ReadUInt64();
var gossipData = GossipMgr.GetGossip<Creature>(ObjectGuid.GetGuid(guid));
if (gossipData != null)
{
PacketWriter gossipMessage = new PacketWriter(LegacyMessage.GossipMessage);
gossipMessage.WriteUInt64(guid);
gossipMessage.WriteInt32(gossipData.Id);
gossipMessage.WriteInt32(gossipData.FriendshipFactionID);
gossipMessage.WriteInt32(gossipData.TextID);
gossipMessage.WriteInt32(gossipData.OptionsCount);
gossipMessage.WriteInt32(gossipData.QuestsCount);
session.Send(ref gossipMessage);
}
}
示例13: HandleQueryGameObject
public static void HandleQueryGameObject(ref PacketReader packet, ref WorldClass session)
{
byte[] guidMask = { 4, 6, 7, 5, 3, 2, 1, 0 };
byte[] guidBytes = { 0, 2, 3, 5, 6, 1, 4, 7 };
BitUnpack BitUnpack = new BitUnpack(packet);
var hasData = false;
var id = packet.Read<int>();
var guid = BitUnpack.GetPackedValue(guidMask, guidBytes);
PacketWriter queryGameObjectResponse = new PacketWriter(ServerMessage.QueryGameObjectResponse);
BitPack BitPack = new BitPack(queryGameObjectResponse);
GameObject gObject = DataMgr.FindGameObject(id);
if (hasData = (gObject != null))
{
GameObjectStats stats = gObject.Stats;
BitPack.Write(hasData);
BitPack.Flush();
queryGameObjectResponse.WriteInt32(stats.Id);
queryGameObjectResponse.WriteInt32(0);
queryGameObjectResponse.WriteInt32(stats.Type);
queryGameObjectResponse.WriteInt32(stats.DisplayInfoId);
queryGameObjectResponse.WriteCString(stats.Name);
for (int i = 0; i < 3; i++)
queryGameObjectResponse.WriteCString("");
queryGameObjectResponse.WriteCString(stats.IconName);
queryGameObjectResponse.WriteCString(stats.CastBarCaption);
queryGameObjectResponse.WriteCString("");
foreach (var v in stats.Data)
queryGameObjectResponse.WriteInt32(v);
queryGameObjectResponse.WriteFloat(stats.Size);
queryGameObjectResponse.WriteUInt8((byte)stats.QuestItemId.Count);
foreach (var v in stats.QuestItemId)
queryGameObjectResponse.WriteInt32(v);
queryGameObjectResponse.WriteInt32(stats.ExpansionRequired);
var size = (uint)queryGameObjectResponse.BaseStream.Length - 13;
queryGameObjectResponse.WriteUInt32Pos(size, 9);
session.Send(ref queryGameObjectResponse);
}
else
{
BitPack.Write(hasData);
Log.Message(LogType.DEBUG, "Gameobject (Id: {0}) not found.", id);
}
}
示例14: SendMessage
public static void SendMessage(ref WorldClass session, ChatMessageValues chatMessage)
{
byte[] GuidMask = { 4, 7, 6, 3, 0, 5, 1, 2 };
byte[] GuidMask3 = { 4, 0, 7, 2, 1, 5, 3, 6 };
byte[] GuidBytes = { 3, 5, 1, 4, 2, 6, 0, 7 };
byte[] GuidBytes3 = { 7, 6, 0, 3, 4, 1, 5, 2 };
var pChar = session.Character;
PacketWriter chat = new PacketWriter(ServerMessage.Chat);
BitPack BitPack = new BitPack(chat, pChar.Guid);
BitPack.Write(1);
BitPack.Write(!chatMessage.HasLanguage);
BitPack.Write(1);
BitPack.Write(0);
BitPack.Write(1);
BitPack.Write(0);
BitPack.Write(0);
BitPack.Write(1);
BitPack.Write(1);
BitPack.Write(0);
BitPack.WriteGuidMask(GuidMask);
BitPack.Write(0);
BitPack.Write(0);
BitPack.Write(chatMessage.Message.Length, 12);
BitPack.Write(!chatMessage.HasRealmId);
BitPack.WriteGuidMask(GuidMask3);
BitPack.Write(1);
BitPack.Write(0, 8);
BitPack.Write(8, 9);
BitPack.Write(1);
BitPack.Write(1);
BitPack.Write(0, 8);
BitPack.Flush();
BitPack.WriteGuidBytes(GuidBytes);
chat.WriteString(chatMessage.Message);
if (chatMessage.HasRealmId)
chat.WriteInt32(chatMessage.RealmId);
BitPack.WriteGuidBytes(GuidBytes3);
if (chatMessage.HasLanguage)
chat.WriteUInt8(chatMessage.Language);
chat.WriteUInt8((byte)chatMessage.ChatType);
switch (chatMessage.ChatType)
{
case MessageType.ChatMessageSay:
WorldMgr.SendByDist(pChar, chat, 625);
break;
case MessageType.ChatMessageYell:
WorldMgr.SendByDist(pChar, chat, 90000);
break;
default:
break;
}
}
示例15: HandleVendorTabeList
public static void HandleVendorTabeList(ref PacketReader packet, ref WorldClass session)
{
ulong targetGuid = packet.ReadUInt64();
if (targetGuid == session.Character.TargetGuid)
{
HighGuidType lol = Framework.ObjectDefines.ObjectGuid.GetGuidType(targetGuid);
ulong odd = ObjectGuid.GetGuid(targetGuid);
CreatureSpawn spawn = Globals.SpawnMgr.FindSpawn(targetGuid);
Creature npc = spawn.Creature;
PacketWriter Inventory = new PacketWriter(JAMCMessage.VendorInventory);
BitPack ss = new BitPack(Inventory);
Inventory.WriteInt8(0x01);//client expects counting to start at 1??
byte[] count = {00,10,00};//count dat bitstream fortmat unkown
Inventory.WriteBytes(count, 3);
/*Item1*/
Inventory.WriteInt8(11);//slot
Inventory.WriteInt32(0xFFF010);//left ub stock?
ss.Flush();
string ssss = "00 00 0C 34 00 00 0C 10 00 00 00 10 00 00 05 30 00 00 03 C0 00 00 00 10 00 00 0C 74 00 00 00 B0 E0 00 0F FF FF FF F0 00 00 00 00 20 00 00 00 10 00 00 02 80 00 00 01 40 00 00 00 10 00 00 0C 44 00 00 0C 20 00 00 0F FF FF FF F0 00 00 00 00 30 00 00 00 10 00 00 05 30 00 00 02 D0 00 00 00 10 00 00 0C 64 00 00 0C 30 00 00 0F FF FF FF F0 00 00 00 00 40 00 00 00 10 00 00 03 E0 00 00 01 E0 00 00 00 10 00 00 0C 84 00 00 00 C0 E0 00 0F FF FF FF F0 00 00 00 00 50 00 00 00 10 00 00 02 80 00 00 01 40 00 00 00 10 00 00 0C 54 00 00 0C 70 20 00 0F FF FF FF F0 00 00 00 00 60 00 00 00 10 00 00 02 C0 00 00 01 40 00 00 00 10 00 00 0F 34 10 00 05 50 00 00 0F FF FF FF F0 00 00 00 00 70 00 00 00 10 00 00 05 50 00 00 03 C0 00 00 00 10 00 00 06 B3 80 00 02 B0 70 00 0F FF FF FF F0 00 00 00 00 80 00 00 00 10 00 00 02 B0 00 00 01 40 00 00 00 10 00 00 0F 44 20 00 0D 10 00 00 0F FF FF FF F0 00 00 00 00 90 00 00 00 10 00 00 05 20 00 00 02 D0 00 00 00 10 00 00 06 C3 80 00 0D 20 00 00 0F FF FF FF F0 00 00 00 00 A0 00 00 00 10 00 00 03 D0 00 00 01 E0 00 00 00 10 00 00 0A 93 70 00 02 C0 70 00 0F FF FF FF F0 00 00 00 00 B0 00 00 00 10 00 00 02 B0 00 00 01 40 00 00 00 10 00 00 06 D3 80 00 0C A0 20 00 0F FF FF FF F0 00 00 00 00 C0 00 00 00 10 00 00 02 C0 00 00 01 40 00 00 05 99 CF 03 10 D9 C0";
string[] all = ssss.Split(' ');
// int gu = int.Parse(all[0] + " " + all[1] + " " + all[2] + " " + all[3], System.Globalization.NumberStyles.HexNumber);
foreach (string a in all)
{
byte test = byte.Parse(a, System.Globalization.NumberStyles.HexNumber);
Inventory.WriteUInt8(test);
}
/* Inventory.WriteGuid(121332123);
Item ii = npc.Data.VendorItems[0];
Inventory.WriteUInt32(1); // client expects counting to start at 1
Inventory.WriteUInt32(1); // unk 4.0.1 always 1
Inventory.WriteUInt32((uint)71634);
Inventory.WriteUInt32((uint)69314);
Inventory.WriteUInt32(0xFFFFFFFF);//left in stcok
Inventory.WriteUInt32(1);
Inventory.WriteUInt32(0);
Inventory.WriteUInt32(1);
Inventory.WriteUInt32(0);
Inventory.WriteInt8(0); ;*/
// unk 4.0.1
session.Send(ref Inventory);
Console.WriteLine(npc.Data.NpcFlags);
}
// Globals.WorldMgr.
}