System.IO.BinaryWriter.Write(uint)

Here are the examples of the csharp api System.IO.BinaryWriter.Write(uint) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1203 Examples 7

19 View Source File : CelesteNetBinaryWriter.cs
License : MIT License
Project Creator : 0x0ade

public virtual void WriteSizeDummy(byte size) {
            Flush();
            SizeDummyIndex = BaseStream.Position;

            if (size == 1) {
                SizeDummySize = 1;
                Write((byte) 0);

            } else if (size == 4) {
                SizeDummySize = 4;
                Write((uint) 0);

            } else {
                SizeDummySize = 2;
                Write((ushort) 0);
            }
        }

19 View Source File : CelesteNetBinaryWriter.cs
License : MIT License
Project Creator : 0x0ade

public virtual void UpdateSizeDummy() {
            if (SizeDummySize == 0)
                return;

            Flush();
            long end = BaseStream.Position;
            long length = end - (SizeDummyIndex + SizeDummySize);

            BaseStream.Seek(SizeDummyIndex, SeekOrigin.Begin);

            if (SizeDummySize == 1) {
                if (length > byte.MaxValue)
                    length = byte.MaxValue;
                Write((byte) length);

            } else if (SizeDummySize == 4) {
                if (length > uint.MaxValue)
                    length = uint.MaxValue;
                Write((uint) length);

            } else {
                if (length > ushort.MaxValue)
                    length = ushort.MaxValue;
                Write((ushort) length);
            }

            Flush();
            BaseStream.Seek(end, SeekOrigin.Begin);
        }

19 View Source File : ExifWriter.cs
License : MIT License
Project Creator : 0xC0000054

public byte[] CreateExifBlob()
        {
            IFDInfo ifdInfo = BuildIFDEntries();
            Dictionary<MetadataSection, IFDEntryInfo> ifdEntries = ifdInfo.IFDEntries;

            byte[] exifBytes = new byte[checked((int)ifdInfo.EXIFDataLength)];

            using (MemoryStream stream = new MemoryStream(exifBytes))
            using (BinaryWriter writer = new BinaryWriter(stream))
            {
                IFDEntryInfo imageInfo = ifdEntries[MetadataSection.Image];
                IFDEntryInfo exifInfo = ifdEntries[MetadataSection.Exif];

                writer.Write(TiffConstants.LittleEndianByteOrderMarker);
                writer.Write(TiffConstants.Signature);
                writer.Write((uint)imageInfo.StartOffset);

                WriteDirectory(writer, this.metadata[MetadataSection.Image], imageInfo.IFDEntries, imageInfo.StartOffset);
                WriteDirectory(writer, this.metadata[MetadataSection.Exif], exifInfo.IFDEntries, exifInfo.StartOffset);

                if (ifdEntries.TryGetValue(MetadataSection.Interop, out IFDEntryInfo interopInfo))
                {
                    WriteDirectory(writer, this.metadata[MetadataSection.Interop], interopInfo.IFDEntries, interopInfo.StartOffset);
                }

                if (ifdEntries.TryGetValue(MetadataSection.Gps, out IFDEntryInfo gpsInfo))
                {
                    WriteDirectory(writer, this.metadata[MetadataSection.Gps], gpsInfo.IFDEntries, gpsInfo.StartOffset);
                }
            }

            return exifBytes;
        }

19 View Source File : IFDEntry.cs
License : MIT License
Project Creator : 0xC0000054

public void Write(System.IO.BinaryWriter writer)
        {
            writer.Write(this.Tag);
            writer.Write((ushort)this.Type);
            writer.Write(this.Count);
            writer.Write(this.Offset);
        }

19 View Source File : ExifWriter.cs
License : MIT License
Project Creator : 0xC0000054

public byte[] CreateExifBlob()
        {
            IFDInfo ifdInfo = BuildIFDEntries();
            Dictionary<MetadataSection, IFDEntryInfo> ifdEntries = ifdInfo.IFDEntries;

            byte[] exifBytes = new byte[checked((int)ifdInfo.EXIFDataLength)];

            using (MemoryStream stream = new MemoryStream(exifBytes))
            using (BinaryWriter writer = new BinaryWriter(stream))
            {
                IFDEntryInfo imageInfo = ifdEntries[MetadataSection.Image];
                IFDEntryInfo exifInfo = ifdEntries[MetadataSection.Exif];

                writer.Write(TiffConstants.LittleEndianByteOrderMarker);
                writer.Write(TiffConstants.Signature);
                writer.Write((uint)imageInfo.StartOffset);

                WriteDirectory(writer, metadata[MetadataSection.Image], imageInfo.IFDEntries, imageInfo.StartOffset);
                WriteDirectory(writer, metadata[MetadataSection.Exif], exifInfo.IFDEntries, exifInfo.StartOffset);

                if (ifdEntries.TryGetValue(MetadataSection.Interop, out IFDEntryInfo interopInfo))
                {
                    WriteDirectory(writer, metadata[MetadataSection.Interop], interopInfo.IFDEntries, interopInfo.StartOffset);
                }

                if (ifdEntries.TryGetValue(MetadataSection.Gps, out IFDEntryInfo gpsInfo))
                {
                    WriteDirectory(writer, metadata[MetadataSection.Gps], gpsInfo.IFDEntries, gpsInfo.StartOffset);
                }
            }

            return exifBytes;
        }

