lastbattle / Harepacker-resurrected

All in one .wz file/map editor for MapleStory game files
Mozilla Public License 2.0
416 stars 156 forks source link

[HaCreator] Saving maps to a new id doesn't work #214

Closed Arnuh closed 1 year ago

Arnuh commented 1 year ago

As the title describes, if you create a map & save it to a mapid that isn't currently used you'll get the following error

System.Exception: Could not find a suitable Map.wz to place the new map into.
   at HaCreator.Wz.MapSaver.InsertImage() in Harepacker-resurrected\HaCreator\Wz\MapSaver.cs:line 69
   at HaCreator.Wz.MapSaver.SaveMapImage() in Harepacker-resurrected\HaCreator\Wz\MapSaver.cs:line 972
   at HaCreator.GUI.Save.saveButton_Click(Object sender, EventArgs e) in Harepacker-resurrected\HaCreator\GUI\Save.cs:line 110

Line numbers are off? But debugging brings me to https://github.com/lastbattle/Harepacker-resurrected/blob/c28be2f92bd76ea1bf4aa1464d4fa42df0804c75/HaCreator/Wz/MapSaver.cs#L65-L75

https://github.com/lastbattle/Harepacker-resurrected/blob/c28be2f92bd76ea1bf4aa1464d4fa42df0804c75/HaSharedLibrary/Wz/WzInfoTools.cs#L257-L271 everything here seems fine except for mapObject?[mapcat]?[mapIdNamePadded] mapIdNamePadded will not exist since its a new map, it'll return null, and the null check in MapSaver will now throw an exception

More notes, this is how it used to work before rewrites. Looks like restructuring didn't persist all functionality. https://github.com/lastbattle/Harepacker-resurrected/blob/6b636036816363e26c035877ca7a4c9a0b97c7ed/HaCreator/Wz/MapSaver.cs#L57-L71

lastbattle commented 1 year ago

Messed up that while creating compatibility for later versions of MapleStory (post 64-bit) + Beta MapleStory. Neglected testing on this aspect of the code. Always hard to have one size that fits it all.