public static void WriteChatString(this StreamHandler Writer, string text) { byte[] bytes = Encoding.UTF8.GetBytes(text); Writer.WriteInt32(bytes.Length + 1); Writer.WriteBytes(bytes); Writer.WriteByte(0); }
public override void Save(StreamHandler writer) { writer.WriteInt32(Items.Length); foreach (var item in Items) writer.WriteStruct(item); writer.WriteUInt32(TotalItemCount); writer.WriteUInt32(NextSearchDelayMs); }
public override void Save(StreamHandler writer) { writer.WritePackedGuid(this.Unit); writer.WriteInt32(ThreatList.Length); for (int i = 0; i < ThreatList.Length; ++i) { writer.WritePackedGuid(ThreatList[i].Unit); writer.WriteUInt32(ThreatList[i].Threat); } }
public override void Save(StreamHandler writer) { writer.WritePackedGuid(this.Unit); writer.WriteInt32(ThreatList.Length); for (int i = 0; i < ThreatList.Length; ++i) { writer.WritePackedGuid(ThreatList[i].Unit); writer.WriteUInt32(ThreatList[i].Threat); } }
public override void Save(StreamHandler writer) { writer.WriteInt32(Items.Length); foreach (var item in Items) { writer.WriteStruct(item); } writer.WriteUInt32(TotalItemCount); writer.WriteUInt32(NextSearchDelayMs); }
protected override void ElementWrite(StreamHandler writer, int index) { if (index == -5) { writer.WriteUInt32(this.Unk); } else { index = -index - 1; writer.WriteInt32(this.Data[index].Length); writer.WriteBytes(this.Data[index]); } }
protected override void ElementWrite(StreamHandler writer, int index) { if (index == -5) { writer.WriteUInt32(this.Unk); } else { index = -index - 1; writer.WriteInt32(this.Data[index].Length); writer.WriteBytes(this.Data[index]); } }
public void Save(StreamHandler writer) { writer .WriteByte(this.Slot) .WriteUInt32(this.Spell); if (this.Spell != 0) { writer .WriteUInt16((ushort)this.Flags) .WriteByte(this.Level) .WriteByte(this.Charges); if ((Flags & AuraFlags.NotCaster) == 0) { writer.WritePackedGuid(this.Caster); } if ((Flags & AuraFlags.Duration) != 0) { writer.WriteUInt32(this.MaxDuration); writer.WriteUInt32(this.LeftDuration); } if ((Flags & AuraFlags.BasePoints) != 0) { for (int i = 0; i < MaxEffects; ++i) { if ((Flags & (AuraFlags)(1 << i)) != 0) { writer.WriteInt32(BasePoints[i]); } } } } }
/// <summary> /// Writes the spline info into the current stream, /// advancing the current position by spline info's size. /// </summary> public static void WriteSplineInfo(this StreamHandler Writer, SplineInfo Info) { Writer.WriteUInt32((uint)Info.Flags); if ((Info.Flags & SplineFlags.FinalPoint) != SplineFlags.None) { Writer.WriteStruct <Vector3>(Info.FinalPoint); } if ((Info.Flags & SplineFlags.FinalTarget) != SplineFlags.None) { Writer.WriteGuid(Info.FinalGuid); } if ((Info.Flags & SplineFlags.FinalOrient) != SplineFlags.None) { Writer.WriteSingle(Info.FinalRotation); } Writer.WriteUInt32(Info.CurrentTime); Writer.WriteUInt32(Info.FullTime); Writer.WriteUInt32(Info.Unknown1); Writer.WriteSingle(Info.DurationMultiplier); Writer.WriteSingle(Info.UnknownFloat2); Writer.WriteSingle(Info.UnknownFloat3); Writer.WriteUInt32(Info.Unknown2); Writer.WriteInt32(Info.Points.Count); for (int i = 0; i < Info.Points.Count; ++i) { Writer.WriteStruct <Vector3>(Info.Points[i]); } Writer.WriteByte((byte)Info.SplineMode); Writer.WriteStruct <Vector3>(Info.EndPoint); }
public override void Save(StreamHandler Writer) { Writer.WriteUInt16((ushort)this.Map); EnsureRead(); long nUpdatesPos = Writer.BaseStream.Position; uint nUpdates = 0; Writer.WriteUInt32(nUpdates); if (this.DestroyedObjects.Count > 0) { ++nUpdates; Writer.WriteByte((byte)UpdateTypes.DestroyObjects); Writer.WriteInt32(this.DestroyedObjects.Count); foreach (WowGuid guid in this.DestroyedObjects) { Writer.WritePackedGuid(guid); } } foreach (var pair in this.ValuesUpdates) { ++nUpdates; Writer.WriteByte((byte)UpdateTypes.UpdateValues); Writer.WritePackedGuid(pair.Key); WriteValues(Writer, pair.Value, WowObject.GetTypeId(pair.Key.Type)); } foreach (var pair in this.CreatedObjects) { ++nUpdates; var type = UpdateTypes.CreateObjects; var obj = pair.Value; if (obj.MovementData.HavePosition) { if (obj.TypeId == ObjectTypeId.DynamicObject || obj.TypeId == ObjectTypeId.Corpse || obj.TypeId == ObjectTypeId.Player) { type = UpdateTypes.CreateObjects2; } if (obj.TypeId == ObjectTypeId.GameObject && obj is WowGameObject) { switch ((obj as WowGameObject).GameObjectType) { case GameObjectTypes.Trap: case GameObjectTypes.DuelArbiter: case GameObjectTypes.FlagStand: case GameObjectTypes.FlagDrop: type = UpdateTypes.CreateObjects2; break; } } } var guid = obj.Guid; Writer.WriteByte((byte)type); Writer.WritePackedGuid(guid); Writer.WriteByte((byte)obj.TypeId); obj.MovementData.Save(Writer); WriteValues(Writer, obj.GetValues(), obj.TypeId); } long pos = Writer.BaseStream.Position; Writer.BaseStream.Position = nUpdatesPos; Writer.WriteUInt32(nUpdates); Writer.BaseStream.Position = pos; }
protected override unsafe void InternalWriteMetaData() { m_stream.DoAt(m_streamOriginalPosition, () => { var bytes = new byte[MainHeader.Size]; byte[] extraData; using (var writer = new StreamHandler()) { var flags = this.ExtraInfoFlags; if (flags.HasFlag(ExtraDataFlags.HasClientIPv4) || flags.HasFlag(ExtraDataFlags.HasClientIPv6)) { writer.WriteBytes(this.ClientAddress.GetAddressBytes()); } if (flags.HasFlag(ExtraDataFlags.HasServerIPv4) || flags.HasFlag(ExtraDataFlags.HasServerIPv6)) { writer.WriteBytes(this.ServerAddress.GetAddressBytes()); } if (flags.HasFlag(ExtraDataFlags.HasClientPort)) { writer.WriteInt32(this.ClientPort); } if (flags.HasFlag(ExtraDataFlags.HasServerPort)) { writer.WriteInt32(this.ServerPort); } if (flags.HasFlag(ExtraDataFlags.HasSnifferIdString)) { byte[] arr = Encoding.UTF8.GetBytes(this.SnifferDesc ?? string.Empty); writer.WriteInt32(arr.Length); using (MemoryStream oStream = new MemoryStream()) { // BUG http://blogs.msdn.com/b/bclteam/archive/2006/05/10/592551.aspx using (var ds = new DeflateStream(oStream, CompressionMode.Compress, true)) ds.Write(arr, 0, arr.Length); arr = oStream.ToArray(); } writer.WriteInt32(arr.Length); writer.WriteBytes(arr); } extraData = writer.ToByteArray(); } fixed(byte *bytesPtr = bytes) { var header = (MainHeader *)bytesPtr; header->PacketCount = this.Count; Marshal.Copy(SignatureBytes, 0, new IntPtr(header->Signature), SignatureBytes.Length); header->StartedOnTicks = this.StartTicks; header->StartedOnUnix = this.StartTime.ToUnixTime(); header->ExtraDataLength = extraData.Length; header->ExtraInfoFlags = this.ExtraInfoFlags; } m_stream.WriteBytes(bytes); m_stream.WriteBytes(extraData); }); }
protected unsafe override void InternalWriteMetaData() { m_stream.DoAt(m_streamOriginalPosition, () => { var bytes = new byte[MainHeader.Size]; byte[] extraData; using (var writer = new StreamHandler()) { var flags = this.ExtraInfoFlags; if (flags.HasFlag(ExtraDataFlags.HasClientIPv4) || flags.HasFlag(ExtraDataFlags.HasClientIPv6)) writer.WriteBytes(this.ClientAddress.GetAddressBytes()); if (flags.HasFlag(ExtraDataFlags.HasServerIPv4) || flags.HasFlag(ExtraDataFlags.HasServerIPv6)) writer.WriteBytes(this.ServerAddress.GetAddressBytes()); if (flags.HasFlag(ExtraDataFlags.HasClientPort)) writer.WriteInt32(this.ClientPort); if (flags.HasFlag(ExtraDataFlags.HasServerPort)) writer.WriteInt32(this.ServerPort); if (flags.HasFlag(ExtraDataFlags.HasSnifferIdString)) { byte[] arr = Encoding.UTF8.GetBytes(this.SnifferDesc ?? string.Empty); writer.WriteInt32(arr.Length); using (MemoryStream oStream = new MemoryStream()) { // BUG http://blogs.msdn.com/b/bclteam/archive/2006/05/10/592551.aspx using (var ds = new DeflateStream(oStream, CompressionMode.Compress, true)) ds.Write(arr, 0, arr.Length); arr = oStream.ToArray(); } writer.WriteInt32(arr.Length); writer.WriteBytes(arr); } extraData = writer.ToByteArray(); } fixed (byte* bytesPtr = bytes) { var header = (MainHeader*)bytesPtr; header->PacketCount = this.Count; Marshal.Copy(SignatureBytes, 0, new IntPtr(header->Signature), SignatureBytes.Length); header->StartedOnTicks = this.StartTicks; header->StartedOnUnix = this.StartTime.ToUnixTime(); header->ExtraDataLength = extraData.Length; header->ExtraInfoFlags = this.ExtraInfoFlags; } m_stream.WriteBytes(bytes); m_stream.WriteBytes(extraData); }); }
public override void Save(StreamHandler Writer) { Writer.WriteUInt16((ushort)this.Map); EnsureRead(); long nUpdatesPos = Writer.BaseStream.Position; uint nUpdates = 0; Writer.WriteUInt32(nUpdates); if (this.DestroyedObjects.Count > 0) { ++nUpdates; Writer.WriteByte((byte)UpdateTypes.DestroyObjects); Writer.WriteInt32(this.DestroyedObjects.Count); foreach (WowGuid guid in this.DestroyedObjects) Writer.WritePackedGuid(guid); } foreach (var pair in this.ValuesUpdates) { ++nUpdates; Writer.WriteByte((byte)UpdateTypes.UpdateValues); Writer.WritePackedGuid(pair.Key); WriteValues(Writer, pair.Value, WowObject.GetTypeId(pair.Key.Type)); } foreach (var pair in this.CreatedObjects) { ++nUpdates; var type = UpdateTypes.CreateObjects; var obj = pair.Value; if (obj.MovementData.HavePosition) { if (obj.TypeId == ObjectTypeId.DynamicObject || obj.TypeId == ObjectTypeId.Corpse || obj.TypeId == ObjectTypeId.Player) { type = UpdateTypes.CreateObjects2; } if (obj.TypeId == ObjectTypeId.GameObject && obj is WowGameObject) { switch ((obj as WowGameObject).GameObjectType) { case GameObjectTypes.Trap: case GameObjectTypes.DuelArbiter: case GameObjectTypes.FlagStand: case GameObjectTypes.FlagDrop: type = UpdateTypes.CreateObjects2; break; } } } var guid = obj.Guid; Writer.WriteByte((byte)type); Writer.WritePackedGuid(guid); Writer.WriteByte((byte)obj.TypeId); obj.MovementData.Save(Writer); WriteValues(Writer, obj.GetValues(), obj.TypeId); } long pos = Writer.BaseStream.Position; Writer.BaseStream.Position = nUpdatesPos; Writer.WriteUInt32(nUpdates); Writer.BaseStream.Position = pos; }
public void Save(StreamHandler writer) { writer .WriteByte(this.Slot) .WriteUInt32(this.Spell); if (this.Spell != 0) { writer .WriteUInt16((ushort)this.Flags) .WriteByte(this.Level) .WriteByte(this.Charges); if ((Flags & AuraFlags.NotCaster) == 0) writer.WritePackedGuid(this.Caster); if ((Flags & AuraFlags.Duration) != 0) { writer.WriteUInt32(this.MaxDuration); writer.WriteUInt32(this.LeftDuration); } if ((Flags & AuraFlags.BasePoints) != 0) { for (int i = 0; i < MaxEffects; ++i) { if ((Flags & (AuraFlags)(1 << i)) != 0) writer.WriteInt32(BasePoints[i]); } } } }