/// <summary> /// Writes the packed value into the current stream and advances /// the current position of the stream by packed value size. /// </summary> public static void WritePackedValue(this StreamHandler Writer, ulong value) { long pos = Writer.BaseStream.Position; byte mask = 0; Writer.WriteByte(mask); if (value == 0) { return; } for (byte bit = 1; value != 0; bit <<= 1, value >>= 8) { if ((value & 0xFF) != 0) { mask |= bit; Writer.WriteByte((byte)(value & 0xFF)); } } long cpos = Writer.BaseStream.Position; Writer.BaseStream.Position = pos; Writer.WriteByte(mask); Writer.BaseStream.Position = cpos; }
public void Write(StreamHandler Writer) { Writer.WriteGuid(TargetGuid); Writer.WriteByte((byte)MissCondition); if (MissCondition == CastMissReason.Reflect) { Writer.WriteByte(ReflectResult); } }
/// <summary> /// Saves the current instance of SpellCast class to a StreamHandler, using the provided target flags. /// </summary> /// <param name="writer">The StreamHandler to use.</param> public override void Save(StreamHandler writer) { writer.WriteByte(CastId); writer.WriteUInt32(SpellId); writer.WriteUInt32(UnknownId); writer.WriteByte(UnknownFlags); TargetData.Write(writer); }
public override void Save(StreamHandler writer) { writer.WriteByte((byte)ContainerSlot); writer.WriteByte((byte)Slot); writer.WriteByte(CastId); writer.WriteUInt32(SpellId); writer.WriteGuid(ItemGuid); writer.WriteUInt32(GlyphSlot); writer.WriteByte(UnkFlags); TargetData.Write(writer); }
public override void Save(StreamHandler writer) { writer.WriteByte((byte)ContainerSlot); writer.WriteByte((byte)Slot); writer.WriteByte(CastId); writer.WriteUInt32(SpellId); writer.WriteGuid(ItemGuid); writer.WriteUInt32(GlyphSlot); writer.WriteByte(UnkFlags); TargetData.Write(writer); }
public override void Save(StreamHandler writer) { writer.WriteGuid(Entity); writer.WriteUInt32(Model); writer.WriteByte((byte)Race); writer.WriteByte((byte)Gender); writer.WriteByte((byte)Class); writer.WriteByte(Skin); writer.WriteByte(Face); writer.WriteByte(Hair); writer.WriteByte(HairColor); writer.WriteByte(FaceFeatures); writer.WriteGuid(Guild); writer.WriteUInt32(Head); writer.WriteUInt32(Shoulders); writer.WriteUInt32(Body); writer.WriteUInt32(Chest); writer.WriteUInt32(Waist); writer.WriteUInt32(Legs); writer.WriteUInt32(Feet); writer.WriteUInt32(Wrists); writer.WriteUInt32(Hands); writer.WriteUInt32(Back); writer.WriteUInt32(Tabard); }
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.WriteUInt32((uint)Roles); writer.WriteUInt16(0); writer.WriteByte((byte)Dungeons.Length); foreach (var entry in Dungeons) writer.WriteUInt32(entry.Entry); writer.WriteByte(3); writer.WriteUInt16(0); writer.WriteByte(0); writer.WriteCString(Comment); }
protected void WriteByteSeq(StreamHandler writer, byte b) { writer.FlushUnalignedBits(); if (b != 0) { writer.WriteByte((byte)(b ^ 1)); } }
public override void Save(StreamHandler writer) { writer.WriteUInt32((uint)Roles); writer.WriteUInt16(0); writer.WriteByte((byte)Dungeons.Length); foreach (var entry in Dungeons) { writer.WriteUInt32(entry.Entry); } writer.WriteByte(3); writer.WriteUInt16(0); writer.WriteByte(0); writer.WriteCString(Comment); }
public override void Save(StreamHandler writer) { writer.WriteUInt32(Dungeon.Entry); writer.WriteByte((byte)State); writer.WriteUInt32(ProposalId); writer.WriteUInt32(BossesKilled); writer.WriteBoolean(SameDungeon); writer.WriteByte((byte)Players.Length); foreach (var info in Players) { writer.WriteUInt32((uint)info.Role); writer.WriteBoolean(info.SelfPlayer); writer.WriteBoolean(info.InDungeon); writer.WriteBoolean(info.SameGroup); writer.WriteBoolean(info.Answered); writer.WriteBoolean(info.Accepted); } }
public override void Save(StreamHandler writer) { writer.WriteByte((byte)UpdateType); writer.WriteBoolean(ExtraData); if (ExtraData) { writer.WriteBoolean(Queued); writer.WriteUInt16(0); writer.WriteByte((byte)Dungeons.Length); foreach (var entry in Dungeons) { writer.WriteUInt32(entry.Entry); } writer.WriteCString(Comment); } }
public override void Save(StreamHandler Writer) { Writer.WritePackedGuid(Caster); Writer.WritePackedGuid(CastInvoker); Writer.WriteByte(CastId); Writer.WriteUInt32(SpellId); Writer.WriteUInt32((uint)Flags); Writer.WriteUInt32(Unk43); Writer.WriteUInt32(Unk43_2); TargetData.Write(Writer); if ((Flags & CastFlags.PredictedPower) != 0) { Writer.WriteUInt32(PredictedPower); } if ((Flags & CastFlags.RuneStates) != 0) { Writer.WriteByte((byte)RunesBefore); Writer.WriteByte((byte)RunesAfter); for (int i = 0; i < RuneCooldowns.Length; ++i) { Writer.WriteByte((byte)RuneCooldowns[i]); } } if ((Flags & CastFlags.Ammo) != 0) { Writer.WriteUInt32(ProjectileDisplayId); Writer.WriteUInt32((uint)ProjectileInventoryType); } if ((Flags & CastFlags.Unk0x04000000) != 0) { Writer.WriteUInt32(Unk0x04000000_UInt32_1); Writer.WriteUInt32(Unk0x04000000_UInt32_2); } }
public static StreamHandler WriteXorByte(this StreamHandler writer, byte value) { if (writer == null) { throw new ArgumentNullException("reader"); } if (value != 0) { writer.WriteByte((byte)(value ^ 1)); } return(writer); }
private void WriteValues(StreamHandler Writer, UpdateFields values, ObjectTypeId type) { uint nValueUpdates = UpdateFields.GetCount(type, values.Last().Key); byte nBlocks = (byte)((nValueUpdates + 31) / 32); BitArray mask = new BitArray(nBlocks * 32); foreach (int key in values.Keys) { mask[key] = true; } // Write block count Writer.WriteByte(nBlocks); // Write all blocks int index = 0; for (byte i = 0; i < nBlocks; ++i) { uint block = 0; uint bit = 1; for (int j = 0; j < 32; ++j) { if (mask[index]) { block |= bit; } ++index; bit <<= 1; } Writer.WriteUInt32(block); } // Write all values foreach (uint value in values.Values) { Writer.WriteUInt32(value); } }
/// <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 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]); } } } } }
public override void Save(StreamHandler Writer) { Writer.WritePackedGuid(Caster); Writer.WritePackedGuid(CastInvoker); Writer.WriteByte(CastId); Writer.WriteUInt32(SpellId); Writer.WriteUInt32((uint)Flags); Writer.WriteUInt32(Unk43); Writer.WriteUInt32(Unk43_2); TargetData.Write(Writer); if ((Flags & CastFlags.PredictedPower) != 0) Writer.WriteUInt32(PredictedPower); if ((Flags & CastFlags.RuneStates) != 0) { Writer.WriteByte((byte)RunesBefore); Writer.WriteByte((byte)RunesAfter); for (int i = 0; i < RuneCooldowns.Length; ++i) Writer.WriteByte((byte)RuneCooldowns[i]); } if ((Flags & CastFlags.Ammo) != 0) { Writer.WriteUInt32(ProjectileDisplayId); Writer.WriteUInt32((uint)ProjectileInventoryType); } if ((Flags & CastFlags.Unk0x04000000) != 0) { Writer.WriteUInt32(Unk0x04000000_UInt32_1); Writer.WriteUInt32(Unk0x04000000_UInt32_2); } }
/// <summary> /// Saves the current instance of SpellGo class to a StreamHandler. /// </summary> /// <param name="Writer">The StreamHandler to use.</param> public override void Save(StreamHandler Writer) { Writer.WritePackedGuid(Caster); Writer.WritePackedGuid(CastInvoker); Writer.WriteByte(CastId); Writer.WriteUInt32(SpellId); Writer.WriteUInt32((uint)Flags); Writer.WriteUInt32(Unk43); Writer.WriteUInt32(CastTime); Writer.WriteByte((byte)Hits.Count); foreach (WowGuid guid in Hits) Writer.WriteGuid(guid); Writer.WriteByte((byte)Misses.Count); foreach (MissData miss in Misses) miss.Write(Writer); TargetData.Write(Writer); if ((Flags & CastFlags.PredictedPower) != 0) Writer.WriteUInt32(PredictedPower); if ((Flags & CastFlags.RuneStates) != 0) { Writer.WriteByte((byte)RunesBefore); Writer.WriteByte((byte)RunesAfter); for (int i = 0; i < RuneCooldowns.Length; ++i) Writer.WriteByte((byte)RuneCooldowns[i]); } if ((Flags & CastFlags.Unk0x00020000) != 0) { Writer.WriteSingle(Unk0x20000_Float); Writer.WriteUInt32(Unk0x20000_UInt32); } if ((Flags & CastFlags.Ammo) != 0) { Writer.WriteUInt32(ProjectileDisplayId); Writer.WriteUInt32((uint)ProjectileInventoryType); } if ((Flags & CastFlags.Unk0x00080000) != 0) { Writer.WriteUInt32(Unk0x80000_UInt32_1); Writer.WriteUInt32(Unk0x80000_UInt32_2); } if ((TargetData.Flags & SpellCastTargetFlags.DestLocation) != 0) { Writer.WriteByte(DestLocationCounter); } if ((TargetData.Flags & SpellCastTargetFlags.Unk4) != 0) { Writer.WriteUInt32(Unk4_Count); foreach (var pair in Unk4_List) { Writer.WriteStruct(pair.Value); Writer.WriteGuid(pair.Key); if (pair.Key.IsEmpty) break; } } }
public void Write(StreamHandler Writer) { Writer.WriteGuid(TargetGuid); Writer.WriteByte((byte)MissCondition); if (MissCondition == CastMissReason.Reflect) Writer.WriteByte(ReflectResult); }
/// <summary> /// Saves the current instance of SpellCast class to a StreamHandler, using the provided target flags. /// </summary> /// <param name="writer">The StreamHandler to use.</param> public override void Save(StreamHandler writer) { writer.WriteByte(CastId); writer.WriteUInt32(SpellId); writer.WriteUInt32(UnknownId); writer.WriteByte(UnknownFlags); TargetData.Write(writer); }
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]); } } } }
public override void Save(StreamHandler writer) { writer.WriteByte((byte)UpdateType); writer.WriteBoolean(ExtraData); if (ExtraData) { writer.WriteBoolean(Queued); writer.WriteUInt16(0); writer.WriteByte((byte)Dungeons.Length); foreach (var entry in Dungeons) writer.WriteUInt32(entry.Entry); writer.WriteCString(Comment); } }
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; }
private void WriteValues(StreamHandler Writer, UpdateFields values, ObjectTypeId type) { uint nValueUpdates = UpdateFields.GetCount(type, values.Last().Key); byte nBlocks = (byte)((nValueUpdates + 31) / 32); BitArray mask = new BitArray(nBlocks * 32); foreach (int key in values.Keys) mask[key] = true; // Write block count Writer.WriteByte(nBlocks); // Write all blocks int index = 0; for (byte i = 0; i < nBlocks; ++i) { uint block = 0; uint bit = 1; for (int j = 0; j < 32; ++j) { if (mask[index]) block |= bit; ++index; bit <<= 1; } Writer.WriteUInt32(block); } // Write all values foreach (uint value in values.Values) Writer.WriteUInt32(value); }
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; }
/// <summary> /// Saves the current ChatMessage to a stream using a StreamHandler. /// </summary> /// <param name="Writer"> /// Instance of StreamHandler used to save the current ChatMessage to a stream. /// </param> public override void Save(StreamHandler Writer) { Writer.WriteByte((byte)m_type); Writer.WriteUInt32((uint)m_language); Writer.WriteGuid(m_senderGUID); Writer.WriteUInt32(m_unknownUInt32); switch (m_type) { case ChatMessageType.MonsterSay: case ChatMessageType.MonsterParty: case ChatMessageType.MonsterYell: case ChatMessageType.MonsterWhisper: case ChatMessageType.MonsterEmote: case ChatMessageType.RaidBossEmote: case ChatMessageType.RaidBossWhisper: case ChatMessageType.BattleNet: Writer.WriteChatString(m_senderName ?? "<sender>"); Writer.WriteGuid(m_targetGUID); if (!m_targetGUID.IsEmpty && !m_targetGUID.IsPlayer && !m_targetGUID.IsPet) { Writer.WriteChatString(m_targetName ?? "<target>"); } if (m_language == Language.Addon) { Writer.WriteCString(m_addonPrefix ?? "<prefix>"); } Writer.WriteChatString(m_text ?? "<text>"); Writer.WriteByte((byte)m_flags); if (m_type == ChatMessageType.RaidBossEmote || m_type == ChatMessageType.RaidBossWhisper) { Writer.WriteSingle(m_displayTime); Writer.WriteBoolean(m_suspendEvent); } break; case ChatMessageType.BGSystemNeutral: case ChatMessageType.BGSystemAlliance: case ChatMessageType.BGSystemHorde: Writer.WriteGuid(m_targetGUID); if (!m_targetGUID.IsEmpty && !m_targetGUID.IsPlayer) { Writer.WriteChatString(m_targetName); } if (m_language == Language.Addon) { Writer.WriteCString(m_addonPrefix ?? "<prefix>"); } Writer.WriteChatString(m_text ?? "<text>"); Writer.WriteByte((byte)m_flags); break; case ChatMessageType.Achievement: case ChatMessageType.GuildAchievement: Writer.WriteGuid(m_targetGUID); if (m_language == Language.Addon) { Writer.WriteCString(m_addonPrefix ?? "<prefix>"); } Writer.WriteChatString(m_text ?? "<text>"); Writer.WriteByte((byte)m_flags); Writer.WriteUInt32(m_achievementId); break; case ChatMessageType.WhisperForeign: Writer.WriteChatString(m_senderName ?? "<sender>"); Writer.WriteGuid(m_targetGUID); if (m_language == Language.Addon) { Writer.WriteCString(m_addonPrefix ?? "<prefix>"); } Writer.WriteChatString(m_text ?? "<text>"); Writer.WriteByte((byte)m_flags); break; default: if (GameMasterMessage) { Writer.WriteChatString(m_senderName ?? "<sender>"); } if (m_type == ChatMessageType.Channel) { Writer.WriteCString(m_channel ?? "<channel>"); } Writer.WriteGuid(m_targetGUID); if (m_language == Language.Addon) { Writer.WriteCString(m_addonPrefix ?? "<prefix>"); } Writer.WriteChatString(m_text ?? "<text>"); Writer.WriteByte((byte)m_flags); break; } }
/// <summary> /// Saves the current instance of SpellGo class to a StreamHandler. /// </summary> /// <param name="Writer">The StreamHandler to use.</param> public override void Save(StreamHandler Writer) { Writer.WritePackedGuid(Caster); Writer.WritePackedGuid(CastInvoker); Writer.WriteByte(CastId); Writer.WriteUInt32(SpellId); Writer.WriteUInt32((uint)Flags); Writer.WriteUInt32(Unk43); Writer.WriteUInt32(CastTime); Writer.WriteByte((byte)Hits.Count); foreach (WowGuid guid in Hits) { Writer.WriteGuid(guid); } Writer.WriteByte((byte)Misses.Count); foreach (MissData miss in Misses) { miss.Write(Writer); } TargetData.Write(Writer); if ((Flags & CastFlags.PredictedPower) != 0) { Writer.WriteUInt32(PredictedPower); } if ((Flags & CastFlags.RuneStates) != 0) { Writer.WriteByte((byte)RunesBefore); Writer.WriteByte((byte)RunesAfter); for (int i = 0; i < RuneCooldowns.Length; ++i) { Writer.WriteByte((byte)RuneCooldowns[i]); } } if ((Flags & CastFlags.Unk0x00020000) != 0) { Writer.WriteSingle(Unk0x20000_Float); Writer.WriteUInt32(Unk0x20000_UInt32); } if ((Flags & CastFlags.Ammo) != 0) { Writer.WriteUInt32(ProjectileDisplayId); Writer.WriteUInt32((uint)ProjectileInventoryType); } if ((Flags & CastFlags.Unk0x00080000) != 0) { Writer.WriteUInt32(Unk0x80000_UInt32_1); Writer.WriteUInt32(Unk0x80000_UInt32_2); } if ((TargetData.Flags & SpellCastTargetFlags.DestLocation) != 0) { Writer.WriteByte(DestLocationCounter); } if ((TargetData.Flags & SpellCastTargetFlags.Unk4) != 0) { Writer.WriteUInt32(Unk4_Count); foreach (var pair in Unk4_List) { Writer.WriteStruct(pair.Value); Writer.WriteGuid(pair.Key); if (pair.Key.IsEmpty) { break; } } } }
public sealed override void Save(StreamHandler writer) { var seq_b = ByteSequence; var seq_m = MaskSequence; var b_xor = ByteXorValue; int size = seq_m.Count(x => x >= 0); if (size != seq_m.Length && this.IsMaskSequenceSwapped) { throw new InvalidOperationException("Cannot have elements in swapped MaskSequence."); } CheckSequences(seq_b, seq_m); if (this.IsMaskSequenceSwapped) { var seq_m_copy = new int[seq_m.Length]; for (int i = 0; i < seq_m.Length;) { var t = i; for (int j = t + 8 - 1; j >= t; --j, ++i) { seq_m_copy[j] = seq_m[i]; } } seq_m = seq_m_copy; } byte[] data = new byte[size]; PackedSave(data); var mask = new BitArray(size); for (int i = 0; i < size; ++i) { var el = seq_m[i]; if (el < 0) { ElementWrite(writer, el); } else { writer.UnalignedWriteBit(data[el] != 0); } } writer.FlushUnalignedBits(); for (int i = 0; i < seq_b.Length; ++i) { var el = seq_b[i]; if (el < 0) { ElementWrite(writer, el); } else if (data[el] != 0) { writer.WriteByte((byte)(data[el] ^ b_xor)); } } }
protected void WriteByteSeq(StreamHandler writer, byte b) { writer.FlushUnalignedBits(); if (b != 0) writer.WriteByte((byte)(b ^ 1)); }
public override void Save(StreamHandler writer) { writer.WriteGuid(Entity); writer.WriteUInt32(Model); writer.WriteByte((byte)Race); writer.WriteByte((byte)Gender); writer.WriteByte((byte)Class); writer.WriteByte(Skin); writer.WriteByte(Face); writer.WriteByte(Hair); writer.WriteByte(HairColor); writer.WriteByte(FaceFeatures); writer.WriteGuid(Guild); writer.WriteUInt32(Head); writer.WriteUInt32(Shoulders); writer.WriteUInt32(Body); writer.WriteUInt32(Chest); writer.WriteUInt32(Waist); writer.WriteUInt32(Legs); writer.WriteUInt32(Feet); writer.WriteUInt32(Wrists); writer.WriteUInt32(Hands); writer.WriteUInt32(Back); writer.WriteUInt32(Tabard); }
public sealed override void Save(StreamHandler writer) { var seq_b = ByteSequence; var seq_m = MaskSequence; var b_xor = ByteXorValue; int size = seq_m.Count(x => x >= 0); if (size != seq_m.Length && this.IsMaskSequenceSwapped) throw new InvalidOperationException("Cannot have elements in swapped MaskSequence."); CheckSequences(seq_b, seq_m); if (this.IsMaskSequenceSwapped) { var seq_m_copy = new int[seq_m.Length]; for (int i = 0; i < seq_m.Length; ) { var t = i; for (int j = t + 8 - 1; j >= t; --j, ++i) seq_m_copy[j] = seq_m[i]; } seq_m = seq_m_copy; } byte[] data = new byte[size]; PackedSave(data); var mask = new BitArray(size); for (int i = 0; i < size; ++i) { var el = seq_m[i]; if (el < 0) ElementWrite(writer, el); else writer.UnalignedWriteBit(data[el] != 0); } writer.FlushUnalignedBits(); for (int i = 0; i < seq_b.Length; ++i) { var el = seq_b[i]; if (el < 0) ElementWrite(writer, el); else if (data[el] != 0) writer.WriteByte((byte)(data[el] ^ b_xor)); } }
/// <summary> /// Saves the current ChatMessage to a stream using a StreamHandler. /// </summary> /// <param name="Writer"> /// Instance of StreamHandler used to save the current ChatMessage to a stream. /// </param> public override void Save(StreamHandler Writer) { Writer.WriteByte((byte)m_type); Writer.WriteUInt32((uint)m_language); Writer.WriteGuid(m_senderGUID); Writer.WriteUInt32(m_unknownUInt32); switch (m_type) { case ChatMessageType.MonsterSay: case ChatMessageType.MonsterParty: case ChatMessageType.MonsterYell: case ChatMessageType.MonsterWhisper: case ChatMessageType.MonsterEmote: case ChatMessageType.RaidBossEmote: case ChatMessageType.RaidBossWhisper: case ChatMessageType.BattleNet: Writer.WriteChatString(m_senderName ?? "<sender>"); Writer.WriteGuid(m_targetGUID); if (!m_targetGUID.IsEmpty && !m_targetGUID.IsPlayer && !m_targetGUID.IsPet) { Writer.WriteChatString(m_targetName ?? "<target>"); } if (m_language == Language.Addon) Writer.WriteCString(m_addonPrefix ?? "<prefix>"); Writer.WriteChatString(m_text ?? "<text>"); Writer.WriteByte((byte)m_flags); if (m_type == ChatMessageType.RaidBossEmote || m_type == ChatMessageType.RaidBossWhisper) { Writer.WriteSingle(m_displayTime); Writer.WriteBoolean(m_suspendEvent); } break; case ChatMessageType.BGSystemNeutral: case ChatMessageType.BGSystemAlliance: case ChatMessageType.BGSystemHorde: Writer.WriteGuid(m_targetGUID); if (!m_targetGUID.IsEmpty && !m_targetGUID.IsPlayer) { Writer.WriteChatString(m_targetName); } if (m_language == Language.Addon) Writer.WriteCString(m_addonPrefix ?? "<prefix>"); Writer.WriteChatString(m_text ?? "<text>"); Writer.WriteByte((byte)m_flags); break; case ChatMessageType.Achievement: case ChatMessageType.GuildAchievement: Writer.WriteGuid(m_targetGUID); if (m_language == Language.Addon) Writer.WriteCString(m_addonPrefix ?? "<prefix>"); Writer.WriteChatString(m_text ?? "<text>"); Writer.WriteByte((byte)m_flags); Writer.WriteUInt32(m_achievementId); break; case ChatMessageType.WhisperForeign: Writer.WriteChatString(m_senderName ?? "<sender>"); Writer.WriteGuid(m_targetGUID); if (m_language == Language.Addon) Writer.WriteCString(m_addonPrefix ?? "<prefix>"); Writer.WriteChatString(m_text ?? "<text>"); Writer.WriteByte((byte)m_flags); break; default: if (GameMasterMessage) Writer.WriteChatString(m_senderName ?? "<sender>"); if (m_type == ChatMessageType.Channel) Writer.WriteCString(m_channel ?? "<channel>"); Writer.WriteGuid(m_targetGUID); if (m_language == Language.Addon) Writer.WriteCString(m_addonPrefix ?? "<prefix>"); Writer.WriteChatString(m_text ?? "<text>"); Writer.WriteByte((byte)m_flags); break; } }
public override void Save(StreamHandler writer) { writer.WriteUInt32(Dungeon.Entry); writer.WriteByte((byte)State); writer.WriteUInt32(ProposalId); writer.WriteUInt32(BossesKilled); writer.WriteBoolean(SameDungeon); writer.WriteByte((byte)Players.Length); foreach (var info in Players) { writer.WriteUInt32((uint)info.Role); writer.WriteBoolean(info.SelfPlayer); writer.WriteBoolean(info.InDungeon); writer.WriteBoolean(info.SameGroup); writer.WriteBoolean(info.Answered); writer.WriteBoolean(info.Accepted); } }