public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(1); PlayerId = reader.ReadObjectId(); uint unknown1 = reader.ReadUInt(); BodyType = reader.ReadModelId(); ushort xloc = reader.ReadUShort(); ushort yloc = reader.ReadUShort(); byte unknown2 = reader.ReadByte(); sbyte zloc = reader.ReadSByte(); Location = new Location3D(xloc, yloc, zloc); (Direction, MovementType) = reader.ReadDirection(); //reader.Skip(5); //var minX = reader.ReadUShort(); //var minY = reader.ReadUShort(); //var maxX = reader.ReadUShort(); //var maxY = reader.ReadUShort(); //MapBoundary = new MapBoundary(minX, minY, maxX, maxY); }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(3); GumpId = new GumpInstanceId(reader.ReadUInt()); GumpTypeId = new GumpTypeId(reader.ReadUInt()); X = reader.ReadUInt(); Y = reader.ReadUInt(); var commandSectionLength = reader.ReadUShort(); Commands = reader.ReadString(commandSectionLength); var textLinesCount = reader.ReadUShort(); TextLines = new string[textLinesCount]; for (var i = 0; i < textLinesCount; i++) { var textLength = reader.ReadUShort(); TextLines[i] = reader.ReadUnicodeString(textLength); } }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.ReadByte(); reader.ReadUShort(); Type = (SpeechType)reader.ReadByte(); Color = reader.ReadUShort(); Font = reader.ReadUShort(); Language = reader.ReadString(4); if (((int)Type & 0xC0) != 0) { ushort rawBytes = reader.ReadUShort(); int keywordCount = (rawBytes & 0x0FFF) >> 4; if (keywordCount > 0) { reader.ReadByte(); keywordCount--; } while (keywordCount != 0) { reader.ReadUShort(); keywordCount--; } Text = reader.ReadNullTerminatedString(); } else { Text = reader.ReadNullTerminatedUnicodeString(); } }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(3); uint rawId = reader.ReadUInt(); ushort rawType = reader.ReadUShort(); uint finalId; if ((rawId & 0x80000000) != 0) { finalId = rawId - 0x80000000; Amount = reader.ReadUShort(); } else { Amount = 1; finalId = rawId; } Id = new ObjectId(finalId); if ((rawType & 0x8000) != 0) { throw new PacketParsingException(rawPacket, "Not implementated: Type & 0x8000"); } Type = rawType; ushort xloc = reader.ReadUShort(); ushort yloc = reader.ReadUShort(); if ((xloc & 0x8000) != 0) { xloc -= 0x8000; (Facing, _) = reader.ReadDirection(); } sbyte zloc = reader.ReadSByte(); if ((yloc & 0x8000) != 0) { yloc -= 0x8000; Dye = (Color)reader.ReadUShort(); } if ((yloc & 0x4000) != 0) { yloc -= 0x4000; Flags = (ObjectFlag)reader.ReadByte(); } Location = new Location3D(xloc, yloc, zloc); }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(1); PlayerId = reader.ReadObjectId(); MaxHealth = reader.ReadUShort(); CurrentHealth = reader.ReadUShort(); }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(1); var length = reader.ReadUShort(); Type = (SpeechType)reader.ReadByte(); Color = reader.ReadColor(); SpeechFont = reader.ReadUShort(); Message = reader.ReadString(length - 8); }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(2); Id = reader.ReadUShort(); reader.Skip(2); var x = reader.ReadUShort(); var y = reader.ReadUShort(); Location = new Location3D(x, y, 0); }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(1); PlayerId = reader.ReadObjectId(); Type = reader.ReadModelId(); Location = new Location3D(reader.ReadUShort(), reader.ReadUShort(), reader.ReadSByte()); (Direction, MovementType) = reader.ReadDirection(); Color = reader.ReadColor(); Flags = reader.ReadByte(); }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(3); Id = reader.ReadObjectId(); Model = reader.ReadModelId(); Type = (SpeechType)reader.ReadByte(); Color = (Color)reader.ReadUShort(); Font = reader.ReadUShort(); Name = reader.ReadString(30); Message = reader.ReadNullTerminatedString(); }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(1); SequenceKey = reader.ReadByte(); ushort xloc = reader.ReadUShort(); ushort yloc = reader.ReadUShort(); (Direction, MovementType) = reader.ReadDirection(); sbyte zloc = reader.ReadSByte(); Location = new Location3D(xloc, yloc, zloc); }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(1); ItemId = reader.ReadObjectId(); Type = reader.ReadModelId(); reader.Skip(1); Amount = reader.ReadUShort(); Location = new Location2D(reader.ReadUShort(), reader.ReadUShort()); ContainerId = reader.ReadObjectId(); Color = (Color)reader.ReadUShort(); }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(3); DialogId = reader.ReadUInt(); MenuId = reader.ReadUShort(); var questionLength = reader.ReadByte(); Question = reader.ReadString(questionLength); var responsesCount = reader.ReadByte(); if (responsesCount == byte.MaxValue) { throw new PacketParsingException(rawPacket, $"Responses count is {responsesCount}. Cannot have byte 1 based index for all responses (last index would be 256 which cannot be encoded to a single byte)."); } Responses = new DialogBoxResponse[responsesCount]; for (byte i = 0; i < responsesCount; i++) { var modelId = reader.ReadModelId(); var color = reader.ReadColor(); var responseTextLength = reader.ReadByte(); var responseText = reader.ReadString(responseTextLength); Responses[i] = new DialogBoxResponse((byte)(i + 1), modelId, color, responseText); } }
protected override void DeserializeTypeAndColor(ArrayPacketReader reader, ref ushort type, ref Color?color) { if ((type & 0x8000) != 0) { type -= 0x8000; } color = (Color)reader.ReadUShort(); }
public override void Deserialize(Packet rawPacket) { _rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(3); Serial = reader.ReadUInt(); BoatSpeed = reader.ReadByte(); (MovingDirection, _) = reader.ReadDirection(); (FacingDirection, _) = reader.ReadDirection(); ushort x = reader.ReadUShort(); ushort y = reader.ReadUShort(); ushort z = reader.ReadUShort(); int count = reader.ReadUShort(); PositionEntities = new PositionEntity[count]; for (int i = 0; i < count; i++) { uint cSerial = reader.ReadUInt(); ushort cx = reader.ReadUShort(); ushort cy = reader.ReadUShort(); ushort cz = reader.ReadUShort(); PositionEntities[i] = new PositionEntity(cSerial, new Location3D(cx, cy, 0)); } }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(4); Id = reader.ReadObjectId(); Type = reader.ReadModelId(); Facing = (Direction)reader.ReadByte(); Amount = reader.ReadUShort(); reader.ReadUShort(); // second amount? Location = new Location3D(reader.ReadUShort(), reader.ReadUShort(), reader.ReadSByte()); Layer = reader.ReadLayer(); Color = reader.ReadColor(); reader.ReadByte(); // flags }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(1); ChosenServerId = reader.ReadUShort(); }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(1); var activeByte = reader.ReadByte(); if (activeByte != 0 && activeByte != 1) { throw new NotSupportedException($"QuestArrowPacket.Active has unsupported value: {activeByte}"); } Active = activeByte != 0; Location = new Location2D(reader.ReadUShort(), reader.ReadUShort()); }
public override void Deserialize(Packet rawPacket) { var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(1); GameServerIp = new byte[4]; reader.Read(GameServerIp, 0, 4); GameServerPort = reader.ReadUShort(); payload = rawPacket.Payload; }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(1); DirectionType = (EffectDirectionType)reader.ReadByte(); CharacterId = reader.ReadObjectId(); TargetId = reader.ReadObjectId(); Type = reader.ReadModelId(); Location = new Location3D(reader.ReadUShort(), reader.ReadUShort(), reader.ReadSByte()); TargetLocation = new Location3D(reader.ReadUShort(), reader.ReadUShort(), reader.ReadSByte()); AnimationSpeed = reader.ReadByte(); AdjustDirection = reader.ReadBool(); ExplodeOnImpact = reader.ReadBool(); }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(1); var packetSize = reader.ReadUShort(); SpeakerId = reader.ReadObjectId(); SpeakerBody = reader.ReadModelId(); reader.ReadByte(); // type Color = reader.ReadColor(); Font = reader.ReadUShort(); MessageId = new MessageId(reader.ReadInt()); Name = reader.ReadString(30); Arguments = reader.ReadNullTerminatedUnicodeString(); }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.ReadByte(); ushort packetSize = reader.ReadUShort(); byte type = reader.ReadByte(); var values = new List <SkillValue>(); ushort skillNumber; ushort value; ushort unmodifiedValue; bool isLocked = false; switch (type) { case 0x00: case 0x02: case 0xDF: while (reader.Position < packetSize && (skillNumber = reader.ReadUShort()) != 0) { value = reader.ReadUShort(); unmodifiedValue = reader.ReadUShort(); isLocked = reader.ReadBool(); ushort cap = 0; if (type == 0x02 || type == 0xDF) { cap = reader.ReadUShort(); } values.Add(new SkillValue((Skill)skillNumber, value, unmodifiedValue, cap, isLocked)); } break; case 0xFF: skillNumber = reader.ReadUShort(); var skill = skillNumber != 0 ? (Skill)(skillNumber + 1) : Skill.Alchemy; value = reader.ReadUShort(); unmodifiedValue = reader.ReadUShort(); isLocked = reader.ReadBool(); values.Add(new SkillValue(skill, value, unmodifiedValue, 0, isLocked)); break; default: throw new NotImplementedException($"Unknown type {type} of SendSkills packet."); } Values = values.ToArray(); }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(1); CursorTarget = (CursorTarget)reader.ReadByte(); CursorId = new CursorId(reader.ReadUInt()); CursorType = (CursorType)reader.ReadByte(); ClickedOnId = reader.ReadObjectId(); ushort xloc = reader.ReadUShort(); ushort yloc = reader.ReadUShort(); byte unknown = reader.ReadByte(); sbyte zloc = reader.ReadSByte(); Location = new Location3D(xloc, yloc, zloc); ClickedOnType = reader.ReadModelId(); }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(3); Id = reader.ReadObjectId(); Type = reader.ReadModelId(); Location = new Location3D(reader.ReadUShort(), reader.ReadUShort(), reader.ReadSByte()); (Direction, MovementType) = reader.ReadDirection(); Color = (Color)reader.ReadUShort(); Flags = reader.ReadByte(); Notoriety = (Notoriety)reader.ReadByte(); var items = new List <Item>(); var itemId = reader.ReadUInt(); while (itemId != 0x00000000) { var type = reader.ReadUShort(); var layer = (Layer)reader.ReadByte(); Color?color = null; if ((type & 0x8000) != 0) { type -= 0x8000; color = (Color)reader.ReadUShort(); } var item = new Item(new ObjectId(itemId), new ModelId(type), 1, new Location3D(0, 0, 0), containerId: Id, layer: layer, color: color); items.Add(item); itemId = reader.ReadUInt(); } Items = items.ToArray(); }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(1); var size = reader.ReadUShort(); GumpId = (GumpInstanceId)reader.ReadUInt(); GumpTypeId = (GumpTypeId)reader.ReadUInt(); X = reader.ReadInt(); Y = reader.ReadInt(); int clen = reader.ReadInt() - 4; int dlen = (int)reader.ReadUInt(); byte[] data = new byte[clen]; reader.Read(data, 0, clen); byte[] decData = new byte[dlen]; Decompress(data, 0, decData, dlen); Commands = Encoding.UTF8.GetString(decData); uint linesNum = reader.ReadUInt(); if (linesNum > 0) { clen = reader.ReadInt() - 4; dlen = reader.ReadInt(); data = new byte[clen]; reader.Read(data, 0, clen); decData = new byte[dlen]; Decompress(data, 0, decData, dlen); TextLines = new string[linesNum]; for (int i = 0, index = 0; i < linesNum; i++) { int length = (decData[index++] << 8) | decData[index++]; byte[] text = new byte[length * 2]; Buffer.BlockCopy(decData, index, text, 0, text.Length); index += text.Length; TextLines[i] = Encoding.BigEndianUnicode.GetString(text); } } else { TextLines = Array.Empty <string>(); } }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(3); var count = reader.ReadUShort(); Servers = new ServerListItem[count]; for (int i = 0; i < count; i++) { var id = reader.ReadUShort(); var name = reader.ReadString(32); var fullPercent = reader.ReadByte(); var timeZone = reader.ReadByte(); var ip = reader.ReadUInt(); Servers[i] = new ServerListItem(id, name, fullPercent, timeZone, ip); } }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(1); PlayerId = reader.ReadObjectId(); BodyType = reader.ReadModelId(); reader.Skip(1); // unknown Color = reader.ReadColor(); Flags = reader.ReadByte(); var xloc = reader.ReadUShort(); var yloc = reader.ReadUShort(); reader.Skip(2); // unknown (Direction, MovementType) = reader.ReadDirection(); var zloc = reader.ReadSByte(); Location = new Location3D(xloc, yloc, zloc); }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(1); ContainerId = reader.ReadObjectId(); GumpModel = reader.ReadModelId(); if (protocolVersion >= 7090) { reader.ReadUShort(); } }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(3); SpeakerId = reader.ReadObjectId(); SpeakerBody = reader.ReadModelId(); Type = (SpeechType)reader.ReadByte(); Color = reader.ReadColor(); Font = reader.ReadUShort(); MessageId = new MessageId(reader.ReadInt()); reader.ReadByte(); // ignoring flags Name = reader.ReadString(30); Affix = reader.ReadNullTerminatedString(); }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(3); byte type = reader.ReadByte(); var values = new List <SkillValue>(); ushort skillNumber; ushort value; ushort unmodifiedValue; switch (type) { case 0x00: skillNumber = reader.ReadUShort(); while (skillNumber != 0) { value = reader.ReadUShort(); unmodifiedValue = reader.ReadUShort(); reader.Skip(1); // skill lock values.Add(new SkillValue((Skill)skillNumber, value, unmodifiedValue)); skillNumber = reader.ReadUShort(); } break; case 0xFF: skillNumber = reader.ReadUShort(); var skill = skillNumber != 0 ? (Skill)(skillNumber + 1) : Skill.None; value = reader.ReadUShort(); unmodifiedValue = reader.ReadUShort(); reader.Skip(1); // skill lock values.Add(new SkillValue(skill, value, unmodifiedValue)); break; default: throw new NotImplementedException($"Unknown type {type} of SendSkills packet."); } Values = values.ToArray(); }
public override void Deserialize(Packet rawPacket) { this.rawPacket = rawPacket; var reader = new ArrayPacketReader(rawPacket.Payload); reader.Skip(1); MapId = reader.ReadObjectId(); MapArt = reader.ReadModelId(); UpperLeft = new Location2D(reader.ReadUShort(), reader.ReadUShort()); LowerRight = new Location2D(reader.ReadUShort(), reader.ReadUShort()); Width = reader.ReadUShort(); Height = reader.ReadUShort(); }