19 View Source File : IFDEntry.cs
License : MIT License
Project Creator : 0xC0000054

public void Write(System.IO.BinaryWriter writer)
        {
            writer.Write(Tag);
            writer.Write((ushort)Type);
            writer.Write(Count);
            writer.Write(Offset);
        }

19 View Source File : OvrAvatarPacket.cs
License : MIT License
Project Creator : absurd-joy

public static void Write(this BinaryWriter writer, OvrAvatarDriver.ControllerPose pose)
    {
        writer.Write((uint)pose.buttons);
        writer.Write((uint)pose.touches);
        writer.Write(pose.joystickPosition);
        writer.Write(pose.indexTrigger);
        writer.Write(pose.handTrigger);
        writer.Write(pose.isActive);
    }

19 View Source File : Wave.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void ReadData(Stream stream)
        {
            var binaryWriter = new BinaryWriter(stream);

            binaryWriter.Write(System.Text.Encoding.ASCII.GetBytes("RIFF"));

            uint filesize = (uint)(Data.Length + 36); // 36 is added for all the extra we're adding for the WAV header format
            binaryWriter.Write(filesize);

            binaryWriter.Write(System.Text.Encoding.ASCII.GetBytes("WAVE"));

            binaryWriter.Write(System.Text.Encoding.ASCII.GetBytes("fmt"));
            binaryWriter.Write((byte)0x20); // Null ending to the fmt

            binaryWriter.Write((int)0x10); // 16 ... length of all the above

            // AC audio headers start at Format Type,
            // and are usually 18 bytes, with some exceptions
            // notably objectID A000393 which is 30 bytes

            // WAV headers are always 16 bytes from Format Type to end of header,
            // so this extra data is truncated here.
            binaryWriter.Write(Header.Take(16).ToArray());

            binaryWriter.Write(System.Text.Encoding.ASCII.GetBytes("data"));
            binaryWriter.Write((uint)Data.Length);
            binaryWriter.Write(Data);
        }

19 View Source File : Position.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void Serialize(BinaryWriter payload, PositionFlags positionFlags, int animationFrame, bool writeLandblock = true)
        {
            payload.Write((uint)positionFlags);

            if (writeLandblock)
                payload.Write(LandblockId.Raw);

            payload.Write(PositionX);
            payload.Write(PositionY);
            payload.Write(PositionZ);

            if ((positionFlags & PositionFlags.OrientationHasNoW) == 0)
                payload.Write(RotationW);

            if ((positionFlags & PositionFlags.OrientationHasNoX) == 0)
                payload.Write(RotationX);

            if ((positionFlags & PositionFlags.OrientationHasNoY) == 0)
                payload.Write(RotationY);

            if ((positionFlags & PositionFlags.OrientationHasNoZ) == 0)
                payload.Write(RotationZ);

            if ((positionFlags & PositionFlags.HasPlacementID) != 0)
                // TODO: this is current animationframe_id when we are animating (?) - when we are not, how are we setting on the ground Position_id.
                payload.Write(animationFrame);

            if ((positionFlags & PositionFlags.HasVelocity) != 0)
            {
                // velocity would go here
                payload.Write(0f);
                payload.Write(0f);
                payload.Write(0f);
            }
        }

19 View Source File : Fellowship.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, Dictionary<uint, int> departedFellows)
        {
            PackableHashTable.WriteHeader(writer, departedFellows.Count, hashComparer.NumBuckets);

            var sorted = new SortedDictionary<uint, int>(departedFellows, hashComparer);

            foreach (var departed in sorted)
            {
                writer.Write(departed.Key);
                writer.Write(departed.Value);
            }
        }

