Пример #1
0
 public void Unserialize(UndertaleReader reader)
 {
     Name        = reader.ReadUndertaleString();
     Occurrences = reader.ReadUInt32();
     if (Occurrences > 0)
     {
         if (reader.GMS2_3)
         {
             GMS2_3       = true;
             FirstAddress = reader.GetUndertaleObjectAtAddress <UndertaleInstruction>(reader.ReadUInt32() - 4);
         }
         else
         {
             FirstAddress = reader.ReadUndertaleObjectPointer <UndertaleInstruction>();
         }
         UndertaleInstruction.Reference <UndertaleFunction> .ParseReferenceChain(reader, this);
     }
     else
     {
         if (reader.ReadInt32() != -1)
         {
             throw new Exception("Function with no occurrences, but still has a first occurrence address");
         }
         FirstAddress = null;
     }
 }
Пример #2
0
    /// <inheritdoc />
    public void Unserialize(UndertaleReader reader)
    {
        Name          = reader.ReadUndertaleString();
        DisplayName   = reader.ReadUndertaleString();
        EmSize        = reader.ReadUInt32();
        EmSizeIsFloat = false;

        // since the float is always written negated, it has the first bit set.
        if ((EmSize & (1 << 31)) != 0)
        {
            float fsize = -BitConverter.ToSingle(BitConverter.GetBytes(EmSize), 0);
            EmSize        = (uint)fsize;
            EmSizeIsFloat = true;
        }

        Bold         = reader.ReadBoolean();
        Italic       = reader.ReadBoolean();
        RangeStart   = reader.ReadUInt16();
        Charset      = reader.ReadByte();
        AntiAliasing = reader.ReadByte();
        RangeEnd     = reader.ReadUInt32();
        Texture      = reader.ReadUndertaleObjectPointer <UndertaleTexturePageItem>();
        ScaleX       = reader.ReadSingle();
        ScaleY       = reader.ReadSingle();
        if (reader.undertaleData.GeneralInfo?.BytecodeVersion >= 17)
        {
            AscenderOffset = reader.ReadInt32();
        }
        if (reader.undertaleData.GMS2022_2)
        {
            Ascender = reader.ReadUInt32();
        }
        Glyphs = reader.ReadUndertaleObject <UndertalePointerList <Glyph> >();
    }
Пример #3
0
        public void Unserialize(UndertaleReader reader)
        {
            Name        = reader.ReadUndertaleString();
            Occurrences = reader.ReadUInt32();
            if (Occurrences > 0)
            {
                FirstAddress = reader.ReadUndertaleObjectPointer <UndertaleInstruction>();

                // Parse the chain of references
                UndertaleInstruction.Reference <UndertaleFunction> reference = null;
                uint addr = reader.GetAddressForUndertaleObject(FirstAddress);
                for (int i = 0; i < Occurrences; i++)
                {
                    reference = reader.GetUndertaleObjectAtAddress <UndertaleInstruction>(addr).GetReference <UndertaleFunction>();
                    if (reference == null)
                    {
                        throw new IOException("Failed to find reference at " + addr);
                    }
                    reference.Target = this;
                    addr            += (uint)reference.NextOccurrenceOffset;
                }
                UnknownChainEndingValue = reference.NextOccurrenceOffset;
            }
            else
            {
                if (reader.ReadInt32() != -1)
                {
                    throw new Exception("Function with no occurrences, but still has a first occurrence address");
                }
                FirstAddress = null;
            }
        }
        public void Unserialize(UndertaleReader reader)
        {
            Name = reader.ReadUndertaleString();

            // Read the pointers
            TexturePages = reader.ReadUndertaleObjectPointer <UndertaleSimpleResourcesList <UndertaleEmbeddedTexture, UndertaleChunkTXTR> >();
            Sprites      = reader.ReadUndertaleObjectPointer <UndertaleSimpleResourcesList <UndertaleSprite, UndertaleChunkSPRT> >();
            SpineSprites = reader.ReadUndertaleObjectPointer <UndertaleSimpleResourcesList <UndertaleSprite, UndertaleChunkSPRT> >();
            Fonts        = reader.ReadUndertaleObjectPointer <UndertaleSimpleResourcesList <UndertaleFont, UndertaleChunkFONT> >();
            Tilesets     = reader.ReadUndertaleObjectPointer <UndertaleSimpleResourcesList <UndertaleBackground, UndertaleChunkBGND> >();

            // Read the objects, throwing an error if the pointers are invalid
            reader.ReadUndertaleObject(TexturePages);
            reader.ReadUndertaleObject(Sprites);
            reader.ReadUndertaleObject(SpineSprites);
            reader.ReadUndertaleObject(Fonts);
            reader.ReadUndertaleObject(Tilesets);
        }
 public void Unserialize(UndertaleReader reader)
 {
     Scaled = reader.ReadUInt32();
     if (reader.undertaleData.GeneralInfo.Major >= 2)
     {
         GeneratedMips = reader.ReadUInt32();
     }
     TextureData = reader.ReadUndertaleObjectPointer <TexData>();
 }
