Exemplo n.º 1
0
        protected void WriteSpontaneousUpdate(UpdateMask mask, UpdatePacket packet, Character receiver, UpdateFieldId[] indices, bool visible)
        {
            // create mask
            for (var i = 0; i < indices.Length; i++)
            {
                var index = indices[i].RawId;
                var field = UpdateFieldMgr.Get(ObjectTypeId).Fields[index];
                for (var j = 0; j < field.Size; j++)
                {
                    mask.SetBit(index + j);
                }
            }

            // write mask
            mask.WriteTo(packet);

            // write values
            for (var i = mask.m_lowestIndex; i <= mask.m_highestIndex; i++)
            {
                if (mask.GetBit(i))
                {
                    if (visible)
                    {
                        WriteUpdateValue(packet, receiver, i);
                    }
                    else
                    {
                        packet.Write(0);
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected void WriteSpontaneousUpdate(UpdateMask mask, UpdatePacket packet, Character receiver,
                                              UpdateFieldId[] indices, bool visible)
        {
            for (int index1 = 0; index1 < indices.Length; ++index1)
            {
                int         rawId = indices[index1].RawId;
                UpdateField field = UpdateFieldMgr.Get(this.ObjectTypeId).Fields[rawId];
                for (int index2 = 0; (long)index2 < (long)field.Size; ++index2)
                {
                    mask.SetBit(rawId + index2);
                }
            }

            mask.WriteTo((PrimitiveWriter)packet);
            for (int lowestIndex = mask.m_lowestIndex; lowestIndex <= mask.m_highestIndex; ++lowestIndex)
            {
                if (mask.GetBit(lowestIndex))
                {
                    if (visible)
                    {
                        this.WriteUpdateValue(packet, receiver, lowestIndex);
                    }
                    else
                    {
                        packet.Write(0);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void _BuildValuesUpdate(ObjectUpdateType type, ObjectUpdateFlags flags, ref PacketOut pkt, IPlayer plr)
        {
            UpdateMask mask = new UpdateMask(State.UpdateFields.Length);
            PacketOut  tmp  = new PacketOut();


            UpdatefieldFlags visibilityFlags = UpdatefieldFlags.UF_FLAG_PUBLIC;

            if (plr.GetPrimaryKeyLong() == this.GetPrimaryKeyLong())
            {
                visibilityFlags |= UpdatefieldFlags.UF_FLAG_PRIVATE;
            }

            var fieldFlags = GetFlagVisibility();

            for (var i = 0; i < State.UpdateFields.Length; ++i)
            {
                //if ((fieldFlags[i] & visibilityFlags) == 0)
                //    continue;
                tmp.Write(State.UpdateFields[i].data);
                mask.SetBit(i);
            }

            pkt.Write((byte)mask.GetMaxBlockCount());
            for (var i = 0; i < mask.GetMaxBlockCount(); ++i)
            {
                pkt.Write(mask.m_blocks[i]);
            }

            pkt.Write(tmp);
        }
Exemplo n.º 4
0
        protected void SetFloat(int iField, float fValue)
        {
            if (m_UpdateValues[iField].Float == fValue)
            {
                return;
            }

            m_UpdateValues[iField].Float = fValue;

            m_PrivateUpdateMask.SetBit(iField);
            if (VisibilityManager.IsPublicField(iField) == true)
            {
                m_PublicUpdateMask.SetBit(iField);
            }

            OnRequestUpdate();
        }
Exemplo n.º 5
0
 /// <summary>
 /// Is called whenever a field has changed.
 /// Adds the given index to the corresponding UpdateMasks.
 /// </summary>
 protected internal void MarkUpdate(int index)
 {
     m_privateUpdateMask.SetBit(index);
     if (index > m_highestUsedUpdateIndex)
     {
         m_highestUsedUpdateIndex = index;
     }
     if (m_publicUpdateMask != m_privateUpdateMask && IsUpdateFieldPublic(index))
     {
         m_publicUpdateMask.SetBit(index);
     }
     if (m_requiresUpdate || !IsInWorld)
     {
         return;
     }
     RequestUpdate();
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="packet"></param>
        /// <param name="bUpdatingSelf"></param>
        private void WriteUpdateMaskForCreation(Packet packet)
        {
            UpdateMask updateMask = new UpdateMask(this.PlayerField.PrivateUpdateMask.Blocks);

            for (int iIndex = 0; iIndex < this.PlayerField.UpdateValues.Length; iIndex++)
            {
                if (this.PlayerField.UpdateValues[iIndex].UInt32 != 0)
                {
                    updateMask.SetBit(iIndex);
                }
            }

            updateMask.WriteToPacked(packet);

            for (int iIndex = 0; iIndex <= updateMask.HighestUpdatedIndex; iIndex++)
            {
                if (updateMask.GetBit(iIndex) == true)
                {
                    packet.WriterStream.Write((uint)this.PlayerField.UpdateValues[iIndex].UInt32);
                }
            }
        }
Exemplo n.º 7
0
        protected void WriteUpdateValues(bool forCreation, Character receiver, UpdateFieldFlags relation)
        {
            UpdateMask mask;

            if (forCreation)
            {
                // completely new
                var pos = receiver.m_updatePacket.Position;
                mask = new UpdateMask(m_highestUsedUpdateIndex);
                receiver.m_updatePacket.Position = pos + 1 + (4 * mask.MaxBlockCount);                  // skip over the index block
                for (var i = 0; i <= m_highestUsedUpdateIndex; i++)
                {
                    var flags = _UpdateFieldInfos.FieldFlags[i];
                    if (flags.HasAnyFlag(relation) && m_updateValues[i].UInt32 != 0)
                    {
                        mask.SetBit(i);
                        WriteUpdateValue(receiver.m_updatePacket, receiver, i);
                    }
                }
                var newPos = receiver.m_updatePacket.Position;
                receiver.m_updatePacket.Position = pos;
                mask.WriteFull(receiver.m_updatePacket);                                                                                // write the full index block
                receiver.m_updatePacket.Position = newPos;
                return;
                //WriteUpdateValues(receiver, relation, 0, _UpdateFieldInfos.Fields.Length, true);
            }

            if (relation.HasAnyFlag(UpdateFieldFlags.Private))
            {
                // Private
                mask = m_privateUpdateMask;
            }
            else if (relation.HasAnyFlag(UpdateFieldFlags.OwnerOnly | UpdateFieldFlags.GroupOnly))
            {
                // Group or Owner
                var pos = receiver.m_updatePacket.Position;
                mask = new UpdateMask(m_privateUpdateMask.m_highestIndex);
                receiver.m_updatePacket.Position = pos + 1 + (4 * mask.MaxBlockCount);          // skip over the index block
                for (var i = m_privateUpdateMask.m_lowestIndex; i <= m_privateUpdateMask.m_highestIndex; i++)
                {
                    var flags = _UpdateFieldInfos.FieldFlags[i];
                    if (flags.HasAnyFlag(relation) &&
                        (!flags.HasAnyFlag(UpdateFieldFlags.Public) || m_publicUpdateMask.GetBit(i)))
                    {
                        mask.SetBit(i);
                        WriteUpdateValue(receiver.m_updatePacket, receiver, i);
                    }
                }
                var newPos = receiver.m_updatePacket.Position;
                receiver.m_updatePacket.Position = pos;
                mask.WriteFull(receiver.m_updatePacket);                                                                        // write the full index block
                receiver.m_updatePacket.Position = newPos;
                //WriteUpdateValues(receiver, relation, m_privateUpdateMask.m_lowestIndex, m_privateUpdateMask.m_highestIndex, false);
                return;
            }
            else
            {
                // Public
                mask = m_publicUpdateMask;
            }

            mask.WriteTo(receiver.m_updatePacket);

            for (var i = mask.m_lowestIndex; i <= mask.m_highestIndex; i++)
            {
                if (mask.GetBit(i))
                {
                    WriteUpdateValue(receiver.m_updatePacket, receiver, i);
                }
            }
        }