Ejemplo n.º 1
0
		internal UpdateFieldCollection(ObjectTypeId id, UpdateField[] fields,
			UpdateFieldCollection baseCollection, int offset, bool hasPrivateFields)
		{
			TypeId = id;
			Fields = fields;
			FieldFlags = new UpdateFieldFlags[fields.Length];
			var ownerIndices = new List<int>(25);
			var groupIndices = new List<int>(25);
			var dynamicIndices = new List<int>(25);
			for (var i = 0; i < Fields.Length; i++)
			{
				var field = Fields[i];
				FieldFlags[i] = field.Flags;
				if ((field.Flags & UpdateFieldFlags.Dynamic) != 0)
				{
					dynamicIndices.Add(i);
				}
				else
				{
					if ((field.Flags & UpdateFieldFlags.OwnerOnly) != 0)
					{
						ownerIndices.Add(i);
					}
					if ((field.Flags & UpdateFieldFlags.GroupOnly) != 0)
					{
						groupIndices.Add(i);
					}
				}
			}
			OwnerIndices = ownerIndices.ToArray();
			GroupIndices = groupIndices.ToArray();
			DynamicIndices = dynamicIndices.ToArray();
			BaseCollection = baseCollection;
			Offset = offset;
			HasPrivateFields = hasPrivateFields;
		}
Ejemplo n.º 2
0
		public UpdateFieldWriter(UpdateField[][] fields)
		{
			m_fields = fields;
		}
Ejemplo n.º 3
0
        public static void Init()
        {
            InitInheritance();
            FixFields();

            for (var i = ObjectTypeId.Object; i < (ObjectTypeId)UpdateField.ObjectTypeCount; i++)
            {
                var fields = (UpdateField[])UpdateFields.AllFields[(int)i].Clone();

                var         offset           = int.MaxValue;
                var         hasPrivateFields = false;
                UpdateField lastField        = null;
                for (var k = 0; k < fields.Length; k++)
                {
                    var field = fields[k];
                    if (field != null)
                    {
                        if (offset == int.MaxValue)
                        {
                            offset = (int)field.Offset;
                        }
                        lastField        = field;
                        hasPrivateFields = hasPrivateFields || (field.Flags & UpdateFieldFlags.Private) != UpdateFieldFlags.None;
                    }
                    else
                    {
                        if (lastField != null)
                        {
                            fields[k] = lastField;
                        }
                    }
                }


                var baseType = InheritedTypeIds[(int)i];

                UpdateFieldCollection baseCollection;
                if (baseType != ObjectTypeId.None)
                {
                    baseCollection = Collections[(int)baseType];

                    if (baseCollection.Fields.Length >= fields.Length)
                    {
                        throw new Exception("BaseCollection of UpdateFields equal or bigger than inherited collection");
                    }

                    // copy all inherited fields into this Collection's array
                    for (var j = 0; j < baseCollection.Fields.Length; j++)
                    {
                        var field = baseCollection.Fields[j];
                        fields[j] = field;
                    }
                }
                else
                {
                    baseCollection = null;
                }

                Collections[(int)i] = new UpdateFieldCollection(i, fields, baseCollection, offset, hasPrivateFields);
            }
        }