Exemple #1
0
        public static void Init()
        {
            InitInheritance();
            FixFields();
            for (ObjectTypeId id = ObjectTypeId.Object; id < ObjectTypeId.Count; ++id)
            {
                UpdateField[] fields           = (UpdateField[])UpdateFields.AllFields[(int)id].Clone();
                int           offset           = int.MaxValue;
                bool          hasPrivateFields = false;
                UpdateField   updateField1     = null;
                for (int index = 0; index < fields.Length; ++index)
                {
                    UpdateField updateField2 = fields[index];
                    if (updateField2 != null)
                    {
                        if (offset == int.MaxValue)
                        {
                            offset = (int)updateField2.Offset;
                        }
                        updateField1     = updateField2;
                        hasPrivateFields = hasPrivateFields ||
                                           (updateField2.Flags & UpdateFieldFlags.Private) != UpdateFieldFlags.None;
                    }
                    else if (updateField1 != null)
                    {
                        fields[index] = updateField1;
                    }
                }

                ObjectTypeId          inheritedTypeId = InheritedTypeIds[(int)id];
                UpdateFieldCollection baseCollection;
                if (inheritedTypeId != ObjectTypeId.None)
                {
                    baseCollection = Collections[(int)inheritedTypeId];
                    if (baseCollection.Fields.Length >= fields.Length)
                    {
                        throw new Exception("BaseCollection of UpdateFields equal or bigger than inherited collection");
                    }
                    for (int index = 0; index < baseCollection.Fields.Length; ++index)
                    {
                        UpdateField field = baseCollection.Fields[index];
                        fields[index] = field;
                    }
                }
                else
                {
                    baseCollection = null;
                }

                Collections[(int)id] =
                    new UpdateFieldCollection(id, fields, baseCollection, offset, hasPrivateFields);
            }
        }
        internal UpdateFieldCollection(ObjectTypeId id, UpdateField[] fields, UpdateFieldCollection baseCollection,
                                       int offset, bool hasPrivateFields)
        {
            TypeId     = id;
            Fields     = fields;
            FieldFlags = new UpdateFieldFlags[fields.Length];
            List <int> intList1 = new List <int>(25);
            List <int> intList2 = new List <int>(25);
            List <int> intList3 = new List <int>(25);

            for (int index = 0; index < Fields.Length; ++index)
            {
                UpdateField field = Fields[index];
                FieldFlags[index] = field.Flags;
                if ((field.Flags & UpdateFieldFlags.Dynamic) != UpdateFieldFlags.None)
                {
                    intList3.Add(index);
                }
                else
                {
                    if ((field.Flags & UpdateFieldFlags.OwnerOnly) != UpdateFieldFlags.None)
                    {
                        intList1.Add(index);
                    }
                    if ((field.Flags & UpdateFieldFlags.GroupOnly) != UpdateFieldFlags.None)
                    {
                        intList2.Add(index);
                    }
                }
            }

            OwnerIndices     = intList1.ToArray();
            GroupIndices     = intList2.ToArray();
            DynamicIndices   = intList3.ToArray();
            BaseCollection   = baseCollection;
            Offset           = offset;
            HasPrivateFields = hasPrivateFields;
        }
        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;
        }
		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;
		}
Exemple #5
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);
			}
		}
Exemple #6
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);
            }
        }