LagoLunatic / DSVEdit

Multi-purpose editor for ROM hacking DS and GBA Castlevania games
MIT License
91 stars 12 forks source link

Editor crashes after matching new room State to original room - Works on emulator, crashes on editor, no log created #62

Open 4lorn5 opened 2 years ago

4lorn5 commented 2 years ago

Editor crashes when matching new room State to original room - Works on emulator, crashes on editor, no log created

Steps taken to create new Room State:

1) Create a duplicate Room numbered 08499CEC, based on original room 0849922C, the only difference being a new entry/exit point 2) Make so the entry/exit point leads into another already existing room 3) Create a new entry/exit point from the already existing room that leads into the new Room State 4) Make sure all Doors are connected 5) Create a Button Special Object with Variable A set to 0001 (bug does not seem related to the value as any value will produce the same result; tested values as high as 007D to avoid conflicts with Events using same values) 7) Set it so the new Room State is activated upon pressing the button 6) Set the original Room's "Alternate state condition flag" to the value used on the Button's Variable A 7) Set the original Room's "Alternate state room pointer" to the new Room's pointer (last on Room Listing in first castle area)

Bug: When attempting to move the new Room over the original Room, the editor saves and builds the ROM without issues. With the final change applied, an emulator will read the ROM without issues. If playtested from within the editor before closing it, no issues occur. However, after closing the editor, any attempts to reopen the ROM result in the editor crashing without generating any information whatsoever on the crashlog.txt.

Provided:

One IPS file generated from the built ROM called "Before". The state of the edits is near final. In this state, the Room is still not moved over the original Room, and the original Room still does not point to its new State (missing Flag and Room Pointer). One IPS file generated from the built ROM called "After". The edit is final and consists only of moving the new Room State over the original Room, and updated values for new Room State (Flag and Room Pointer). If relevant, each IPS file is accompanied by the .sym file generated by the Editor.

Download link: https://ufile.io/f/axc7w

To playtest: head right, enter Room to the right, press Button, exit left and go all the way to the left to see changes.

Is total Room/Map size the issue? Deleting the contents of other Rooms to free up space results in the same issue.

LagoLunatic commented 2 years ago

This is a bug with how DSVEdit loads room states. It only seems to work 100% correctly in the vanilla case (room states don't appear as normal sector rooms, only as unique alternative states for normal sector rooms or other alt states). In your case a room's alt state is another room in the same sector, so it gets into an infinite loop of trying to load that whole sector into memory every time it encounters the alternate room state. I'll have to rethink how DSVEdit loads and caches rooms in memory to fix this.

4lorn5 commented 2 years ago

Thank you for your explanation.

For an alternate State, I also thought about moving away its opposing Castle counterpart and placing the new Castle State in its place (ie, for a Castle A State, moving away its Castle B counterpart and replacing it with the new Room), but it won't work. It does seem to accept already existing Castle counterparts as alternate States, however, so I might give my project a little push - even if it this requires considerable more juggling than I thought.

While I did not address the previous bug I've posted, I've realized it's somewhat related. It seems a room's layer size was somehow being affected if I created a Room meant to replicate it, and used the exact same information on the original's Room Layers. The error stopped happening once I chose to Select Tileset from within each Layer's options, and also didn't use any repeating information from its Room Props. Regardless, I think either is now solved or at least explained so as to find alternatives on my end.

Thank you once again.

LagoLunatic commented 2 years ago

It seems a room's layer size was somehow being affected if I created a Room meant to replicate it, and used the exact same information on the original's Room Layers.

I don't understand how that could happen as the layer's dimensions were being set to invalid values in your other issue. Even if two states share a layer and editing one edits the other, the safeguard to prevent invalid dimensions should still exist.

4lorn5 commented 2 years ago

Well, I have no copies of the previous project version I was working on. If I manage to replicate that particular error, I'll be sure to post it here.