示例#1
0
        public override void BuildValuesCreate(WorldPacket data, Player target)
        {
            UpdateFieldFlag flags  = GetUpdateFieldFlagsFor(target);
            WorldPacket     buffer = new WorldPacket();

            m_objectData.WriteCreate(buffer, flags, this, target);
            m_conversationData.WriteCreate(buffer, flags, this, target);

            data.WriteUInt32(buffer.GetSize());
            data.WriteUInt8((byte)flags);
            data.WriteBytes(buffer);
        }
示例#2
0
        void BuildValuesUpdateForPlayerWithMask(UpdateData data, UpdateMask requestedObjectMask, UpdateMask requestedItemMask, UpdateMask requestedAzeriteItemMask, Player target)
        {
            UpdateFieldFlag flags      = GetUpdateFieldFlagsFor(target);
            UpdateMask      valuesMask = new UpdateMask((int)TypeId.Max);

            if (requestedObjectMask.IsAnySet())
            {
                valuesMask.Set((int)TypeId.Object);
            }

            m_itemData.FilterDisallowedFieldsMaskForFlag(requestedItemMask, flags);
            if (requestedItemMask.IsAnySet())
            {
                valuesMask.Set((int)TypeId.Item);
            }

            m_azeriteItemData.FilterDisallowedFieldsMaskForFlag(requestedAzeriteItemMask, flags);
            if (requestedAzeriteItemMask.IsAnySet())
            {
                valuesMask.Set((int)TypeId.AzeriteItem);
            }

            WorldPacket buffer = new WorldPacket();

            buffer.WriteUInt32(valuesMask.GetBlock(0));

            if (valuesMask[(int)TypeId.Object])
            {
                m_objectData.WriteUpdate(buffer, requestedObjectMask, true, this, target);
            }

            if (valuesMask[(int)TypeId.Item])
            {
                m_itemData.WriteUpdate(buffer, requestedItemMask, true, this, target);
            }

            if (valuesMask[(int)TypeId.AzeriteItem])
            {
                m_azeriteItemData.WriteUpdate(buffer, requestedAzeriteItemMask, true, this, target);
            }

            WorldPacket buffer1 = new WorldPacket();

            buffer1.WriteUInt8((byte)UpdateType.Values);
            buffer1.WritePackedGuid(GetGUID());
            buffer1.WriteUInt32(buffer.GetSize());
            buffer1.WriteBytes(buffer.GetData());

            data.AddUpdateBlock(buffer1);
        }
示例#3
0
        public UpdateField(Type type, UpdateFieldFlag flag, int size = 0, int bitSize = 0, CustomUpdateFieldFlag customFlag = CustomUpdateFieldFlag.None, [CallerLineNumber] int order = 0)
        {
            if (size == 0 && type.IsArray)
            {
                throw new ArgumentException($"Given type is an array with 0 length ({type.Name})", nameof(type));
            }
            else if (size != 0 && !type.IsArray)
            {
                throw new ArgumentException($"Given type is not an array ({type.Name})", nameof(type));
            }

            if (type == typeof(Bits) && (bitSize == 0 || bitSize > 32))
            {
                throw new ArgumentOutOfRangeException(nameof(bitSize), bitSize, "must be in range 1-32");
            }

            (Type, Flag, Size, BitSize, CustomFlag, Order) = (type, flag, size, bitSize, customFlag, order);
        }
示例#4
0
        public override void BuildValuesUpdate(WorldPacket data, Player target)
        {
            UpdateFieldFlag flags  = GetUpdateFieldFlagsFor(target);
            WorldPacket     buffer = new WorldPacket();

            buffer.WriteUInt32(m_values.GetChangedObjectTypeMask());
            if (m_values.HasChanged(TypeId.Object))
            {
                m_objectData.WriteUpdate(buffer, flags, this, target);
            }

            if (m_values.HasChanged(TypeId.Conversation))
            {
                m_conversationData.WriteUpdate(buffer, flags, this, target);
            }

            data.WriteUInt32(buffer.GetSize());
            data.WriteBytes(buffer);
        }
