sonicretro / SonLVL

SonLVL
http://info.sonicretro.org/SonLVL
58 stars 27 forks source link

Unable to load some levels with specific format #125

Closed giovannidotgen closed 2 years ago

giovannidotgen commented 2 years ago

I'm trying to load a Sonic 1 level with this specific format:

However, when loading up the level, the program throws an error at me, requiring the parameter "key" not to be null, although I'm unsure of what this "key" parameter is.

Program: SonLVL
Build Date: 12/27/2021 21:10:17
OS Version: Microsoft Windows NT 6.2.9200.0
Log:
Operating system: Microsoft Windows NT 6.2.9200.0
Opening INI file "E:\Giovanni's Files\SEGA Genesis Stuff\Sonic ROM Hacking\Disassemblies\s1Hivebrain OM3\Sonic 1 2005 INIs\SonLVL.ini"...
Game type is S1.
Loading Green Hill Zone Act 1...
Loading 16x16 blocks from file "../map16/ghz.bin", using compression Enigma...
Loading 8x8 tiles from file "../artnem/8x8ghz1.bin", using compression Nemesis...
Loading 256x256 chunks from file "../map256_u/ghz.bin", using compression Uncompressed...
Layout file "../levels/filethatdoesnotexist.bin" not found.
Loading 8x8 tiles from file "../artnem/8x8ghz2.bin", using compression Nemesis...
Loading palette file "../pallet/sonic.bin"...
Source: 0 Destination: 0 Length: 16
Loading palette file "../pallet/ghz.bin"...
Source: 0 Destination: 16 Length: 48
System.AggregateException: Si sono verificati uno o più errori. ---> System.ArgumentNullException: Il valore non può essere null.
Nome parametro: key
   in System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   in System.Collections.Generic.Dictionary`2.ContainsKey(TKey key)
   in SonicRetro.SonLVL.API.LevelData.LoadLevelLayout(String levelname)
   in SonicRetro.SonLVL.API.LevelData.<>c__DisplayClass70_0.<LoadLevel>b__0()
   in System.Threading.Tasks.Task.InnerInvoke()
   in System.Threading.Tasks.Task.Execute()
   --- Fine della traccia dello stack dell'eccezione interna ---
   in System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)
   in System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout)
   in System.Threading.Tasks.Parallel.Invoke(ParallelOptions parallelOptions, Action[] actions)
   in System.Threading.Tasks.Parallel.Invoke(Action[] actions)
   in SonicRetro.SonLVL.API.LevelData.LoadLevel(String levelname, Boolean loadGraphics)
   in SonicRetro.SonLVL.GUI.MainForm.backgroundLevelLoader_DoWork(Object sender, DoWorkEventArgs e) in D:\Programs\SonLVL\SonLVL\MainForm.cs:riga 574
---> (Eccezione interna 0) System.ArgumentNullException: Il valore non può essere null.
Nome parametro: key
   in System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   in System.Collections.Generic.Dictionary`2.ContainsKey(TKey key)
   in SonicRetro.SonLVL.API.LevelData.LoadLevelLayout(String levelname)
   in SonicRetro.SonLVL.API.LevelData.<>c__DisplayClass70_0.<LoadLevel>b__0()
   in System.Threading.Tasks.Task.InnerInvoke()
   in System.Threading.Tasks.Task.Execute()<---

For the record, I have tried loading as a layout a file that does not exist in my machine, which would normally load up the "level" with no issue, but in this case, the level is not loaded.

Here's my SonLVL.INI file, along with the specific level I'm trying to load:

version=S1
ringfmt=S3K
objectfmt=S3K
layoutfmt=S2
layoutcmp=Uncompressed
objlst=obj.ini
colarr1=../collide/carray_n.bin
colarr2=../collide/carray_r.bin
angles=../collide/anglemap.bin
chunkcmp=Uncompressed
buildscr=../build.bat
romfile=../s1built.bin

[Green Hill Zone Act 1]
tiles=../artnem/8x8ghz1.bin|../artnem/8x8ghz2.bin
blocks=../map16/ghz.bin
chunks=../map256_u/ghz.bin
layout=../levels/filethatdoesnotexist.bin
objects=../objpos/filethatdoesnotexist.bin
rings=../rings/filethatdoesnotexist.bin
palette=../pallet/sonic.bin:0:0:16|../pallet/ghz.bin:0:16:48
startpos=../misc/sloc_lev.bin:Sonic:Level Start:0|../misc/sloc_end.bin:Sonic:Credits Demo 1:0|../misc/sloc_end.bin:Sonic:Credits Demo 2:1C
colind=../collide/ghz.bin
loopchunks=35
objlst=objGHZ.ini
animtiles1=../artunc/ghzwater.bin:0:0x378:8
animtiles2=../artunc/ghzflowl.bin:0:0x35C:16
animtiles3=../artunc/ghzflows.bin:0:0x36C:12
animtiles4=GHZ/GHZ Flower Stalk.unc:0:0x358:4
MainMemory commented 2 years ago

Do you have other levels in the ini file that have fglayout/bglayout instead of layout? Because that would cause a crash.

giovannidotgen commented 2 years ago