19 View Source File : AllegianceData.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, AllegianceData data)
        {
            // ObjectID - characterID - Character ID
            // uint - cpCached - XP gained while logged off
            // uint - cpreplacedhed - Total allegiance XP contribution
            // uint - bitfield - AllegianceIndex
            // Gender - gender - The gender of the character (for determining replacedle)
            // HeritageGroup - hg - The heritage of the character (for determining replacedle)
            // ushort - rank - The numerical rank (1 is lowest).

            // Choose valid sections by masking against bitfield
            // uint - level

            // ushort - loyalty - Character loyalty
            // ushort - leadership - Character leadership

            // Choose based on testing bitfield == 0x4 (HasAllegianceAge)
            // True:
            // uint - timeOnline
            // uint - allegianceAge
            // False: (Not found in later retail pcaps. Probably deprecated.)
            // ulong - uTimeOnline

            // string - name

            uint characterID = 0;
            uint cpCached = 0;
            uint cpreplacedhed = 0;
            var bitfield = AllegianceIndex.HasAllegianceAge | AllegianceIndex.HasPackedLevel;
            var gender = Gender.Female;
            var hg = HeritageGroup.Aluvian;
            ushort rank = 0;
            uint level = 0;
            ushort loyalty = 0;
            ushort leadership = 0;
            ulong uTimeOnline = 0;
            uint timeOnline = 0;
            uint allegianceAge = 0;
            var name = "";

            if (data.Node != null)
            {
                var node = data.Node;
                var playerGuid = node.PlayerGuid;
                var player = PlayerManager.FindByGuid(playerGuid, out var playerIsOnline);
                
                characterID = player.Guid.Full;
                cpCached = (uint)Math.Min(player.AllegianceXPCached, uint.MaxValue);
                cpreplacedhed = (uint)Math.Min(player.AllegianceXPGenerated, uint.MaxValue);

                if (playerIsOnline)
                    bitfield |= AllegianceIndex.LoggedIn;

                if (!node.IsMonarch && node.Player.ExistedBeforeAllegianceXpChanges)
                    bitfield |= AllegianceIndex.MayPreplacedupExperience;

                gender = (Gender)player.Gender;
                hg = (HeritageGroup)player.Heritage;
                rank = (ushort)node.Rank;
                level = (uint)player.Level;
                loyalty = (ushort)player.GetCurrentLoyalty();
                leadership = (ushort)player.GetCurrentLeadership();
                
                //if (!node.IsMonarch)
                //{
                // TODO: Get/set total time sworn to patron (allegianceAge) and total in-game time since swearing to patron (timeOnline)
                //}

                name = player.Name;
                
            }

            writer.Write(characterID);
            writer.Write(cpCached);
            writer.Write(cpreplacedhed);
            writer.Write((uint)bitfield);
            writer.Write((byte)gender);
            writer.Write((byte)hg);
            writer.Write(rank);

            if (bitfield.HasFlag(AllegianceIndex.HasPackedLevel))
                writer.Write(level);

            writer.Write(loyalty);
            writer.Write(leadership);

            if (bitfield.HasFlag(AllegianceIndex.HasAllegianceAge))
            {
                writer.Write(timeOnline);
                writer.Write(allegianceAge);
            }
            else
                writer.Write(uTimeOnline);

            writer.WriteString16L(name);
        }

19 View Source File : AllegianceHierarchy.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, AllegianceHierarchy hierarchy)
        {
            // ushort - recordCount - Number of character allegiance records
            // ushort - oldVersion = 0x000B - Defines which properties are available. 0x000B seems to be the latest version which includes all properties.
            // Dictionary<ObjectID, AllegianceOfficerLevel> - officers - Taking a guess on these values. Guessing they may only be valid for Monarchs
            //                                                           A list of officers and their officer levels?
            // List<string> - officerreplacedles - Believe these may preplaced in the current officer replacedle list. Guessing they may only be valid on Monarchs.
            // uint - monarchBroadcastTime - May only be valid for Monarchs/Speakers?
            // uint - monarchBroadcastsToday - May only be valid for Monarchs/Speakers?
            // uint - spokesBroadcastTime - May only be valid for Monarchs/Speakers?
            // uint - spokesBroadcastsToday - May only be valid for Monarchs/Speakers?
            // string - motd - Text for current Message of the Day. May only be valid for Monarchs/Speakers?
            // string - motdSetBy - Who set the current Message of the Day. May only be valid for Monarchs/Speakers?
            // uint - chatRoomID - allegiance chat channel number
            // Position - bindpoint - Location of monarchy bindpoint
            // string - allegianceName - The name of the allegiance.
            // uint - nameLastSetTime - Time name was last set. Seems to count upward for some reason.
            // bool - isLocked - Whether allegiance is locked.
            // int - approvedVreplacedal - ??
            // AllegianceData - monarchData - Monarch's data

            // records: vector of length recordCount - 1
            // ObjectID - treeParent - The ObjectID for the parent character to this character. Used by the client to decide how to build the display in the Allegiance tab. 1 is the monarch.
            // AllegianceData - allegianceData

            // recordCount = Monarch + Patron + Vreplacedals?
            // 2 in data for small allegiances?
            ushort recordCount = 0;
            ushort oldVersion = 0x000B;
            var officers = new Dictionary<ObjectGuid, AllegianceOfficerLevel>();
            var officerreplacedles = new List<string>();
            uint monarchBroadcastTime = 0;
            uint monarchBroadcastsToday = 0;
            uint spokesBroadcastTime = 0;
            uint spokesBroadcastsToday = 0;
            var motd = "";
            var motdSetBy = "";
            uint chatRoomID = 0;
            var bindPoint = new Position();
            var allegianceName = "";
            uint nameLastSetTime = 0;
            bool isLocked = false;
            int approvedVreplacedal = 0;
            AllegianceData monarchData = null;
            List<Tuple<ObjectGuid, AllegianceData>> records = null;

            var allegiance = hierarchy.Profile.Allegiance;
            var node = hierarchy.Profile.Node;

            if (allegiance != null && node != null)
            {
                // only send these to monarch?
                //foreach (var officer in allegiance.Officers)
                    //officers.Add(officer.Key, (AllegianceOfficerLevel)officer.Value.Player.AllegianceOfficerRank);

                // not in retail packets, breaks decal
                /*if (allegiance.HasCustomreplacedles)
                {
                    officerreplacedles.Add(allegiance.GetOfficerreplacedle(AllegianceOfficerLevel.Speaker));
                    officerreplacedles.Add(allegiance.GetOfficerreplacedle(AllegianceOfficerLevel.Seneschal));
                    officerreplacedles.Add(allegiance.GetOfficerreplacedle(AllegianceOfficerLevel.Castellan));
                }*/

                allegianceName = allegiance.AllegianceName ?? allegiance.Monarch.Player.Name;
                //motd = allegiance.AllegianceMotd ?? "";
                //motdSetBy = allegiance.AllegianceMotdSetBy ?? "";
                motd = "";          // fixes decal AllegianceUpdate parsing
                motdSetBy = "";
                chatRoomID = allegiance.Biota.Id;

                if (allegiance.Sanctuary != null)
                    bindPoint = allegiance.Sanctuary;

                // aclogview (verify):
                // i == 0 : monarch (no guid)
                // i == 1 : patron
                // i == 2 : peer?
                // i  > 2 : vreplacedals

                // peers = others with the same patron?

                recordCount = 1;    // monarch
                if (node.Patron != null && !node.Patron.IsMonarch)  // patron
                    recordCount++;
                if (!node.IsMonarch)    // self
                    recordCount++;
                if (node.TotalVreplacedals > 0)  // vreplacedals
                {
                    recordCount += (ushort)node.TotalVreplacedals;
                }
                //Console.WriteLine("Records: " + recordCount);

                // monarch
                monarchData = new AllegianceData(allegiance.Monarch);

                if (recordCount > 1)
                {
                    records = new List<Tuple<ObjectGuid, AllegianceData>>();

                    // patron
                    if (node.Patron != null && !node.Patron.IsMonarch)
                    {
                        records.Add(new Tuple<ObjectGuid, AllegianceData>(node.Monarch.PlayerGuid, new AllegianceData(node.Patron)));
                    }

                    // self
                    if (!node.IsMonarch)
                        records.Add(new Tuple<ObjectGuid, AllegianceData>(node.Patron.PlayerGuid, new AllegianceData(node)));

                    // vreplacedals
                    if (node.TotalVreplacedals > 0)
                    {
                        foreach (var vreplacedal in node.Vreplacedals.Values)
                            records.Add(new Tuple<ObjectGuid, AllegianceData>(node.PlayerGuid, new AllegianceData(vreplacedal)));
                    }
                }
            }

            writer.Write(recordCount);
            writer.Write(oldVersion);
            writer.Write(officers);
            writer.Write(officerreplacedles);
            writer.Write(monarchBroadcastTime);
            writer.Write(monarchBroadcastsToday);
            writer.Write(spokesBroadcastTime);
            writer.Write(spokesBroadcastsToday);
            writer.WriteString16L(motd);
            writer.WriteString16L(motdSetBy);
            writer.Write(chatRoomID);
            writer.Write(bindPoint);
            writer.WriteString16L(allegianceName);
            writer.Write(nameLastSetTime);
            writer.Write(Convert.ToUInt32(isLocked));
            writer.Write(approvedVreplacedal);

            if (monarchData != null)
                writer.Write(monarchData);

            if (records != null)
                writer.Write(records);
        }

