public void Unserialize(UndertaleReader reader) { Value = reader.ReadInt32(); }
internal override void UnserializeChunk(UndertaleReader reader) { Object = reader.ReadUndertaleObject <T>(); }
internal override void UnserializeChunk(UndertaleReader reader) { }
internal override void UnserializeChunk(UndertaleReader reader) { Alignment = 8; base.UnserializeChunk(reader); }
private void CheckForEffectData(UndertaleReader reader) { // Do a length check on room layers to see if this is 2022.1 or higher if (!reader.undertaleData.GMS2022_1 && reader.undertaleData.GMS2_3) { uint returnTo = reader.Position; // Iterate over all rooms until a length check is performed int roomCount = reader.ReadInt32(); bool finished = false; for (uint roomIndex = 0; roomIndex < roomCount && !finished; roomIndex++) { // Advance to room data we're interested in (and grab pointer for next room) reader.Position = returnTo + 4 + (4 * roomIndex); uint roomPtr = (uint)reader.ReadInt32(); reader.Position = roomPtr + (22 * 4); // Get the pointer for this room's layer list, as well as pointer to sequence list uint layerListPtr = (uint)reader.ReadInt32(); int seqnPtr = reader.ReadInt32(); reader.Position = layerListPtr; int layerCount = reader.ReadInt32(); if (layerCount >= 1) { // Get pointer into the individual layer data (plus 8 bytes) for the first layer in the room uint jumpOffset = (uint)(reader.ReadInt32() + 8); // Find the offset for the end of this layer int nextOffset; if (layerCount == 1) { nextOffset = seqnPtr; } else { nextOffset = reader.ReadInt32(); // (pointer to next element in the layer list) } // Actually perform the length checks, depending on layer data reader.Position = jumpOffset; switch ((LayerType)reader.ReadInt32()) { case LayerType.Background: if (nextOffset - reader.Position > 16 * 4) { reader.undertaleData.GMS2022_1 = true; } finished = true; break; case LayerType.Instances: reader.Position += 6 * 4; int instanceCount = reader.ReadInt32(); if (nextOffset - reader.Position != (instanceCount * 4)) { reader.undertaleData.GMS2022_1 = true; } finished = true; break; case LayerType.Assets: reader.Position += 6 * 4; int tileOffset = reader.ReadInt32(); if (tileOffset != reader.Position + 8) { reader.undertaleData.GMS2022_1 = true; } finished = true; break; case LayerType.Tiles: reader.Position += 7 * 4; int tileMapWidth = reader.ReadInt32(); int tileMapHeight = reader.ReadInt32(); if (nextOffset - reader.Position != (tileMapWidth * tileMapHeight * 4)) { reader.undertaleData.GMS2022_1 = true; } finished = true; break; case LayerType.Effect: reader.Position += 7 * 4; int propertyCount = reader.ReadInt32(); if (nextOffset - reader.Position != (propertyCount * 3 * 4)) { reader.undertaleData.GMS2022_1 = true; } finished = true; break; } } } reader.Position = returnTo; } }
internal override void UnserializeChunk(UndertaleReader reader) { throw new NotImplementedException(); }
public void Unserialize(UndertaleReader reader) { Content = reader.ReadGMString(); }
public void Unserialize(UndertaleReader reader) { Other = reader.ReadInt16(); Amount = reader.ReadInt16(); }
public void Unserialize(UndertaleReader reader) { Name = reader.ReadUndertaleString(); TextureEntry = reader.ReadUndertaleObjectPointer <UndertaleTexturePageItem>(); }
public void Unserialize(UndertaleReader reader) { Name = reader.ReadUndertaleString(); GraphType = (GraphTypeEnum)reader.ReadUInt32(); Channels = reader.ReadUndertaleObject <UndertaleSimpleList <Channel> >(); }
public void Unserialize(UndertaleReader reader) { Index = reader.ReadUInt32(); Name = reader.ReadUndertaleString(); }
public static void Main(string[] args) { UndertaleData data; Parser.Default.ParseArguments <Options>(args).WithParsed(opts => { try { Process[] processes = Process.GetProcessesByName("MyRabbitsAreGone"); if (processes.Length != 0) { if (opts.CloseBeforeStarting) { Console.WriteLine("Closing all open instances of My Rabbits Are Gone"); foreach (var proc in processes) { proc.CloseMainWindow(); } } else { Console.WriteLine("Close My Rabbits Are Gone before continuing."); } while (processes.Length != 0) { Thread.Sleep(1000); processes = Process.GetProcessesByName("MyRabbitsAreGone"); } Console.WriteLine("Continuing!"); } if (Path.GetFileNameWithoutExtension(opts.FileLocation) != "data") //cross platform momento { throw new Exception("File name is not data.win!"); } if (File.Exists(opts.FileLocation + ".bak")) { Console.WriteLine("Found a backup, overwriting current data.win with it."); File.Delete(opts.FileLocation); opts.FileLocation += ".bak"; } else { Console.WriteLine("Backup not found, doing that now."); File.Copy(opts.FileLocation, opts.FileLocation + ".bak"); } if (!File.Exists(opts.FileLocation)) { throw new Exception("File does not exist!"); } var read = new UndertaleReader(File.OpenRead(opts.FileLocation)); Data = data = read.ReadUndertaleData(); read.Close(); var md5 = MD5.Create(); Engine engine = new Engine(cfg => cfg.AllowClr( typeof(UndertaleData).Assembly, typeof(UndertaleGameObject).Assembly, typeof(File).Assembly).DebugMode()); engine = engine.SetValue("RoomGameObject", TypeReference.CreateTypeReference(engine, typeof(UndertaleRoom.GameObject))).SetValue( "EventAction", TypeReference.CreateTypeReference(engine, typeof(UndertaleGameObject.EventAction))).SetValue( "UEvent", TypeReference.CreateTypeReference(engine, typeof(UndertaleGameObject.Event))); engine = engine.SetValue("log", new Action <object>(Console.WriteLine)) .SetValue("Data", data) .SetValue("emmdeefive", new Func <string, string>((s) => { var hash = md5.ComputeHash(Encoding.ASCII.GetBytes(s)); StringBuilder sb = new StringBuilder(); for (int i = 0; i < hash.Length; i++) { sb.Append(hash[i].ToString("X2")); } return(sb.ToString()); })); Console.WriteLine("Passing control to patcher.js"); engine.Execute(File.ReadAllText("patcher.js")).Invoke("main"); Console.WriteLine("Exited JavaScript mode."); Console.WriteLine("Now writing data.win..."); if (opts.FileLocation.EndsWith(".bak")) { opts.FileLocation = opts.FileLocation.Slice(0, opts.FileLocation.Length - 4); } Console.WriteLine(opts.FileLocation); var write = new UndertaleWriter(File.OpenWrite(opts.FileLocation)); write.WriteUndertaleData(data); write.Close(); Console.WriteLine("Written!"); if (!opts.DoNotRunLater) { Process.Start(Path.Combine( Path.GetDirectoryName(opts.FileLocation) ?? throw new InvalidOperationException(), "MyRabbitsAreGone.exe")); if (opts.RunTwo) { Process.Start(Path.Combine( Path.GetDirectoryName(opts.FileLocation) ?? throw new InvalidOperationException(), "MyRabbitsAreGone.exe")); } Console.WriteLine("Now starting the game :)"); Process.GetCurrentProcess().Kill(); } Console.WriteLine("Seeya!"); } catch (JavaScriptException e) { Console.Error.WriteLine("Error \"{0}\" at {1}:{2}", e.Message, e.LineNumber, e.Column); Console.Error.WriteLine(e.CallStack); Environment.Exit(1); } catch (Exception e) { Console.Error.WriteLine("{0}: \"{1}\"", e.GetType().Name, e.Message); Console.Error.WriteLine(e.Source); Environment.Exit(1); } }); }
public override void Unserialize(UndertaleReader reader) { Value = reader.ReadSingle(); base.Unserialize(reader); }
public override void Unserialize(UndertaleReader reader) { base.Unserialize(reader); List = new UndertaleSimpleList <Keyframe <StringData> >(); List.Unserialize(reader); }
public void Unserialize(UndertaleReader reader) { Type = (ExtensionVarType)reader.ReadUInt32(); }
internal override void UnserializeChunk(UndertaleReader reader) { Functions = reader.ReadUndertaleObject <UndertaleSimpleList <UndertaleFunction> >(); CodeLocals = reader.ReadUndertaleObject <UndertaleSimpleList <UndertaleCodeLocals> >(); }
internal override void UnserializeChunk(UndertaleReader reader) { base.UnserializeChunk(reader); Padding = reader.ReadBytes(512); }
public void Unserialize(UndertaleReader reader) { Name = reader.ReadUndertaleString(); Type = (ShaderType)(reader.ReadUInt32() & 0x7FFFFFFFu); // in big endian? GLSL_ES_Vertex = reader.ReadUndertaleString(); GLSL_ES_Fragment = reader.ReadUndertaleString(); GLSL_Vertex = reader.ReadUndertaleString(); GLSL_Fragment = reader.ReadUndertaleString(); HLSL9_Vertex = reader.ReadUndertaleString(); HLSL9_Fragment = reader.ReadUndertaleString(); HLSL11_VertexData.Unserialize(reader, false); HLSL11_PixelData.Unserialize(reader, false); VertexShaderAttributes = reader.ReadUndertaleObject<UndertaleSimpleList<VertexShaderAttribute>>(); Version = reader.ReadInt32(); PSSL_VertexData.Unserialize(reader); PSSL_PixelData.Unserialize(reader); Cg_PSVita_VertexData.Unserialize(reader); Cg_PSVita_PixelData.Unserialize(reader); if (Version >= 2) { Cg_PS3_VertexData.Unserialize(reader); Cg_PS3_PixelData.Unserialize(reader); } if (!HLSL11_VertexData.IsNull) { ReadPadding(reader, 7); // Calculate length of data uint next; if (!HLSL11_PixelData.IsNull) next = HLSL11_PixelData._Position; else next = _EntryEnd; int length = (int)(next - reader.Position); HLSL11_VertexData.ReadData(reader, length); } if (!HLSL11_PixelData.IsNull) { ReadPadding(reader, 7); // Calculate length of data uint next; if (!PSSL_VertexData.IsNull) next = PSSL_VertexData._Position; else next = _EntryEnd; int length = (int)(next - reader.Position); HLSL11_PixelData.ReadData(reader, length); } if (!PSSL_VertexData.IsNull) { ReadPadding(reader, 7); // Calculate length of data uint next; if (!PSSL_PixelData.IsNull) next = PSSL_PixelData._Position; else next = _EntryEnd; int length = (int)(next - reader.Position); PSSL_VertexData.ReadData(reader, length); } if (!PSSL_PixelData.IsNull) { ReadPadding(reader, 7); // Calculate length of data uint next; if (!Cg_PSVita_VertexData.IsNull) next = Cg_PSVita_VertexData._Position; else next = _EntryEnd; int length = (int)(next - reader.Position); PSSL_PixelData.ReadData(reader, length); } if (!Cg_PSVita_VertexData.IsNull) { ReadPadding(reader, 7); // Calculate length of data uint next; if (!Cg_PSVita_PixelData.IsNull) next = Cg_PSVita_PixelData._Position; else next = _EntryEnd; int length = (int)(next - reader.Position); Cg_PSVita_VertexData.ReadData(reader, length); } if (!Cg_PSVita_PixelData.IsNull) { ReadPadding(reader, 7); // Calculate length of data uint next; if (!Cg_PS3_VertexData.IsNull) next = Cg_PS3_VertexData._Position; else next = _EntryEnd; int length = (int)(next - reader.Position); Cg_PSVita_PixelData.ReadData(reader, length); } if (Version >= 2) { if (!Cg_PS3_VertexData.IsNull) { ReadPadding(reader, 15); // Calculate length of data uint next; if (!Cg_PS3_PixelData.IsNull) next = Cg_PS3_PixelData._Position; else next = _EntryEnd; int length = (int)(next - reader.Position); Cg_PS3_VertexData.ReadData(reader, length); } if (!Cg_PS3_PixelData.IsNull) { ReadPadding(reader, 15); // Calculate length of data uint next = _EntryEnd; // final possible data, nothing else to check for int length = (int)(next - reader.Position); Cg_PS3_PixelData.ReadData(reader, length); } } }
public void Unserialize(UndertaleReader reader) { throw new NotImplementedException(); }
public void Unserialize(UndertaleReader reader) { NextOccurrenceOffset = reader.ReadInt24(); Type = (VariableType)reader.ReadByte(); }
public void Unserialize(UndertaleReader reader) { X = reader.ReadSingle(); Y = reader.ReadSingle(); Speed = reader.ReadSingle(); }
public void Unserialize(UndertaleReader reader) { uint instructionStartAddress = reader.Position; reader.ReadByte(); reader.ReadByte(); reader.ReadByte(); // skip for now, we'll read them later Kind = (Opcode)reader.ReadByte(); reader.Position = instructionStartAddress; switch (GetInstructionType(Kind)) { case InstructionType.SingleTypeInstruction: case InstructionType.DoubleTypeInstruction: case InstructionType.ComparisonInstruction: { DupExtra = reader.ReadByte(); if (DupExtra != 0 && Kind != Opcode.Dup) { throw new IOException("Invalid padding in " + Kind.ToString().ToUpper()); } ComparisonKind = (ComparisonType)reader.ReadByte(); if ((Kind == Opcode.Cmp) != ((byte)ComparisonKind != 0)) { throw new IOException("Got unexpected comparison type in " + Kind.ToString().ToUpper() + " (should be only in CMP)"); } byte TypePair = reader.ReadByte(); Type1 = (DataType)(TypePair & 0xf); Type2 = (DataType)(TypePair >> 4); if (GetInstructionType(Kind) == InstructionType.SingleTypeInstruction && Type2 != (byte)0) { throw new IOException("Second type should be 0 in " + Kind.ToString().ToUpper()); } if (reader.ReadByte() != (byte)Kind) { throw new Exception("really shouldn't happen"); } } break; case InstructionType.GotoInstruction: { uint v = reader.ReadUInt24(); // TODO: This is SO WRONG that I don't even believe it. Is that Int24 or Int23?!?! uint r = v & 0x003FFFFF; if ((v & 0x00C00000) != 0) { r |= 0xFFC00000; } JumpOffset = (int)r; JumpOffsetIsWeird = (v & 0x00800000) != 0; if (reader.ReadByte() != (byte)Kind) { throw new Exception("really shouldn't happen"); } } break; case InstructionType.PopInstruction: { TypeInst = (InstanceType)reader.ReadInt16(); byte TypePair = reader.ReadByte(); Type1 = (DataType)(TypePair & 0xf); Type2 = (DataType)(TypePair >> 4); if (reader.ReadByte() != (byte)Kind) { throw new Exception("really shouldn't happen"); } Destination = reader.ReadUndertaleObject <Reference <UndertaleVariable> >(); } break; case InstructionType.PushInstruction: { short val = reader.ReadInt16(); Type1 = (DataType)reader.ReadByte(); if (reader.ReadByte() != (byte)Kind) { throw new Exception("really shouldn't happen"); } switch (Type1) { case DataType.Double: Value = reader.ReadDouble(); break; case DataType.Float: Value = reader.ReadSingle(); break; case DataType.Int32: Value = reader.ReadInt32(); break; case DataType.Int64: Value = reader.ReadInt64(); break; case DataType.Boolean: Value = (reader.ReadUInt32() == 1); // TODO: double check break; case DataType.Variable: TypeInst = (InstanceType)val; Value = reader.ReadUndertaleObject <Reference <UndertaleVariable> >(); break; case DataType.String: UndertaleResourceById <UndertaleString> str = new UndertaleResourceById <UndertaleString>("STRG"); str.Unserialize(reader, reader.ReadInt32()); Value = str; break; case DataType.Int16: Value = val; break; } } break; case InstructionType.CallInstruction: { ArgumentsCount = reader.ReadUInt16(); Type1 = (DataType)reader.ReadByte(); if (reader.ReadByte() != (byte)Kind) { throw new Exception("really shouldn't happen"); } Function = reader.ReadUndertaleObject <Reference <UndertaleFunction> >(); } break; case InstructionType.BreakInstruction: { Value = reader.ReadInt16(); Type1 = (DataType)reader.ReadByte(); if (reader.ReadByte() != (byte)Kind) { throw new Exception("really shouldn't happen"); } } break; default: throw new IOException("Unknown opcode " + Kind.ToString().ToUpper()); } }
internal override void UnserializeChunk(UndertaleReader reader) { CheckForEffectData(reader); base.UnserializeChunk(reader); }
public void Unserialize(UndertaleReader reader) { DisableDebugger = reader.ReadByte() != 0; BytecodeVersion = reader.ReadByte(); Unknown = reader.ReadUInt16(); Filename = reader.ReadUndertaleString(); Config = reader.ReadUndertaleString(); LastObj = reader.ReadUInt32(); LastTile = reader.ReadUInt32(); GameID = reader.ReadUInt32(); byte[] GuidData = reader.ReadBytes(16); DirectPlayGuid = new Guid(GuidData); Name = reader.ReadUndertaleString(); Major = reader.ReadUInt32(); Minor = reader.ReadUInt32(); Release = reader.ReadUInt32(); Build = reader.ReadUInt32(); DefaultWindowWidth = reader.ReadUInt32(); DefaultWindowHeight = reader.ReadUInt32(); Info = (InfoFlags)reader.ReadUInt32(); LicenseCRC32 = reader.ReadUInt32(); LicenseMD5 = reader.ReadBytes(16); Timestamp = reader.ReadUInt64(); DisplayName = reader.ReadUndertaleString(); ActiveTargets = reader.ReadUInt64(); FunctionClassifications = (FunctionClassification)reader.ReadUInt64(); SteamAppID = reader.ReadInt32(); if (BytecodeVersion >= 14) { DebuggerPort = reader.ReadUInt32(); } RoomOrder = reader.ReadUndertaleObject <UndertaleSimpleResourcesList <UndertaleRoom, UndertaleChunkROOM> >(); if (Major >= 2) { // Begin parsing random UID, and verify it based on original algorithm GMS2RandomUID = new List <long>(); Random random = new Random((int)(Timestamp & 4294967295L)); long firstRandom = (long)random.Next() << 32 | (long)random.Next(); if (reader.ReadInt64() != firstRandom) { //throw new IOException("Unexpected random UID"); } long infoNumber = (long)(Timestamp - 1000); ulong temp = (ulong)infoNumber; temp = ((temp << 56 & 18374686479671623680UL) | (temp >> 8 & 71776119061217280UL) | (temp << 32 & 280375465082880UL) | (temp >> 16 & 1095216660480UL) | (temp << 8 & 4278190080UL) | (temp >> 24 & 16711680UL) | (temp >> 16 & 65280UL) | (temp >> 32 & 255UL)); infoNumber = (long)temp; infoNumber ^= firstRandom; infoNumber = ~infoNumber; infoNumber ^= ((long)GameID << 32 | (long)GameID); infoNumber ^= ((long)(DefaultWindowWidth + (int)Info) << 48 | (long)(DefaultWindowHeight + (int)Info) << 32 | (long)(DefaultWindowHeight + (int)Info) << 16 | (long)(DefaultWindowWidth + (int)Info)); infoNumber ^= BytecodeVersion; int infoLocation = (int)(Math.Abs((int)(Timestamp & 65535L) / 7 + (GameID - DefaultWindowWidth) + RoomOrder.Count) % 4); for (int i = 0; i < 4; i++) { if (i == infoLocation) { reader.ReadInt64(); GMS2RandomUID.Add(infoNumber); } else { reader.ReadInt64(); int first = random.Next(); int second = random.Next(); GMS2RandomUID.Add(((long)first << 32) | (long)second); } } GMS2FPS = reader.ReadSingle(); GMS2AllowStatistics = reader.ReadBoolean(); GMS2GameGUID = reader.ReadBytes(16); } reader.undertaleData.UnsupportedBytecodeVersion = BytecodeVersion < 13 || BytecodeVersion > 17; reader.Bytecode14OrLower = BytecodeVersion <= 14; }
/// <inheritdoc /> public void Unserialize(UndertaleReader reader) { ID = reader.ReadInt32(); Tags = reader.ReadUndertaleObject <UndertaleSimpleListString>(); }
public void Unserialize(UndertaleReader reader) { Name = reader.ReadUndertaleString(); Value = reader.ReadUndertaleString(); }
internal abstract void UnserializeChunk(UndertaleReader reader);
public void Unserialize(UndertaleReader reader) { NewFormat = reader.ReadInt32() == int.MinValue; reader.Position -= 4; if (NewFormat) { Unknown1 = reader.ReadUInt32(); Unknown2 = reader.ReadUInt32(); Info = (OptionsFlags)reader.ReadUInt64(); Scale = reader.ReadInt32(); WindowColor = reader.ReadUInt32(); ColorDepth = reader.ReadUInt32(); Resolution = reader.ReadUInt32(); Frequency = reader.ReadUInt32(); VertexSync = reader.ReadUInt32(); Priority = reader.ReadUInt32(); BackImage = reader.ReadUndertaleObject <UndertaleSprite.TextureEntry>(); FrontImage = reader.ReadUndertaleObject <UndertaleSprite.TextureEntry>(); LoadImage = reader.ReadUndertaleObject <UndertaleSprite.TextureEntry>(); LoadAlpha = reader.ReadUInt32(); Constants = reader.ReadUndertaleObject <UndertaleSimpleList <Constant> >(); } else { Info = 0; if (reader.ReadBoolean()) { Info |= OptionsFlags.FullScreen; } if (reader.ReadBoolean()) { Info |= OptionsFlags.InterpolatePixels; } if (reader.ReadBoolean()) { Info |= OptionsFlags.UseNewAudio; } if (reader.ReadBoolean()) { Info |= OptionsFlags.NoBorder; } if (reader.ReadBoolean()) { Info |= OptionsFlags.ShowCursor; } Scale = reader.ReadInt32(); if (reader.ReadBoolean()) { Info |= OptionsFlags.Sizeable; } if (reader.ReadBoolean()) { Info |= OptionsFlags.StayOnTop; } WindowColor = reader.ReadUInt32(); if (reader.ReadBoolean()) { Info |= OptionsFlags.ChangeResolution; } ColorDepth = reader.ReadUInt32(); Resolution = reader.ReadUInt32(); Frequency = reader.ReadUInt32(); if (reader.ReadBoolean()) { Info |= OptionsFlags.NoButtons; } VertexSync = reader.ReadUInt32(); if (reader.ReadBoolean()) { Info |= OptionsFlags.ScreenKey; } if (reader.ReadBoolean()) { Info |= OptionsFlags.HelpKey; } if (reader.ReadBoolean()) { Info |= OptionsFlags.QuitKey; } if (reader.ReadBoolean()) { Info |= OptionsFlags.SaveKey; } if (reader.ReadBoolean()) { Info |= OptionsFlags.ScreenShotKey; } if (reader.ReadBoolean()) { Info |= OptionsFlags.CloseSec; } Priority = reader.ReadUInt32(); if (reader.ReadBoolean()) { Info |= OptionsFlags.Freeze; } if (reader.ReadBoolean()) { Info |= OptionsFlags.ShowProgress; } BackImage = reader.ReadUndertaleObject <UndertaleSprite.TextureEntry>(); FrontImage = reader.ReadUndertaleObject <UndertaleSprite.TextureEntry>(); LoadImage = reader.ReadUndertaleObject <UndertaleSprite.TextureEntry>(); if (reader.ReadBoolean()) { Info |= OptionsFlags.LoadTransparent; } LoadAlpha = reader.ReadUInt32(); if (reader.ReadBoolean()) { Info |= OptionsFlags.ScaleProgress; } if (reader.ReadBoolean()) { Info |= OptionsFlags.DisplayErrors; } if (reader.ReadBoolean()) { Info |= OptionsFlags.WriteErrors; } if (reader.ReadBoolean()) { Info |= OptionsFlags.AbortErrors; } if (reader.ReadBoolean()) { Info |= OptionsFlags.VariableErrors; } if (reader.ReadBoolean()) { Info |= OptionsFlags.CreationEventOrder; } Constants = reader.ReadUndertaleObject <UndertaleSimpleList <Constant> >(); } }
public static UndertaleChunk Unserialize(UndertaleReader reader) { string name = "(unknown)"; try { name = reader.ReadChars(4); uint length = reader.ReadUInt32(); // TODO: I can't think of a cleaner way to do this... Type type = Type.GetType(typeof(UndertaleChunk).FullName + name); if (type == null) { throw new IOException("Unknown chunk " + name + "!!!"); /*Debug.WriteLine("Unknown chunk " + name + "!!!"); * reader.Position = reader.Position + length; * return null;*/ } UndertaleChunk chunk = (UndertaleChunk)Activator.CreateInstance(type); Debug.Assert(chunk.Name == name); chunk.Length = length; reader.SubmitMessage("Reading chunk " + chunk.Name); var lenReader = reader.EnsureLengthFromHere(chunk.Length); chunk.UnserializeChunk(reader); if (name != "FORM" && name != reader.LastChunkName) { UndertaleGeneralInfo generalInfo = name == "GEN8" ? ((UndertaleChunkGEN8)chunk).Object : reader.undertaleData.GeneralInfo; // These versions introduced new padding // all chunks now start on 16-byte boundaries // (but the padding is included with length of previous chunk) if (generalInfo.Major >= 2 || (generalInfo.Major == 1 && generalInfo.Build >= 9999)) { int e = reader.undertaleData.PaddingAlignException; uint pad = (e == -1 ? 16 : (uint)e); while (reader.Position % pad != 0) { if (reader.ReadByte() != 0) { reader.Position -= 1; if (reader.Position % 4 == 0) { reader.undertaleData.PaddingAlignException = 4; } else { reader.undertaleData.PaddingAlignException = 1; } break; } } } } lenReader.ToHere(); return(chunk); } catch (UndertaleSerializationException e) { throw new UndertaleSerializationException(e.Message + " in chunk " + name, e); } catch (Exception e) { throw new UndertaleSerializationException(e.Message + "\nat " + reader.Position.ToString("X8") + " while reading chunk " + name, e); } }
public virtual void Unserialize(UndertaleReader reader) { Resource = new T(); Resource.Unserialize(reader); }