示例#5
0
        public override void OnStructureBegin(Type structureType, ObjectType objectType, bool create, bool writeUpdateMasks)
        {
            base.OnStructureBegin(structureType, objectType, create, writeUpdateMasks);
            _allUsedFlags = UpdateFieldFlag.None;
            _flagByUpdateBit.Clear();
            _flagByUpdateBit[0] = new SortedSet <UpdateFieldFlag>()
            {
                UpdateFieldFlag.None
            };
            _owningObjectType = GetClassForObjectType(objectType);
            _delayedHeaderWrites.Clear();
            _changesMaskClears.Clear();
            _equalityComparisonFields.Clear();

            var structureName = RenameType(structureType);

            if (_create)
            {
                if (_isRoot)
                {
                    _source.WriteLine($"void {structureName}::WriteCreate(ByteBuffer& data, EnumFlag<UpdateFieldFlag> fieldVisibilityFlags, {_owningObjectType} const* owner, Player const* receiver) const");
                }
                else
                {
                    _source.WriteLine($"void {structureName}::WriteCreate(ByteBuffer& data, {_owningObjectType} const* owner, Player const* receiver) const");
                }
            }
            else
            {
                if (_isRoot)
                {
                    _source.WriteLine($"void {structureName}::WriteUpdate(ByteBuffer& data, EnumFlag<UpdateFieldFlag> fieldVisibilityFlags, {_owningObjectType} const* owner, Player const* receiver) const");
                }
                else
                {
                    _source.WriteLine($"void {structureName}::WriteUpdate(ByteBuffer& data, bool ignoreChangesMask, {_owningObjectType} const* owner, Player const* receiver) const");
                }
            }

            _source.WriteLine("{");
        }
示例#6
0
        public override void BuildValuesUpdateWithFlag(WorldPacket data, UpdateFieldFlag flags, Player target)
        {
            UpdateMask valuesMask = new UpdateMask(14);

            valuesMask.Set((int)TypeId.Item);
            valuesMask.Set((int)TypeId.AzeriteItem);

            WorldPacket buffer = new WorldPacket();

            buffer.WriteUInt32(valuesMask.GetBlock(0));

            UpdateMask mask = new UpdateMask(40);

            m_itemData.AppendAllowedFieldsMaskForFlag(mask, flags);
            m_itemData.WriteUpdate(buffer, mask, true, this, target);

            UpdateMask mask2 = new UpdateMask(9);

            m_azeriteItemData.AppendAllowedFieldsMaskForFlag(mask2, flags);
            m_azeriteItemData.WriteUpdate(buffer, mask2, true, this, target);

            data.WriteUInt32(buffer.GetSize());
            data.WriteBytes(buffer);
        }
示例#7
0
        public override void BuildValuesUpdate(WorldPacket data, Player target)
        {
            UpdateFieldFlag flags  = GetUpdateFieldFlagsFor(target);
            WorldPacket     buffer = new();

            if (m_values.HasChanged(TypeId.Object))
            {
                m_objectData.WriteUpdate(buffer, flags, this, target);
            }

            if (m_values.HasChanged(TypeId.Item))
            {
                m_itemData.WriteUpdate(buffer, flags, this, target);
            }

            if (m_values.HasChanged(TypeId.AzeriteEmpoweredItem))
            {
                m_azeriteEmpoweredItemData.WriteUpdate(buffer, flags, this, target);
            }

            data.WriteUInt32(buffer.GetSize());
            data.WriteUInt32(m_values.GetChangedObjectTypeMask());
            data.WriteBytes(buffer);
        }