19 View Source File : AppraiseInfo.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, Dictionary<PropertyInt64, long> _properties)
        {
            PackableHashTable.WriteHeader(writer, _properties.Count, PropertyInt64Comparer.NumBuckets);

            var properties = new SortedDictionary<PropertyInt64, long>(_properties, PropertyInt64Comparer);

            foreach (var kvp in properties)
            {
                writer.Write((uint)kvp.Key);
                writer.Write(kvp.Value);
            }
        }

19 View Source File : AppraiseInfo.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, Dictionary<PropertyBool, bool> _properties)
        {
            PackableHashTable.WriteHeader(writer, _properties.Count, PropertyBoolComparer.NumBuckets);

            var properties = new SortedDictionary<PropertyBool, bool>(_properties, PropertyBoolComparer);

            foreach (var kvp in properties)
            {
                writer.Write((uint)kvp.Key);
                writer.Write(Convert.ToUInt32(kvp.Value));
            }
        }

19 View Source File : AppraiseInfo.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, Dictionary<PropertyFloat, double> _properties)
        {
            PackableHashTable.WriteHeader(writer, _properties.Count, PropertyFloatComparer.NumBuckets);

            var properties = new SortedDictionary<PropertyFloat, double>(_properties, PropertyFloatComparer);

            foreach (var kvp in properties)
            {
                writer.Write((uint)kvp.Key);
                writer.Write(kvp.Value);
            }
        }

19 View Source File : AppraiseInfo.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, Dictionary<PropertyString, string> _properties)
        {
            PackableHashTable.WriteHeader(writer, _properties.Count, PropertyStringComparer.NumBuckets);

            var properties = new SortedDictionary<PropertyString, string>(_properties, PropertyStringComparer);

            foreach (var kvp in properties)
            {
                writer.Write((uint)kvp.Key);
                writer.WriteString16L(kvp.Value);
            }
        }

19 View Source File : AppraiseInfo.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, Dictionary<PropertyDataId, uint> _properties)
        {
            PackableHashTable.WriteHeader(writer, _properties.Count, PropertyDataIdComparer.NumBuckets);

            var properties = new SortedDictionary<PropertyDataId, uint>(_properties, PropertyDataIdComparer);

            foreach (var kvp in properties)
            {
                writer.Write((uint)kvp.Key);
                writer.Write(kvp.Value);
            }
        }

