예제 #1
0
 public void ApplyValues(UpdateFields values)
 {
     foreach (var pair in values)
     {
         this.m_updateFields[pair.Key] = pair.Value;
     }
 }
예제 #2
0
        protected WowObject(ObjectTypeId typeid)
        {
            m_updateMask = new BitArray((int)UpdateFields.GetCount(typeid, uint.MaxValue));

            this.TypeId   = typeid;
            this.TypeMask = (ObjectTypeMask)(1 << (int)typeid) | ObjectTypeMask.Object;
        }
예제 #3
0
        public UpdateFields CreateUpdate()
        {
            var ret = new UpdateFields();

            for (int i = 0; i < m_updateMask.Length; ++i)
            {
                if (m_updateMask[i])
                {
                    ret.Add((uint)i, GetUInt((uint)i));
                }
            }

            ResetUpdatedFields();

            return(ret);
        }
예제 #4
0
        private void PrintValues(System.Text.StringBuilder builder, UpdateFields values, ObjectTypeId type)
        {
            foreach (var pair in values)
            {
                var uf = UpdateFields.GetUpdateField(pair.Key, type);

                if (uf.Type == UpdateFieldType.Long && uf.Id.ToString().EndsWith("_HIPART"))
                    continue;

                builder.Append("    ");
                builder.Append(uf.Id);
                builder.Append(" = ");

                if (uf.Type == UpdateFieldType.Long && values.ContainsKey(pair.Key + 1))
                    builder.Append(uf.Print(((ulong)values[pair.Key + 1] << 32) | (ulong)pair.Value));
                else
                    builder.Append(uf.Print(pair.Value));

                builder.AppendLine();
            }
        }
예제 #5
0
        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);
        }
예제 #6
0
        private UpdateFields ReadValues(StreamHandler Reader)
        {
            var values = new UpdateFields();

            byte blocksCount = Reader.ReadByte();
            int[] updatemask = new int[blocksCount];

            for (int i = 0; i < updatemask.Length; ++i)
                updatemask[i] = Reader.ReadInt32();

            var mask = new BitArray(updatemask);

            for (uint i = 0; i < mask.Count; ++i)
                if (mask[(int)i])
                    values[i] = Reader.ReadUInt32();

            return values;
        }
예제 #7
0
 public void SetValues(UpdateFields values)
 {
     this.m_updateFields = values;
 }
예제 #8
0
        public UpdateFields CreateUpdate()
        {
            var ret = new UpdateFields();

            for (int i = 0; i < m_updateMask.Length; ++i)
            {
                if (m_updateMask[i])
                    ret.Add((uint)i, GetUInt((uint)i));
            }

            ResetUpdatedFields();

            return ret;
        }
예제 #9
0
 public void ApplyValues(UpdateFields values)
 {
     foreach (var pair in values)
         this.m_updateFields[pair.Key] = pair.Value;
 }
예제 #10
0
 public void SetValues(UpdateFields values)
 {
     this.m_updateFields = values;
 }