예제 #1
0
        int ImplicitUpgradeCalculateFieldStartIndex(Definition def, int size_of, BlamVersion engine, uint flags)
        {
            int index;

            if (!implicitUpgradeFieldIndexes.TryGetValue(size_of, out index))
            {
                int current_size_of = VersioningGetRealSizeOf(flags);
                for (int x = def.Count - 1; x >= 0; x--)
                {
                    var f = def[x];

                    //if(f.FieldType != FieldType.UselessPad)
                    current_size_of -= FieldUtil.Sizeof(f, engine, false, flags);

                    if (current_size_of == size_of)
                    {
                        implicitUpgradeFieldIndexes.Add(size_of, index = x);
                        break;
                    }
                    else if (current_size_of < size_of)                     // field layouts don't match up
                    {
                        return(-1);
                    }
                }
            }

            return(index);
        }
예제 #2
0
        private Definition Parse(Definition parent)
        {
            Definition def;

            if (parent == null)
            {
                def = this.def;
            }
            else
            {
                def = new Definition();
            }

            Field temp = null;

            currentField.Read(InputStream);
            IStructureOwner struct_owner = (IStructureOwner)def;

            while (currentField.Type != FieldType.Terminator)
            {
                def.Add(temp = FieldUtil.CreateFromDefinitionItem(engine, struct_owner.OwnerObject, currentField));

                if (currentField.Type == FieldType.Block ||
                    currentField.Type == FieldType.Struct)
                {
                    Parse(temp.FieldValue as Definition);
                }

                currentField.Read(InputStream);
            }

            return(def);
        }