19 View Source File : ArmorLevel.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, ArmorLevel armorLevel)
        {
            writer.Write(armorLevel.Head);
            writer.Write(armorLevel.Chest);
            writer.Write(armorLevel.Abdomen);
            writer.Write(armorLevel.UpperArm);
            writer.Write(armorLevel.LowerArm);
            writer.Write(armorLevel.Hand);
            writer.Write(armorLevel.UpperLeg);
            writer.Write(armorLevel.LowerLeg);
            writer.Write(armorLevel.Foot);
        }

19 View Source File : CreatureProfile.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, CreatureProfile profile)
        {
            writer.Write((uint)profile.Flags);
            writer.Write(profile.Health);
            writer.Write(profile.HealthMax);

            // has flags & 0x8?
            if (profile.Flags.HasFlag(CreatureProfileFlags.ShowAttributes))
            {
                writer.Write(profile.Strength);
                writer.Write(profile.Endurance);
                writer.Write(profile.Quickness);
                writer.Write(profile.Coordination);
                writer.Write(profile.Focus);
                writer.Write(profile.Self);

                writer.Write(profile.Stamina);
                writer.Write(profile.Mana);
                writer.Write(profile.StaminaMax);
                writer.Write(profile.ManaMax);
            }

            // has flags & 0x1?
            if (profile.Flags.HasFlag(CreatureProfileFlags.HasBuffsDebuffs))
            {
                writer.Write((ushort)profile.AttributeHighlights);
                writer.Write((ushort)profile.AttributeColors);
            }
        }

19 View Source File : Enchantment.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, Enchantment enchantment)
        {
            writer.Write(enchantment.SpellID);
            var layer = enchantment.SpellID == (ushort)SpellId.Vitae ? (ushort)0 : enchantment.Layer; // this line is to force vitae to be layer 0 to match retail pcaps. We save it as layer 1 to make EF Core happy.
            writer.Write(layer);
            writer.Write(enchantment.SpellCategory);
            writer.Write(enchantment.HreplacedpellSetID);
            writer.Write(enchantment.PowerLevel);
            writer.Write(enchantment.StartTime);
            writer.Write(enchantment.Duration);
            writer.Write(enchantment.CasterGuid);
            writer.Write(enchantment.DegradeModifier);
            writer.Write(enchantment.DegradeLimit);
            writer.Write(enchantment.LastTimeDegraded);     // always 0 / spell economy?
            writer.Write((uint)enchantment.StatModType);
            writer.Write(enchantment.StatModKey);
            writer.Write(enchantment.StatModValue);
            if (enchantment.HreplacedpellSetID != 0)
                writer.Write(enchantment.SpellSetID);
        }

19 View Source File : SquelchDB.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, Dictionary<uint, SquelchInfo> characterHash)
        {
            PackableHashTable.WriteHeader(writer, characterHash.Count, HashComparer.NumBuckets);

            var sorted = new SortedDictionary<uint, SquelchInfo>(characterHash, HashComparer);

            foreach (var kvp in sorted)
            {
                writer.Write(kvp.Key);
                writer.Write(kvp.Value);
            }
        }

19 View Source File : SquelchInfo.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, SquelchInfo info)
        {
            writer.Write(info.Filters);
            writer.WriteString16L(info.PlayerName);
            writer.Write(Convert.ToUInt32(info.Account));
        }

19 View Source File : SquelchInfo.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, List<SquelchMask> filters)
        {
            writer.Write(filters.Count);
            foreach (var filter in filters)
                writer.Write((uint)filter);
        }

19 View Source File : WeaponProfile.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, WeaponProfile profile)
        {
            writer.Write((uint)profile.DamageType);
            writer.Write(profile.WeaponTime);
            writer.Write((uint)profile.WeaponSkill);
            writer.Write(profile.Damage);
            writer.Write(profile.DamageVariance);
            writer.Write(profile.DamageMod);
            writer.Write(profile.WeaponLength);
            writer.Write(profile.MaxVelocity);
            writer.Write(profile.WeaponOffense);
            writer.Write(profile.MaxVelocityEstimated);
        }

19 View Source File : Extensions.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void WritePosition(this BinaryWriter writer, uint value, long position)
        {
            long originalPosition = writer.BaseStream.Position;
            writer.BaseStream.Position = position;
            writer.Write(value);
            writer.BaseStream.Position = originalPosition;
        }

