UnderminersTeam / UndertaleModTool

The most complete tool for modding, decompiling and unpacking Undertale (and other GameMaker games!)
GNU General Public License v3.0
1.19k stars 233 forks source link

ImportAllStrings.csx deletes profile mode code #1938

Open luizzeroxis opened 1 month ago

luizzeroxis commented 1 month ago

Describe the bug

Using the ImportAllStrings script deletes profile mode code.

Reproducing steps

  1. Enable profile mode
  2. Open any data.win
  3. Change some code somewhere that profile mode saves (such as adding a comment)
  4. Run Resource Unpackers\ExportAllStrings and save it somewhere
  5. Run Resource Repackers\ImportAllStrings and load it
  6. All profile code is gone, replaced with recompiled versions.

This doesn't happen in v0.6.1.0

Setup Details

  1. underanalyzer (8c5462c)
  2. Windows 10
  3. Any
colinator27 commented 1 month ago

No clue why this happens... Underanalyzer's implementation shouldn't have touched these scripts all that much, so I'm curious what makes this not occur on 0.6.1.0. The only two things I can think of are:

The first one can be easily tested, at the very least. If the script is detecting profile mode correctly, it should give this message:

This script will not modify your existing edited GML code registered in your profile. Please use GML editing for text editing, or a script like FindAndReplace, for editing strings within these code entries.

Otherwise, it gives the following message and nukes the profile mode GML intentionally (if you continue):

This script will recompile all code entries in your profile (if they exist) to the default decompiled output. Continue?
luizzeroxis commented 1 month ago

I think I understand why this is happening. On that script, it calls ReapplyProfileCode in the end (probably to fix the strings in code), which eventually calls SafeImport, which calls GetDecompiledText when in profile mode (or I guess if a profile file for that GML exists at all, that's probably wrong). That calls the decompiler, which is different on those two versions.

The problem is that the regular decompiler actually checked for profile mode code and returned it, but underanalyzer recompiles it regardless. So it would be fine to call GetDecompiledText in profile mode on the regular version, but not in underanalyzer.

This difference could have wide reaching implications so it's probably worth investigating further, or better yet, rewrite the whole profile system