Example #1
0
        public override string ToString()
        {
            var sb = new StringBuilder(Type);

            switch (Type)
            {
            case "StructProperty":
                sb.AppendFormat("<{0}>", StructType);
                break;

            case "ByteProperty" when EnumName != null:
            case "EnumProperty":
                sb.AppendFormat("<{0}>", EnumName);
                break;

            case "ArrayProperty":
            case "SetProperty":
                sb.AppendFormat("<{0}>", InnerTypeData?.ToString() ?? InnerType);
                break;

            case "MapProperty":
                sb.AppendFormat("<{0}, {1}>", InnerTypeData?.ToString() ?? InnerType, ValueTypeData?.ToString() ?? ValueType);
                break;
            }

            return(sb.ToString());
        }
Example #2
0
        public FPropertyTag(FAssetArchive Ar, PropertyInfo info, ReadType type)
        {
            Name            = new FName(info.Name);
            PropertyType    = new FName(info.MappingType.Type);
            ArrayIndex      = 0;
            TagData         = new FPropertyTagData(info.MappingType);
            HasPropertyGuid = false;
            PropertyGuid    = null;

            var pos = Ar.Position;

            try
            {
                Tag = FPropertyTagType.ReadPropertyTagType(Ar, PropertyType.Text, TagData, type);
            }
            catch (ParserException e)
            {
                throw new ParserException($"Failed to read FPropertyTagType {TagData?.ToString() ?? PropertyType.Text} {Name.Text}", e);
            }

            Size = (int)(Ar.Position - pos);
        }
Example #3
0
        public FPropertyTag(FAssetArchive Ar, bool readData)
        {
            Name = Ar.ReadFName();
            if (Name.IsNone)
            {
                return;
            }

            PropertyType = Ar.ReadFName();
            Size         = Ar.Read <int>();
            ArrayIndex   = Ar.Read <int>();
            TagData      = new FPropertyTagData(Ar, PropertyType.Text);
            if (Ar.Ver >= UE4Version.VER_UE4_PROPERTY_GUID_IN_PROPERTY_TAG)
            {
                HasPropertyGuid = Ar.ReadFlag();
                if (HasPropertyGuid)
                {
                    PropertyGuid = Ar.Read <FGuid>();
                }
            }

            if (readData)
            {
                var pos      = Ar.Position;
                var finalPos = pos + Size;
                try
                {
                    Tag = FPropertyTagType.ReadPropertyTagType(Ar, PropertyType.Text, TagData, ReadType.NORMAL);
#if DEBUG
                    if (finalPos != Ar.Position)
                    {
                        Log.Debug("FPropertyTagType {0} {1} was not read properly, pos {2}, calculated pos {3}", TagData?.ToString() ?? PropertyType.Text, Name.Text, Ar.Position, finalPos);
                    }
#endif
                }
                catch (ParserException e)
                {
#if DEBUG
                    if (finalPos != Ar.Position)
                    {
                        Log.Warning(e, "Failed to read FPropertyTagType {0} {1}, skipping it", TagData?.ToString() ?? PropertyType.Text, Name.Text);
                    }
#endif
                }
                finally
                {
                    // Always seek to calculated position, no need to crash
                    Ar.Position = finalPos;
                }
            }
        }