19 View Source File : PacketHeaderOptional.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public void Unpack(BinaryReader reader, PacketHeader header)
        {
            Header = header;
            Size = (uint)reader.BaseStream.Position;
            BinaryWriter writer = new BinaryWriter(headerBytes);

            if (header.HasFlag(PacketHeaderFlags.ServerSwitch)) // 0x100
            {
                writer.Write(reader.ReadBytes(8));
            }

            if (header.HasFlag(PacketHeaderFlags.RequestRetransmit)) // 0x1000
            {
                if (reader.BaseStream.Length < reader.BaseStream.Position + 4) { IsValid = false; return; }
                uint retransmitCount = reader.ReadUInt32();
                writer.Write(retransmitCount);
                RetransmitData = new List<uint>();
                for (uint i = 0u; i < retransmitCount; i++)
                {
                    if (reader.BaseStream.Length < reader.BaseStream.Position + 4) { IsValid = false; return; }
                    uint sequence = reader.ReadUInt32();
                    writer.Write(sequence);
                    RetransmitData.Add(sequence);
                }
            }

            if (header.HasFlag(PacketHeaderFlags.RejectRetransmit)) // 0x2000
            {
                if (reader.BaseStream.Length < reader.BaseStream.Position + 4) { IsValid = false; return; }
                uint count = reader.ReadUInt32();
                writer.Write(count);
                for (int i = 0; i < count; i++)
                {
                    if (reader.BaseStream.Length < reader.BaseStream.Position + 4) { IsValid = false; return; }
                    writer.Write(reader.ReadBytes(4));
                }
            }

            if (header.HasFlag(PacketHeaderFlags.AckSequence)) // 0x4000
            {
                if (reader.BaseStream.Length < reader.BaseStream.Position + 4) { IsValid = false; return; }
                AckSequence = reader.ReadUInt32();
                writer.Write(AckSequence);
            }

            if (header.HasFlag(PacketHeaderFlags.LoginRequest)) // 0x10000
            {
                long position = reader.BaseStream.Position;
                long length = reader.BaseStream.Length - position;
                if (length < 1) { IsValid = false; return; }
                byte[] loginBytes = new byte[length];
                reader.BaseStream.Read(loginBytes, (int)position, (int)length);
                writer.Write(loginBytes);
                reader.BaseStream.Position = position;
            }

            if (header.HasFlag(PacketHeaderFlags.WorldLoginRequest)) // 0x20000
            {
                if (reader.BaseStream.Length < reader.BaseStream.Position + 8) { IsValid = false; return; }
                long position = reader.BaseStream.Position;
                writer.Write(reader.ReadBytes(8));
                reader.BaseStream.Position = position;
            }

            if (header.HasFlag(PacketHeaderFlags.ConnectResponse)) // 0x80000
            {
                long position = reader.BaseStream.Position;
                if (reader.BaseStream.Length < reader.BaseStream.Position + 8) { IsValid = false; return; }
                writer.Write(reader.ReadBytes(8));
                reader.BaseStream.Position = position;
            }

            if (header.HasFlag(PacketHeaderFlags.CICMDCommand)) // 0x400000
            {
                if (reader.BaseStream.Length < reader.BaseStream.Position + 8) { IsValid = false; return; }
                writer.Write(reader.ReadBytes(8));
            }

            if (header.HasFlag(PacketHeaderFlags.TimeSync)) // 0x1000000
            {
                if (reader.BaseStream.Length < reader.BaseStream.Position + 8) { IsValid = false; return; }
                TimeSynch = reader.ReadDouble();
                writer.Write(TimeSynch);
            }

            if (header.HasFlag(PacketHeaderFlags.Ecreplacedquest)) // 0x2000000
            {
                if (reader.BaseStream.Length < reader.BaseStream.Position + 4) { IsValid = false; return; }
                EcreplacedquestClientTime = reader.ReadSingle();
                writer.Write(EcreplacedquestClientTime);
            }

            if (header.HasFlag(PacketHeaderFlags.Flow)) // 0x8000000
            {
                if (reader.BaseStream.Length < reader.BaseStream.Position + 6) { IsValid = false; return; }
                FlowBytes = reader.ReadUInt32();
                FlowInterval = reader.ReadUInt16();
                writer.Write(FlowBytes);
                writer.Write(FlowInterval);
            }

            Size = (uint)reader.BaseStream.Position - Size;
        }

19 View Source File : TurnToParameters.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, TurnToParameters turnTo)
        {
            writer.Write((uint)turnTo.MovementParams);
            writer.Write(turnTo.Speed);
            writer.Write(turnTo.DesiredHeading);
        }

19 View Source File : AllegianceHierarchy.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, Dictionary<ObjectGuid, AllegianceOfficerLevel> _officers)
        {
            PackableHashTable.WriteHeader(writer, _officers.Count, headerNumBuckets);

            // always sent as empty in retail?
            var officers = new SortedDictionary<ObjectGuid, AllegianceOfficerLevel>(_officers, guidComparer);

            foreach (var officer in officers)
            {
                writer.Write(officer.Key.Full);
                writer.Write((uint)officer.Value);
            }
        }

19 View Source File : AllegianceProfile.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, AllegianceProfile profile)
        {
            // uint - totalMembers - The number of allegiance members.
            // uint - totalVreplacedals - Your personal number of followers.
            // AllegianceHierarchy - allegianceHierarchy

            uint totalMembers = 0; 
            uint totalVreplacedals = 0;

            if (profile.Allegiance != null && profile.Node != null)
            {
                totalMembers = (uint)profile.Node.Monarch.TotalFollowers + 1;       // includes monarch
                totalVreplacedals = (uint)profile.Node.TotalFollowers;
            }

            writer.Write(totalMembers);
            writer.Write(totalVreplacedals);

            var allegianceHierarchy = new AllegianceHierarchy(profile);
            writer.Write(allegianceHierarchy);
        }

19 View Source File : AppraiseInfo.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, Dictionary<PropertyInt, int> _properties)
        {
            PackableHashTable.WriteHeader(writer, _properties.Count, PropertyIntComparer.NumBuckets);

            var properties = new SortedDictionary<PropertyInt, int>(_properties, PropertyIntComparer);

            foreach (var kvp in properties)
            {
                writer.Write((uint)kvp.Key);
                writer.Write(kvp.Value);
            }
        }

