Skip to content

Duplicate tracks in a bank are overwritten, causing them to be missing in the final output. #3

Description

@ashsystems

I noticed when running FModBankParser.Demo to extract audio from the game UNBEATABLE, file Master.bank the tool reported exporting 126 audio files but only 54 were found in ExportedAudio/Master.bank. I traced this issue to

if (!overwrite && filePath.Exists)
continue;
File.WriteAllBytes(filePath.FullName, dataBytes);
exportedFiles++;
In FModBankParser.Demo overwrite is set to the default value of true, so when a track comes up that has the same name as a previous track, it overwrites it even if they were different. (when overwrite is set to false, it counts correctly but also fails to output the files)

Some of the duplicate names are in fact duplicate audio files (same content), I assume this is the reason that overwrite was set in the first place. But this isn't always the case, and that leads to missing audio files.

I fixed this by replacing

if (!overwrite && filePath.Exists)
continue;
with

    int extraNumber = 1;

    while (filePath.Exists)
    {
        filePath = new(Path.Combine(bankFolder.FullName, $"{sampleName}_({extraNumber}).{fileExtension}"));
        extraNumber++;
    }

which exports duplicates with a _(NUMBER) appended to the file name. This needs some more work, it ignores the overwrite config option (so if you run the tool more than once it would create duplicates for EVERYTHING) and probably needs some further changes. But if anyone having the same issue needs a quick fix, here it is.

  • FModBankParser revision b7cfcfc
  • Platform: NixOS with packages mono msbuild dotnet-sdk_10
  • Game: UNBEATABLE, bank steamapps/common/UNBEATABLE/UNBEATABLE_Data/StreamingAssets/Master.bank

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions