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

Forced sorting on save breaks wz files #217

Closed Arnuh closed 10 months ago

Arnuh commented 1 year ago

I already stated this in the initial issue #173 that ended up introducing such change. This change directly breaks wz files.

Running something as simple as what's shown below "corrupts" Base.wz due to the code introduced in https://github.com/lastbattle/Harepacker-resurrected/commit/a5760d43eb187354c466665a404ee5ca9f3e2001

private static void PrepareAllImages(WzDirectory dir) {
    foreach (WzImage img in dir.WzImages) {
        img.ParseImage();
        img.Changed = true;
    }

    foreach (WzDirectory subDir in dir.WzDirectories) {
        PrepareAllImages(subDir);
    }
}

static void modifyBase(WzMapleVersion version) {
    WzFile wzFile = new WzFile(Path.Combine(baseDir, "Base.wz"), version);
    wzFile.ParseWzFile();

    PrepareAllImages(wzFile.WzDirectory);

    wzFile.SaveToDisk(Path.Combine(outputDir, "Base.wz"), false, version);
}

I suggest reverting the commit and looking to introduce the feature in another manner if still deemed as needed.

Order matters, MapleLib should never touch it without the user opting in. Attempting to add workarounds where ever it breaks things is not the correct way.

proof

lastbattle commented 1 year ago

It's always hard to catch issues like this, given the enormous amount of versions and variations of files to be tested against. I wish it could be done automatically someway, somehow.

lastbattle commented 1 year ago

Perhaps limiting the scope of sorting to only map layer canvas and subproperty?

Arnuh commented 1 year ago

Like I said previously, sorting shouldn't happen unless its opt in.

I'd assume proper setup is the following, hopefully I'm not missing anything.

  1. Import should obviously keep the exact order being imported, appending to bottom of any previous data if such exists.
  2. Manual property creation should just append to the bottom like 1.
  3. Give a right click option on WzFile, WzImage, and WzDirectory, or all to sort the sub properties
  4. A way to move up/down properties to manually order without sorting all sub properties
  5. No forced sorting anywhere :) A complete load of the wz & then full save should give an identical wz back.
lastbattle commented 11 months ago

image

LMK if there's any other issues.

Arnuh commented 10 months ago

I'll close it. From my basic usage it seems to work as intended, any issues with the sort buttons would be a new issue imo.

wangxiaobao0851 commented 8 months ago

image Your problem also occurred when I saved GMSv83 as another IV. How did you solve it? Can you guide me to solve it? Is there a bug in the operation or can you post the code that fixes the problem.

Arnuh commented 8 months ago

image Your problem also occurred when I saved GMSv83 as another IV. How did you solve it? Can you guide me to solve it? Is there a bug in the operation or can you post the code that fixes the problem.

Latest release doesn't have the issue fixed, you have to build it yourself for now if you want it fixed.