That did solve the issue partially. I am now able to load non-GHZ levels. GHZ based levels (including the Ending) now throw this exception at me:

Program: SonLVL
Build Date: 07/18/2022 03:48:03
OS Version: Microsoft Windows NT 6.2.9200.0
Log:
Operating system: Microsoft Windows NT 6.2.9200.0
Opening INI file "E:\Giovanni's Files\SEGA Genesis Stuff\Sonic ROM Hacking\Disassemblies\s1Hivebrain OM3\Sonic 1 2005 INIs\SonLVL.ini"...
Game type is S1.
Loading Green Hill Zone Act 1...
Loading 16x16 blocks from file "../map16/GHZ.bin", using compression Enigma...
Loading 256x256 chunks from file "../map256_u/GHZ.bin", using compression Uncompressed...
Loading 8x8 tiles from file "../artnem/8x8ghz.bin", using compression Nemesis...
Loading layout from file "../levels/ghz1.bin", using compression Uncompressed...
Loading layout from file "../levels/ghz2.bin", using compression Uncompressed...
Loading palette file "../pallet/sonic.bin"...
Source: 0 Destination: 0 Length: 16
Loading palette file "../pallet/ghz.bin"...
Source: 0 Destination: 16 Length: 48
Loading layout from file "../levels/ghz3.bin", using compression Uncompressed...
Loading layout from file "../levels/ending.bin", using compression Uncompressed...
System.AggregateException: Si sono verificati uno o più errori. ---> System.IndexOutOfRangeException: Indice oltre i limiti della matrice.
   in SonicRetro.SonLVL.API.S2.Layout.ReadLayout(Byte[] rawdata, LayoutData layout) in C:\Programs\SonLVL\SonLVLAPI\S2\Layout.cs:riga 7
   in SonicRetro.SonLVL.API.LayoutFormatCombined.ReadLayout(String filename, CompressionType compression, LayoutData layout) in C:\Programs\SonLVL\SonLVLAPI\LayoutFormat.cs:riga 47
   in SonicRetro.SonLVL.API.LayoutFormatCombined.TryReadLayout(String filename, CompressionType compression, LayoutData layout) in C:\Programs\SonLVL\SonLVLAPI\LayoutFormat.cs:riga 55
   in SonicRetro.SonLVL.API.LevelData.LoadLevelLayout(String levelname) in C:\Programs\SonLVL\SonLVLAPI\LevelData.cs:riga 622
   in SonicRetro.SonLVL.API.LevelData.<>c__DisplayClass70_0.<LoadLevel>b__0() in C:\Programs\SonLVL\SonLVLAPI\LevelData.cs:riga 166
   in System.Threading.Tasks.Task.InnerInvoke()
   in System.Threading.Tasks.Task.Execute()
   --- Fine della traccia dello stack dell'eccezione interna ---
   in System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken)
   in System.Threading.Tasks.Task.WaitAll(Task[] tasks, Int32 millisecondsTimeout)
   in System.Threading.Tasks.Parallel.Invoke(ParallelOptions parallelOptions, Action[] actions)
   in System.Threading.Tasks.Parallel.Invoke(Action[] actions)
   in SonicRetro.SonLVL.API.LevelData.LoadLevel(String levelname, Boolean loadGraphics) in C:\Programs\SonLVL\SonLVLAPI\LevelData.cs:riga 166
   in SonicRetro.SonLVL.GUI.MainForm.backgroundLevelLoader_DoWork(Object sender, DoWorkEventArgs e) in C:\Programs\SonLVL\SonLVL\MainForm.cs:riga 567
---> (Eccezione interna 0) System.IndexOutOfRangeException: Indice oltre i limiti della matrice.
   in SonicRetro.SonLVL.API.S2.Layout.ReadLayout(Byte[] rawdata, LayoutData layout) in C:\Programs\SonLVL\SonLVLAPI\S2\Layout.cs:riga 7
   in SonicRetro.SonLVL.API.LayoutFormatCombined.ReadLayout(String filename, CompressionType compression, LayoutData layout) in C:\Programs\SonLVL\SonLVLAPI\LayoutFormat.cs:riga 47
   in SonicRetro.SonLVL.API.LayoutFormatCombined.TryReadLayout(String filename, CompressionType compression, LayoutData layout) in C:\Programs\SonLVL\SonLVLAPI\LayoutFormat.cs:riga 55
   in SonicRetro.SonLVL.API.LevelData.LoadLevelLayout(String levelname) in C:\Programs\SonLVL\SonLVLAPI\LevelData.cs:riga 622
   in SonicRetro.SonLVL.API.LevelData.<>c__DisplayClass70_0.<LoadLevel>b__0() in C:\Programs\SonLVL\SonLVLAPI\LevelData.cs:riga 166
   in System.Threading.Tasks.Task.InnerInvoke()
   in System.Threading.Tasks.Task.Execute()<---

No levels in the INI file feature the fglayout/bglayout parameters.

giovannidotgen commented 2 years ago

Whoops! This one was also a me error. The ending level was not 4KB in size, which may have screwed something up within the loading process, fairly enough. All levels load just fine now, thanks for the assistance!