d0k3 / GodMode9

GodMode9 Explorer - A full access file browser for the Nintendo 3DS console :godmode:
GNU General Public License v3.0
2.12k stars 191 forks source link

Fix NDS / DSi names being cut off when renaming to good name #717

Closed ZeroSkill1 closed 3 years ago

ZeroSkill1 commented 3 years ago

To better understand what this fixes, let's take a look at what happens when renaming this NDS file to good name: og_prompt og_result

The result is a cut-off name, because currently, the name is copied only until the first newline. NDS/DSi Names consist of Title + Publisher in one string. However, to avoid overlapping, parts of the Title and the Publisher are separated by newlines, as seen here: grafik

and this is what the Title looks like, if we were to interpret it as a string:

"Professor Kageyama's\nMaths Training\nNINTENDO"

Therefore, every character until the last newline is still part of the Title, because what comes after the last newline is the Publisher.

I have implemented it like this:

  1. Instead of checking for the first occurrence of a newline, I'm checking for the last ocurrence of a newline, to know where the Title stops and the Publisher starts.
  2. Looping through the Title and replacing every remaining newline with a space to merge all possible parts together, forming the correct Title.

And as a result: fix_prompt fix_result It now correctly renames the Title, it is no longer cut off.

ZeroSkill1 commented 3 years ago

After some more testing, it seems that it works fine with DSiWare CIAs, too. before: 00030015534C524E TWiLight Menu++ (TWL-SLRN) (DSi Exclusive) (W) (v0.0.0).standard.cia after: 00030015534C524E TWiLight Menu++ Last-run ROM (TWL-SLRN) (DSi Exclusive) (W) (v0.0.0).standard.cia

d0k3 commented 3 years ago

Thanks, good addition!