示例#8
0
        public override IReadOnlyList <FlowControlBlock> OnField(string name, UpdateField updateField, IReadOnlyList <FlowControlBlock> previousControlFlow)
        {
            _allUsedFlags |= updateField.Flag;

            name = RenameField(name);

            var flowControl = new List <FlowControlBlock>();

            if (_create && updateField.Flag != UpdateFieldFlag.None)
            {
                flowControl.Add(new FlowControlBlock {
                    Statement = $"if (fieldVisibilityFlags.HasFlag({updateField.Flag.ToFlagsExpression(" | ", "UpdateFieldFlag::")}))"
                });
            }

            var type                = updateField.Type;
            var nameUsedToWrite     = name;
            var access              = "->";
            var arrayLoopBlockIndex = -1;
            var indexLetter         = 'i';
            var allIndexes          = "";

            if (type.IsArray)
            {
                flowControl.Add(new FlowControlBlock {
                    Statement = $"for (std::size_t {indexLetter} = 0; {indexLetter} < {updateField.Size}; ++{indexLetter})"
                });
                nameUsedToWrite    += $"[{indexLetter}]";
                access              = ".";
                type                = type.GetElementType();
                arrayLoopBlockIndex = flowControl.Count;
                allIndexes         += ", " + indexLetter;
                ++indexLetter;
            }
            if (typeof(DynamicUpdateField).IsAssignableFrom(type))
            {
                flowControl.Add(new FlowControlBlock {
                    Statement = $"for (std::size_t {indexLetter} = 0; {indexLetter} < {nameUsedToWrite}.size(); ++{indexLetter})"
                });
                if (!_create)
                {
                    flowControl.Add(new FlowControlBlock {
                        Statement = $"if ({nameUsedToWrite}.HasChanged({indexLetter}) || {(_isRoot ? "ignoreNestedChangesMask" : "ignoreChangesMask")})"
                    });
                }

                nameUsedToWrite += $"[{indexLetter}]";
                access           = ".";
                type             = type.GenericTypeArguments[0];
                allIndexes      += ", " + indexLetter;
                ++indexLetter;
            }
            if (typeof(BlzVectorField).IsAssignableFrom(type))
            {
                flowControl.Add(new FlowControlBlock {
                    Statement = $"for (std::size_t {indexLetter} = 0; {indexLetter} < {name}->size(); ++{indexLetter})"
                });
                nameUsedToWrite = $"(*{nameUsedToWrite})[{indexLetter}]";
                access          = ".";
                type            = type.GenericTypeArguments[0];
                allIndexes     += ", " + indexLetter;
                ++indexLetter;
            }
            if (typeof(BlzOptionalField).IsAssignableFrom(type))
            {
                flowControl.Add(new FlowControlBlock {
                    Statement = $"if ({name}.is_initialized())"
                });
                type = type.GenericTypeArguments[0];
            }

            if ((updateField.CustomFlag & CustomUpdateFieldFlag.ViewerDependent) != CustomUpdateFieldFlag.None)
            {
                nameUsedToWrite = $"ViewerDependentValue<{name}Tag>::GetValue({nameUsedToWrite}{allIndexes}, owner, receiver)";
            }

            if (!_create && _writeUpdateMasks)
            {
                GenerateBitIndexConditions(updateField, name, flowControl, previousControlFlow, arrayLoopBlockIndex);
            }

            RegisterDynamicChangesMaskFieldType(type);

            _fieldWrites.Add((name, false, (pcf) =>
            {
                WriteControlBlocks(_source, flowControl, pcf);
                WriteField(nameUsedToWrite, access, type, updateField.BitSize);
                _indent = 1;
                return(flowControl);
            }
                              ));

            if (!_create && updateField.SizeForField == null)
            {
                _delayedHeaderWrites.Add(() =>
                {
                    WriteFieldDeclaration(name, updateField);
                });
                if (_writeUpdateMasks)
                {
                    _changesMaskClears.Add($"    Base::ClearChangesMask({name});");
                }
            }

            return(flowControl);
        }
 public virtual IDynamicObjectData ReadCreateDynamicObjectData(Packet packet, UpdateFieldFlag flags, params object[] indexes)
 {
     return(null);
 }
 public virtual IActivePlayerData ReadCreateActivePlayerData(Packet packet, UpdateFieldFlag flags, params object[] indexes)
 {
     return(null);
 }
 public virtual IAzeriteItemData ReadCreateAzeriteItemData(Packet packet, UpdateFieldFlag flags, params object[] indexes)
 {
     return(null);
 }
 public virtual IContainerData ReadCreateContainerData(Packet packet, UpdateFieldFlag flags, params object[] indexes)
 {
     return(null);
 }
示例#13
0
 public UpdateField(Type type, UpdateFieldFlag flag, FieldInfo sizeForField, int size = 0, int bitSize = 0, CustomUpdateFieldFlag customFlag = CustomUpdateFieldFlag.None, [CallerLineNumber] int order = 0)
     : this(type, flag, size, bitSize, customFlag, order)
 {
     SizeForField = sizeForField ?? throw new ArgumentNullException(nameof(sizeForField));
 }
示例#14
0
 public virtual void WriteUpdate(WorldPacket data, UpdateFieldFlag fieldVisibilityFlags, T owner, Player receiver)
 {
 }
示例#15
0
 public abstract void WriteUpdate(WorldPacket data, UpdateFieldFlag fieldVisibilityFlags, T owner, Player receiver);