本文整理汇总了C#中Packet.ReadInt32方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.ReadInt32方法的具体用法?C# Packet.ReadInt32怎么用?C# Packet.ReadInt32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.ReadInt32方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleGuildInfo
public static void HandleGuildInfo(Packet packet)
{
packet.ReadCString("Name");
packet.ReadTime("Created");
packet.ReadInt32("Number of members");
packet.ReadInt32("Number of accounts");
}
示例2: GameobjectQueryResponse
public static void GameobjectQueryResponse(Packet packet)
{
GameObject go = new GameObject();
var entry = packet.ReadEntryKey("Entry");
go.Entry = entry.Key;
if (entry.Value)
return;
go.Type = packet.ReadEnum<GameObjectType>("Type");
go.DisplayID = packet.ReadInt32("Display ID");
for (var i = 0; i < 4; i++)
go.Name[i] = packet.ReadCString("Name " + i);
go.IconName = packet.ReadCString("Icon Name");
go.CastCaption = packet.ReadCString("Cast Caption");
go.UnkString = packet.ReadCString("Unk String");
for (var i = 0; i < 32; i++)
go.Data[i] = packet.ReadInt32("Data " + i);
go.Size = packet.ReadSingle("Size");
for (var i = 0; i < 6; i++)
go.QuestItems[i] = packet.ReadInt32("Quest Item " + i);
go.Exp = packet.ReadInt32("Expansion ID");
GameObjectStorage.GetSingleton().Add(go);
}
示例3: HandleCompressedUpdateObject
public static void HandleCompressedUpdateObject(Packet packet)
{
var decompCount = packet.ReadInt32();
var pkt = packet.Inflate(decompCount);
HandleUpdateObject(pkt);
// otherwise Handler.cs will bitch about not reading the entire packet
packet.SetPosition(packet.GetLength());
}
示例4: HandleAccountDataTimes
public static void HandleAccountDataTimes(Packet packet)
{
packet.ReadTime("Time");
packet.ReadByte("Unk byte (1)");
int mask = packet.ReadInt32("Mask");
for (int i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i)
{
if ((mask & (1 << i)) != 0)
packet.ReadTime(((AccountDataType)i).ToString());
}
}
示例5: HandleReqUpdateAccountData
public static void HandleReqUpdateAccountData(Packet packet)
{
packet.ReadEnum<AccountDataType>("Type");
packet.ReadTime("Time");
int inflatedSize = packet.ReadInt32("Size");
byte[] compressedData = packet.ReadBytes((int)packet.GetLength() - (int)packet.GetPosition());
byte[] data = new byte[inflatedSize];
var inflater = new Inflater();
inflater.SetInput(compressedData, 0, compressedData.Length);
inflater.Inflate(data, 0, inflatedSize);
Console.WriteLine("Data: {0}", encoder.GetString(data));
}
示例6: 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));
}
示例7: 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");
}
}
示例8: HandleCreatureQueryResponse
public static void HandleCreatureQueryResponse(Packet packet)
{
Creature c = new Creature();
var entry = packet.ReadEntryKey("Entry");
if (entry.Value)
return;
c.Entry = entry.Key;
for (var i = 0; i < 4; i++)
c.Name[i] = packet.ReadCString("Name " + i);
for (var i = 0; i < 4; i++)
c.Name[i] = packet.ReadCString("Unk string " + i);
c.SubName = packet.ReadCString("Sub Name");
c.IconName = packet.ReadCString("Icon Name");
c.TypeFlags = packet.ReadEnum<CreatureTypeFlag>("Type Flags");
c.Type = packet.ReadEnum<CreatureType>("Type");
c.Family = packet.ReadEnum<CreatureFamily>("Family");
int val = packet.ReadInt32("Unk int");
c.Rank = packet.ReadEnum<CreatureRank>("Rank");
c.KillCredit1 = packet.ReadInt32("Kill Credit 1");
c.KillCredit2 = packet.ReadInt32("Kill Credit 2");
for (var i = 0; i < 4; i++)
c.DisplayIDs[i] = packet.ReadInt32("Display ID " + i);
c.HealthModifier = packet.ReadSingle("Health Modifier");
c.ManaModifier = packet.ReadSingle("Mana Modifier");
c.RacialLeader = packet.ReadBoolean("Racial Leader");
for (var i = 0; i < 6; i++)
c.QuestItems[i] = packet.ReadInt32("Quest Item " + i);
c.MovementID = packet.ReadInt32("Movement ID");
c.Exp = packet.ReadInt32("Expansion ID");
CreatureStorage.GetSingleton().Add(c);
}
示例9: HandleUpdateObject
public static void HandleUpdateObject(Packet packet)
{
var map = packet.ReadInt16("Map");
var count = packet.ReadInt32("Count");
long sposition = packet.GetPosition();
var unkByte = packet.ReadByte();
if (unkByte != 3)
packet.SetPosition(sposition);
else
{
Console.WriteLine("firstType: " + unkByte);
var guidCount = packet.ReadInt32("GUID Count");
if (guidCount > 0) {
for (uint i = 0; i < guidCount; i++)
packet.ReadPackedGuid("GUID " + (i + 1));
}
}
for (var i = 0; i < (count - ((unkByte == 3) ? 1 : 0)); i++)
{
var type = packet.ReadEnum<UpdateType>("Update Type #" + (i + 1));
switch (type)
{
case UpdateType.Values:
{
var guid = packet.ReadPackedGuid("GUID");
var updates = ReadValuesUpdateBlock(packet);
WowObject obj;
if (Objects.ContainsKey(map) && Objects[map].TryGetValue(guid, out obj))
HandleUpdateFieldChangedValues(false, guid, obj.Type, updates, obj.Movement);
break;
}
case UpdateType.Movement:
{
var guid = packet.ReadPackedGuid("GUID");
packet.ReadEnum<ObjectType>("Object type");
ReadMovementUpdateBlock(packet, guid);
ReadValuesUpdateBlock(packet);
break;
}
case UpdateType.CreateObject1:
case UpdateType.CreateObject2:
{
var guid = packet.ReadPackedGuid("GUID");
ReadCreateObjectBlock(packet, guid, map);
break;
}
case UpdateType.FarObjects:
case UpdateType.NearObjects:
{
var objCount = packet.ReadInt32("Object Count");
for (var j = 0; j < objCount; j++)
packet.ReadPackedGuid("Object GUID");
break;
}
}
}
}
示例10: ReadMovementInfo
public static MovementInfo ReadMovementInfo(Packet packet, Guid guid)
{
bool HaveTransportData = false,
HaveTransportTime2 = false,
HaveTransportTime3 = false,
HavePitch = false,
HaveFallData = false,
HaveFallDirection = false,
HaveSplineElevation = false,
UnknownBool = false;
var info = new MovementInfo();
info.Flags = packet.ReadEnum<MoveFlag>("Movement Flags", 30);
var flags2 = packet.ReadEnum<MoveFlagExtra>("Extra Movement Flags", 12);
if (HaveTransportData = packet.ReadBit())
{
HaveTransportTime2 = packet.ReadBit();
HaveTransportTime3 = packet.ReadBit();
}
HavePitch = packet.ReadBit();
if (HaveFallData = packet.ReadBit())
HaveFallDirection = packet.ReadBit();
HaveSplineElevation = packet.ReadBit();
UnknownBool = packet.ReadBit();
packet.ReadGuid("GUID");
packet.ReadInt32("Time");
var pos = packet.ReadVector4("Position");
info.Position = new Vector3(pos.X, pos.Y, pos.Z);
info.Orientation = pos.O;
if (HaveTransportData)//info.Flags.HasFlag(MoveFlag.OnTransport))
{
packet.ReadGuid("Transport GUID");
packet.ReadVector4("Transport Position");
packet.ReadByte("Transport Seat");
packet.ReadInt32("Transport Time");
if (HaveTransportTime2)//flags2.HasFlag(MoveFlagExtra.InterpolatedPlayerMovement))
packet.ReadInt32("Transport Time 2");
if (HaveTransportTime3)
packet.ReadInt32("Transport Time 3");
}
if (HavePitch)//info.Flags.HasAnyFlag(MoveFlag.Swimming | MoveFlag.Flying) ||
//flags2.HasFlag(MoveFlagExtra.AlwaysAllowPitching))
packet.ReadSingle("Swim Pitch");
if (HaveFallData) // info.Flags.HasFlag(MoveFlag.Falling)
{
packet.ReadInt32("Fall Time");
packet.ReadSingle("Jump Velocity");
if (HaveFallDirection)
{
packet.ReadSingle("Jump Sin");
packet.ReadSingle("Jump Cos");
packet.ReadSingle("Jump XY Speed");
}
}
if (HaveSplineElevation) //info.Flags.HasFlag(MoveFlag.SplineElevation))
packet.ReadSingle("Spline Elevation");
return info;
}
示例11: ParseMonsterMovePackets
public static void ParseMonsterMovePackets(Packet packet)
{
var guid = packet.ReadPackedGuid("GUID");
if (packet.GetOpcode() == (ushort)Opcode.SMSG_MONSTER_MOVE_TRANSPORT)
{
packet.ReadPackedGuid("Transport GUID");
packet.ReadByte("Transport Seat");
}
packet.ReadBoolean("Unk Boolean");
var pos = packet.ReadVector3("Position");
packet.ReadInt32("Move Ticks");
var type = packet.ReadEnum<SplineType>("Spline Type");
switch (type)
{
case SplineType.FacingSpot:
{
packet.ReadVector3("Facing Spot");
break;
}
case SplineType.FacingTarget:
{
packet.ReadGuid("Facing GUID");
break;
}
case SplineType.FacingAngle:
{
packet.ReadSingle("Facing Angle");
break;
}
case SplineType.Stop:
{
return;
}
}
var flags = packet.ReadEnum<SplineFlag>("Spline Flags");
if (flags.HasFlag(SplineFlag.Unknown3)) {
packet.ReadEnum<MoveAnimationState>("Animation State");
packet.ReadInt32("Unk Int32 1");
}
packet.ReadInt32("Move Time");
if (flags.HasFlag(SplineFlag.Trajectory)) {
packet.ReadSingle("Unk Single");
packet.ReadInt32("Unk Int32 2");
}
var waypoints = packet.ReadInt32("Waypoints");
var newpos = packet.ReadVector3("Waypoint 0");
if (flags.HasFlag(SplineFlag.Flying) || flags.HasFlag(SplineFlag.CatmullRom)) {
for (var i = 0; i < waypoints - 1; i++) {
packet.ReadVector3("Waypoint " + (i + 1));
}
}
else {
var mid = new Vector3();
mid.X = (pos.X + newpos.X) * 0.5f;
mid.Y = (pos.Y + newpos.Y) * 0.5f;
mid.Z = (pos.Z + newpos.Z) * 0.5f;
for (var i = 0; i < waypoints - 1; i++) {
var vec = packet.ReadPackedVector3();
vec.X += mid.X;
vec.Y += mid.Y;
vec.Z += mid.Z;
Console.WriteLine("Waypoint " + (i + 1) + ": " + vec);
}
}
}
示例12: HandleSetDataRequest
private void HandleSetDataRequest(TcpSession session, Packet p)
{
//_logger.Debug("-C_SETDATA_REQ-");
Player plr;
if (!_players.TryGetValue(session.Guid, out plr))
{
session.StopListening();
return;
}
p.ReadUInt16(); // unk
p.ReadUInt64(); // accID
plr.ServerID = p.ReadUInt16();
var channelID = p.ReadInt16();
var roomID = p.ReadInt32();
if(roomID == -1)
roomID = 0;
if (channelID == -1)
channelID = 0;
plr.Room = new Room(null, EServerType.Chat) { ID = (uint)roomID };
plr.CommunityByte = p.ReadByte();
p.ReadUInt32(); // total exp
p.ReadBytes(32); // td/dm info
plr.AllowCombiRequest = (EAllowCommunityRequest)p.ReadByte();
plr.AllowFriendRequest = (EAllowCommunityRequest)p.ReadByte();
plr.AllowInvite = (EAllowCommunityRequest)p.ReadByte();
plr.AllowInfoRequest = (EAllowCommunityRequest)p.ReadByte();
plr.CommunityData = p.ReadBytes(41);
Channel channel;
if (!_channels.TryGetValue((ushort)channelID, out channel))
return;
if (plr.Channel == null && channelID > 0) // join
{
var ack = new Packet(EChatPacket.SChannelPlayerListInfoAck);
ack.Write((uint)channel.ID);
ack.Write(channel.Players.Count);
foreach (var player in channel.Players.Values)
ack.WriteChatUserData(player);
session.Send(ack);
channel.Join(plr);
}
else if(channelID == 0) // leave
{
if(plr.Channel != null)
plr.Channel.Leave(plr);
}
else // update
{
var ack = new Packet(EChatPacket.SChannelPlayerListInfoAck);
ack.Write((uint)channel.ID);
ack.Write(channel.Players.Count);
foreach (var player in channel.Players.Values)
ack.WriteChatUserData(player);
channel.Broadcast(ack);
}
}
示例13: HandleBRSFriendNotify
private void HandleBRSFriendNotify(TcpSession session, Packet p)
{
var accID = p.ReadUInt64();
var accepted = p.ReadInt32() > 0;
var nickname = p.ReadCStringBuffer(31);
//_logger.Debug("-C_ADD_FRIEND_REQ- ID: {0} Nickname: {1}", accID, nickname);
Player plr;
if (!_players.TryGetValue(session.Guid, out plr))
{
session.StopListening();
return;
}
Packet ack;
var plrFromRequest = _players.GetPlayerByID(accID);
if (plrFromRequest == null) return;
if (accepted)
{
SendBRSFriendNotify(plr, plrFromRequest, EFriendNotify.Accepted);
SendBRSFriendNotify(plrFromRequest, plr, EFriendNotify.Accepted);
}
else
{
SendBRSFriendNotify(plr, plrFromRequest, EFriendNotify.Denied);
SendBRSFriendNotify(plr, plrFromRequest, EFriendNotify.DeleteRelation);
SendBRSFriendNotify(plrFromRequest, plr, EFriendNotify.DeleteRelation);
}
var friend = plrFromRequest.FriendList.FirstOrDefault(f => f.ID == plr.AccountID);
if (friend == null) return;
if (accepted)
{
friend.Accepted = true;
GameDatabase.Instance.UpdateFriend(plrFromRequest.AccountID, friend.ID, friend.Accepted);
var newFriend = new Friend()
{
ID = plrFromRequest.AccountID,
Nickname = plrFromRequest.Nickname,
Accepted = true
};
plr.FriendList.Add(newFriend);
GameDatabase.Instance.AddFriend(plr.AccountID, newFriend.ID, newFriend.Nickname, newFriend.Accepted);
}
else
{
plrFromRequest.FriendList.Remove(friend);
GameDatabase.Instance.RemoveFriend(plrFromRequest.AccountID, friend.ID);
}
}
示例14: HandleCreateRoom
private void HandleCreateRoom(TcpSession session, Packet p)
{
Player player;
if (!Players.TryGetValue(session.Guid, out player))
{
session.StopListening();
return;
}
if (player.Channel == null || player.PublicIP == 0)
return;
var room = new Room(Rooms);
var roomID = Rooms.CreateRoomID(player.Channel.ID);
var tunnelID = Rooms.CreateTunnelID();
room.MasterID = player.AccountID;
room.ID = roomID;
room.TunnelID = tunnelID;
room.Channel = player.Channel;
room.Name = p.ReadCStringBuffer(31);
room.MatchKey = p.ReadBytes(4);
room.TimeLimit = p.ReadByte();
room.TimeLimit *= 60 * 1000;
room.ScoreLimit = p.ReadByte();
room.Unk = p.ReadInt32();
room.Password = p.ReadUInt32();
room.IsFriendly = p.ReadBoolean();
room.IsBalanced = p.ReadBoolean();
room.MinLevel = p.ReadByte();
room.MaxLevel = p.ReadByte();
room.EquipLimit = p.ReadByte();
room.IsNoIntrusion = p.ReadBoolean();
room.State = EGameRuleState.Waiting;
var cont = _pluginManager.OnCreateRoom(player, room);
Packet ack;
//_logger.Debug("-CCreateRoom- MapID: {0} Mode: {1}", room.MapID, (int)room.GameRule);
if (!GameDatabase.Instance.IsValidMapID(room.MapID))
{
Logger.Error("-CCreateRoom HAX- NOT ALLOWED MapID: {0} Mode: {1}", room.MapID, (int)room.GameRule);
ack = new Packet(EGamePacket.SResultAck);
ack.Write((uint)EServerResult.FailedToRequestTask);
session.Send(ack);
return;
}
if (room.GameRule != EGameRule.Touchdown && room.GameRule != EGameRule.Deathmatch && room.GameRule != EGameRule.Survival && cont)
{
ack = new Packet(EGamePacket.SResultAck);
ack.Write((uint)EServerResult.FailedToRequestTask);
session.Send(ack);
return;
}
Rooms.TryAdd(tunnelID, room);
ack = new Packet(EGamePacket.SDeployRoomAck);
ack.Write(room.ID);
ack.Write(room.MatchKey);
ack.Write((byte)room.State);
ack.Write(room.GetPing());
ack.WriteStringBuffer(room.Name, 31);
ack.Write(room.PublicType);
ack.Write(room.TimeLimit);
ack.Write(room.ScoreLimit);
ack.Write(room.IsFriendly);
ack.Write(room.IsBalanced);
ack.Write(room.MinLevel);
ack.Write(room.MaxLevel);
ack.Write(room.EquipLimit);
ack.Write(room.IsNoIntrusion);
player.Channel.Broadcast(ack);
room.Join(player);
}
示例15: ReadMovementInfo
public static MovementInfo ReadMovementInfo(Packet packet, Guid guid)
{
var info = new MovementInfo();
info.Flags = packet.ReadEnum<MoveFlag>("Movement Flags");
var flags2 = packet.ReadEnum<MoveFlagExtra>("Extra Movement Flags");
packet.ReadInt32("Time");
var pos = packet.ReadVector4("Position");
info.Position = new Vector3(pos.X, pos.Y, pos.Z);
info.Orientation = pos.O;
if (info.Flags.HasFlag(MoveFlag.OnTransport))
{
packet.ReadPackedGuid("Transport GUID");
packet.ReadVector4("Transport Position");
packet.ReadInt32("Transport Time");
packet.ReadByte("Transport Seat");
if (flags2.HasFlag(MoveFlagExtra.InterpolatedPlayerMovement))
packet.ReadInt32("Transport Time 2");
}
if (info.Flags.HasAnyFlag(MoveFlag.Swimming | MoveFlag.Flying) ||
flags2.HasFlag(MoveFlagExtra.AlwaysAllowPitching))
packet.ReadSingle("Swim Pitch");
packet.ReadInt32("Fall Time");
if (info.Flags.HasFlag(MoveFlag.Falling))
{
packet.ReadSingle("Jump Velocity");
packet.ReadSingle("Jump Sin");
packet.ReadSingle("Jump Cos");
packet.ReadSingle("Jump XY Speed");
}
if (info.Flags.HasFlag(MoveFlag.SplineElevation))
packet.ReadSingle("Spline Elevation");
return info;
}