public void ApplyValues(UpdateFields values) { foreach (var pair in values) { this.m_updateFields[pair.Key] = pair.Value; } }
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; }
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); }
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(); } }
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); }
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; }
public void SetValues(UpdateFields values) { this.m_updateFields = values; }
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; }
public void ApplyValues(UpdateFields values) { foreach (var pair in values) this.m_updateFields[pair.Key] = pair.Value; }