Пример #6
0
        public void Unserialize(UndertaleReader reader)
        {
            Name = reader.ReadUndertaleString();

            // Read the pointers
            TexturePages = reader.ReadUndertaleObjectPointer <UndertaleSimpleResourcesList <UndertaleEmbeddedTexture, UndertaleChunkTXTR> >();
            Sprites      = reader.ReadUndertaleObjectPointer <UndertaleSimpleResourcesList <UndertaleSprite, UndertaleChunkSPRT> >();
            SpineSprites = reader.ReadUndertaleObjectPointer <UndertaleSimpleResourcesList <UndertaleSprite, UndertaleChunkSPRT> >();
            Fonts        = reader.ReadUndertaleObjectPointer <UndertaleSimpleResourcesList <UndertaleFont, UndertaleChunkFONT> >();
            Tilesets     = reader.ReadUndertaleObjectPointer <UndertaleSimpleResourcesList <UndertaleBackground, UndertaleChunkBGND> >();

            // Read the objects, throwing an error if the pointers are invalid
            if (reader.ReadUndertaleObject <UndertaleSimpleResourcesList <UndertaleEmbeddedTexture, UndertaleChunkTXTR> >() != TexturePages ||
                reader.ReadUndertaleObject <UndertaleSimpleResourcesList <UndertaleSprite, UndertaleChunkSPRT> >() != Sprites ||
                reader.ReadUndertaleObject <UndertaleSimpleResourcesList <UndertaleSprite, UndertaleChunkSPRT> >() != SpineSprites ||
                reader.ReadUndertaleObject <UndertaleSimpleResourcesList <UndertaleFont, UndertaleChunkFONT> >() != Fonts ||
                reader.ReadUndertaleObject <UndertaleSimpleResourcesList <UndertaleBackground, UndertaleChunkBGND> >() != Tilesets)
            {
                throw new UndertaleSerializationException("Invalid pointer to SimpleResourcesList");
            }
        }
Пример #7
0
        public void Unserialize(UndertaleReader reader)
        {
            uint count = reader.ReadUInt32();

            Clear();
            for (uint i = 0; i < count; i++)
            {
                try
                {
                    Add(reader.ReadUndertaleObjectPointer <T>());
                }
                catch (UndertaleSerializationException e)
                {
                    throw new UndertaleSerializationException(e.Message + "\nwhile reading pointer to item " + (i + 1) + " of " + count + " in a list of " + typeof(T).FullName, e);
                }
            }
            if (Count > 0 && reader.Position != reader.GetAddressForUndertaleObject(this[0]))
            {
                int skip = (int)reader.GetAddressForUndertaleObject(this[0]) - (int)reader.Position;
                if (skip > 0)
                {
                    //Console.WriteLine("Skip " + skip + " bytes of blobs");
                    reader.Position = reader.Position + (uint)skip;
                }
                else
                {
                    throw new IOException("First list item starts inside the pointer list?!?!");
                }
            }
            for (uint i = 0; i < count; i++)
            {
                try
                {
                    (this[(int)i] as PrePaddedObject)?.UnserializePrePadding(reader);
                    T obj = reader.ReadUndertaleObject <T>();
                    if (!obj.Equals(this[(int)i]))
                    {
                        throw new UndertaleSerializationException("Something got misaligned...");
                    }
                    if (i != count - 1)
                    {
                        (obj as PaddedObject)?.UnserializePadding(reader);
                    }
                }
                catch (UndertaleSerializationException e)
                {
                    throw new UndertaleSerializationException(e.Message + "\nwhile reading item " + (i + 1) + " of " + count + " in a list of " + typeof(T).FullName, e);
                }
            }
        }
 public void Unserialize(UndertaleReader reader)
 {
     Name         = reader.ReadUndertaleString();
     InstanceType = (UndertaleInstruction.InstanceType)reader.ReadInt32();
     VarID        = reader.ReadInt32();
     Occurrences  = reader.ReadUInt32();
     if (Occurrences > 0)
     {
         FirstAddress = reader.ReadUndertaleObjectPointer <UndertaleInstruction>();
         UndertaleInstruction.Reference <UndertaleVariable> .ParseReferenceChain(reader, this);
     }
     else
     {
         if (reader.ReadInt32() != -1)
         {
             throw new Exception("Variable with no occurrences, but still has a first occurrence address");
         }
         FirstAddress = null;
     }
 }
Пример #9
0
        //private static int id = 0;
        public void Unserialize(UndertaleReader reader)
        {
            Name         = reader.ReadUndertaleString();
            InstanceType = (UndertaleInstruction.InstanceType)reader.ReadInt32();
            VarID        = reader.ReadInt32();
            Occurrences  = reader.ReadUInt32();
            //Debug.WriteLine("Variable " + (id++) + " at " + reader.GetAddressForUndertaleObject(Name).ToString("X8") + " child of " + Unknown);
            if (Occurrences > 0)
            {
                FirstAddress = reader.ReadUndertaleObjectPointer <UndertaleInstruction>();

                // Parse the chain of references
                UndertaleInstruction.Reference <UndertaleVariable> reference = null;
                uint addr = reader.GetAddressForUndertaleObject(FirstAddress);
                for (int i = 0; i < Occurrences; i++)
                {
                    reference = reader.GetUndertaleObjectAtAddress <UndertaleInstruction>(addr).GetReference <UndertaleVariable>();
                    if (reference == null)
                    {
                        throw new IOException("Failed to find reference at " + addr);
                    }
                    reference.Target = this;
                    // Debug.WriteLine("* " + addr.ToString("X8"));
                    addr += (uint)reference.NextOccurrenceOffset;
                }
                //Debug.WriteLine("* " + reference.NextOccurrenceOffset.ToString() + " (ending value)");
                UnknownChainEndingValue = reference.NextOccurrenceOffset;
            }
            else
            {
                if (reader.ReadInt32() != -1)
                {
                    throw new Exception("Variable with no occurrences, but still has a first occurrence address");
                }
                FirstAddress = null;
            }
        }
Пример #10
0
 /// <inheritdoc />
 public void Unserialize(UndertaleReader reader)
 {
     Name         = reader.ReadUndertaleString();
     TextureEntry = reader.ReadUndertaleObjectPointer <UndertaleTexturePageItem>();
 }