X-Hax / sa_tools

Sonic Adventure Toolset
http://info.sonicretro.org/SA_Tools
100 stars 24 forks source link

DLC data corruption #255

Closed Pyrochrome closed 4 months ago

Pyrochrome commented 6 months ago

Describe the bug/request The DLC tool produces invalid output files, which load improperly in-game and crash the editor upon attempting to reimport the file.

To Reproduce (if applicable) Steps to reproduce the behavior: Import an existing DLC (specifically the Quo, XmasJP or Kadomatsu ones) by either opening the original file or importing an .ini, and change a portion of text; upon saving the resulting file (vms or dci) will be corrupt.

Expected behavior The creation of an output file that actually works and doesn't crash Sonic Adventure/the editor.

[Uploading vms.zip…]()

Log Program: VMS Editor Build Date: 12/22/2023 00:15:08 OS Version: Microsoft Windows NT 10.0.19045.0 Log: System.Exception: Error: Unknown archive format at ArchiveLib.PuyoFile..ctor(Byte[] pvmdata) in C:\Programs\sa_tools\Libraries\ArchiveLib\Puyo.cs:line 196 at VMSEditor.EditorDLC.UpdateTextures() in C:\Programs\sa_tools\SA1Tools\VMSEditor\EditorDLC.cs:line 76 at VMSEditor.EditorDLC.LoadVMS_DLC(String filename) in C:\Programs\sa_tools\SA1Tools\VMSEditor\EditorDLC.cs:line 169 at VMSEditor.EditorDLC.openToolStripMenuItem_Click(Object sender, EventArgs e) in C:\Programs\sa_tools\SA1Tools\VMSEditor\EditorDLC.cs:line 242 at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e) at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea) at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ToolStrip.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)

That's just one possible error, the following can also show up:

System.NullReferenceException: Object reference not set to an instance of an object.

System.ArgumentException: Source array was not long enough.

Greater detail and specifics can be seen in the attached file, with the faulty vms files included.

PiKeyAr commented 6 months ago

I tried opening the original files for QUO and Kadomatsu, editing the messages and saving them, and the resulting VMS and DCI files did not crash the editor, so I was unable to reproduce your issue. Also, there are no files attached to your report.

Pyrochrome commented 6 months ago

vms.zip Kadonew.txt

Sorry, seems like the attachment failed for some reason. The bug itself is difficult to replicate consistently since it seems to be related to the amount of text changed, but I can say from experience that this has been a prevalent problem for a while.

I should note that my most recent attempt to edit Kado involved exporting everything to a folder, editing the .ini and then importing that to save a new .vms. I am pretty certain that I did not enter invalid data, all I did was copy paste the text entries from your PC mod ini. Imports in the editor just fine, but upon saving and loading the new .vms; BAM corrupted. I'll add the .ini too (as txt) so you can see.

I tried opening the original files for QUO and Kadomatsu, editing the messages and saving them, and the resulting VMS and DCI files did not crash the editor, so I was unable to reproduce your issue. Also, there are no files attached to your report.

Pyrochrome commented 6 months ago

AND I forgot to put the text file I meant to add to the zip. Oh well, I'll just paste it here.

"The following DLCs were altered to contain English text and remove the region lock (they were supposed to be translations for English speaking players.) They are included in this zip file for examination.

XMASJP

Demul: Trigger object is present but invisible, does not play music and might not load the correct string (english text is supposed to be present). Redream: Sonic is placed in Station Square as normal, upon moving close enough to load the christmas tree object the game endlessly resets itself. Flycast: Identical to Demul

Kado

Demul: Resets to the BIOS bootup screen. Redream: Crash and reset back to the license screen, endlessly looping. Flycast: Similar behavior to XMASJP, triggers load properly but not visual assets or collision.

Quo

Demul: Resets to the BIOS bootup screen. Redream: Crashes on a cyan screen after the character select. Flycast: Doesn't load.

All instances of testing were done using the US 1.05 version. I can't ascertain the exact conditions for producing a bad .vms, but I strongly suspect invalid pointers are the underlying issue here."

PiKeyAr commented 6 months ago

I've pushed an update that improves padding for non-Japanese strings. I was able to import Xmas 98 and Kadomatsu INI files from the mod and save them as VMS files which worked ingame, so it should be fixed now.