19 View Source File : ContractTracker.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, ContractTracker contractTracker)
        {
            writer.Write(contractTracker.Version);
            writer.Write(contractTracker.ContractId);
            writer.Write((uint)contractTracker.Stage);
            writer.Write(contractTracker.TimeWhenDone);
            writer.Write(contractTracker.TimeWhenRepeats);

            // This is not written here.
            //writer.Write(Convert.ToUInt32(contractTracker.DeleteContract));
            //writer.Write(Convert.ToUInt32(contractTracker.SetAsDisplayContract));
        }

19 View Source File : PositionPack.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, PositionPack position)
        {
            writer.Write((uint)position.Flags);
            writer.Write(position.Origin);

            // choose valid sections by masking against flags
            if ((position.Flags & PositionFlags.OrientationHasNoW) == 0)
                writer.Write(position.Rotation.W);
            if ((position.Flags & PositionFlags.OrientationHasNoX) == 0)
                writer.Write(position.Rotation.X);
            if ((position.Flags & PositionFlags.OrientationHasNoY) == 0)
                writer.Write(position.Rotation.Y);
            if ((position.Flags & PositionFlags.OrientationHasNoZ) == 0)
                writer.Write(position.Rotation.Z);

            if ((position.Flags & PositionFlags.HasVelocity) != 0)
                writer.Write(position.Velocity);

            if ((position.Flags & PositionFlags.HasPlacementID) != 0)
                writer.Write((uint)position.PlacementID);

            writer.Write(position.InstanceSequence);
            writer.Write(position.PositionSequence);
            writer.Write(position.TeleportSequence);
            writer.Write(position.ForcePositionSequence);
        }

19 View Source File : RestrictionDB.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, RestrictionDB restrictions)
        {
            writer.Write(restrictions.Version);
            writer.Write(Convert.ToUInt32(restrictions.OpenStatus));
            writer.Write(restrictions.MonarchID.Full);
            writer.Write(restrictions.Table);
        }

19 View Source File : RestrictionDB.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, Dictionary<ObjectGuid, uint> db)
        {
            PackableHashTable.WriteHeader(writer, db.Count, headerNumBuckets);

            var sorted = new SortedDictionary<ObjectGuid, uint>(db, guidComparer);

            foreach (var kvp in sorted)
            {
                writer.Write(kvp.Key.Full);
                writer.Write(kvp.Value);
            }
        }

19 View Source File : SalvageResult.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, SalvageResult result)
        {
            writer.Write((uint)result.MaterialType);
            writer.Write(result.Workmanship);
            writer.Write(result.Units);
        }

19 View Source File : Shortcut.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, Shortcut shortcut)
        {
            writer.Write(shortcut.Index);
            writer.Write(shortcut.ObjectId);
            writer.Write(shortcut.Spell);
        }

19 View Source File : EnchantmentRegistry.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, EnchantmentRegistry registry)
        {
            var enchantmentMask = registry.EnchantmentMask;

            writer.Write((uint)enchantmentMask);
            if (enchantmentMask.HasFlag(EnchantmentMask.Multiplicative))
                writer.Write(registry.Enchantments[EnchantmentMask.Multiplicative]);
            if (enchantmentMask.HasFlag(EnchantmentMask.Additive))
                writer.Write(registry.Enchantments[EnchantmentMask.Additive]);
            if (enchantmentMask.HasFlag(EnchantmentMask.Cooldown))
                writer.Write(registry.Enchantments[EnchantmentMask.Cooldown]);
            if (enchantmentMask.HasFlag(EnchantmentMask.Vitae))
                writer.Write(registry.Enchantments[EnchantmentMask.Vitae].FirstOrDefault());
        }

19 View Source File : FellowshipLockData.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, FellowshipLockData fellowshipLockData)
        {
            writer.Write(fellowshipLockData.Unknown_1);
            writer.Write(fellowshipLockData.Unknown_2);
            writer.Write(fellowshipLockData.Unknown_3);
            writer.Write(fellowshipLockData.Timestamp);
            writer.Write(fellowshipLockData.Sequence);
        }

19 View Source File : GuestInfo.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, GuestInfo info)
        {
            writer.Write(Convert.ToUInt32(info.ItemStoragePermission));
            writer.WriteString16L(info.GuestName);
        }

19 View Source File : HookProfile.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, HookProfile hook)
        {
            writer.Write((uint)hook.Flags);
            writer.Write((uint)hook.ValidLocations);
            writer.Write((uint)hook.AmmoType);
        }

19 View Source File : HouseAccess.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, HouseAccess har)
        {
            writer.Write(har.Version);
            writer.Write((uint)har.Bitmask);
            writer.Write(har.MonarchID.Full);
            writer.Write(har.GuestList);
            writer.Write(har.Roommates);
        }

19 View Source File : HouseData.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, HouseData data)
        {
            writer.Write(data.BuyTime);
            writer.Write(data.RentTime);
            writer.Write((uint)data.Type);
            writer.Write(Convert.ToUInt32(data.MaintenanceFree));
            writer.Write(data.Buy);
            writer.Write(data.Rent);
            writer.Write(data.Position);
        }

19 View Source File : HousePayment.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, HousePayment payment)
        {
            writer.Write(payment.Num);
            writer.Write(payment.Paid);
            writer.Write(payment.WeenieID);
            writer.WriteString16L(payment.Name);
            writer.WriteString16L(payment.PluralName);
        }

19 View Source File : HouseProfile.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, HouseProfile profile)
        {
            writer.Write(profile.DwellingID);
            writer.Write(profile.OwnerID.Full);
            writer.Write((uint)profile.Bitmask);
            writer.Write(profile.MinLevel);
            writer.Write(profile.MaxLevel);
            writer.Write(profile.MinAllegRank);
            writer.Write(profile.MaxAllegRank);
            writer.Write(Convert.ToUInt32(profile.MaintenanceFree));
            writer.Write((uint)profile.Type);
            writer.WriteString16L(profile.OwnerName);
            writer.Write(profile.Buy);
            writer.Write(profile.Rent);
        }

19 View Source File : Origin.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, Origin origin)
        {
            writer.Write(origin.CellID);
            writer.Write(origin.Position);
        }

19 View Source File : PackableList.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, List<uint> list)
        {
            writer.Write(list.Count);
            foreach (var item in list)
                writer.Write(item);
        }

19 View Source File : PageData.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, PageData page)
        {
            writer.Write(page.AuthorGuid);
            writer.WriteString16L(page.AuthorName);
            writer.WriteString16L(page.AuthorAccount);
            writer.Write(page.Version);
            writer.Write(Convert.ToUInt32(page.HasText));
            writer.Write(Convert.ToUInt32(page.IgnoreAuthor));

            if (page.HasText)
                writer.WriteString16L(page.PageText);
        }

19 View Source File : MoveToParameters.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, MoveToParameters mvp)
        {
            writer.Write((uint)mvp.MovementParameters);
            writer.Write(mvp.DistanceToObject);
            writer.Write(mvp.MinDistance);
            writer.Write(mvp.FailDistance);
            writer.Write(mvp.Speed);
            writer.Write(mvp.WalkRunThreshold);
            writer.Write(mvp.DesiredHeading);
        }

19 View Source File : AppraiseInfo.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, AppraiseInfo info)
        {
            writer.Write((uint)info.Flags);
            writer.Write(Convert.ToUInt32(info.Success));
            if (info.Flags.HasFlag(IdentifyResponseFlags.IntStatsTable))
                writer.Write(info.PropertiesInt);
            if (info.Flags.HasFlag(IdentifyResponseFlags.Int64StatsTable))
                writer.Write(info.PropertiesInt64);
            if (info.Flags.HasFlag(IdentifyResponseFlags.BoolStatsTable))
                writer.Write(info.PropertiesBool);
            if (info.Flags.HasFlag(IdentifyResponseFlags.FloatStatsTable))
                writer.Write(info.PropertiesFloat);
            if (info.Flags.HasFlag(IdentifyResponseFlags.StringStatsTable))
                writer.Write(info.PropertiesString);
            if (info.Flags.HasFlag(IdentifyResponseFlags.DidStatsTable))
                writer.Write(info.PropertiesDID);
            if (info.Flags.HasFlag(IdentifyResponseFlags.SpellBook))
                writer.Write(info.SpellBook);
            if (info.Flags.HasFlag(IdentifyResponseFlags.ArmorProfile))
                writer.Write(info.ArmorProfile);
            if (info.Flags.HasFlag(IdentifyResponseFlags.CreatureProfile))
                writer.Write(info.CreatureProfile);
            if (info.Flags.HasFlag(IdentifyResponseFlags.WeaponProfile))
                writer.Write(info.WeaponProfile);
            if (info.Flags.HasFlag(IdentifyResponseFlags.HookProfile))
                writer.Write(info.HookProfile);
            if (info.Flags.HasFlag(IdentifyResponseFlags.ArmorEnchantmentBitfield))
            {
                writer.Write((ushort)info.ArmorHighlight);
                writer.Write((ushort)info.ArmorColor);
            }
            if (info.Flags.HasFlag(IdentifyResponseFlags.WeaponEnchantmentBitfield))
            {
                writer.Write((ushort)info.WeaponHighlight);
                writer.Write((ushort)info.WeaponColor);
            }
            if (info.Flags.HasFlag(IdentifyResponseFlags.ResistEnchantmentBitfield))
            {
                writer.Write((ushort)info.ResistHighlight);
                writer.Write((ushort)info.ResistColor);
            }
            if (info.Flags.HasFlag(IdentifyResponseFlags.ArmorLevels))
                writer.Write(info.ArmorLevels);
        }

19 View Source File : ContractManager.cs
License : GNU Affero General Public License v3.0
Project Creator : ACEmulator

public static void Write(this BinaryWriter writer, Dictionary<uint, ContractTracker> contractTable)
        {
            PackableHashTable.WriteHeader(writer, contractTable.Count, hashComparer.NumBuckets);

            var contractTrackers = new SortedDictionary<uint, ContractTracker>(contractTable, hashComparer);

            foreach (var contractTracker in contractTrackers)
            {
                writer.Write(contractTracker.Key);
                writer.Write(contractTracker.Value);
            }
        }

See More Examples