UnderminersTeam / UndertaleModTool

The most complete tool for modding, decompiling and unpacking Undertale (and other Game Maker: Studio games!)
GNU General Public License v3.0
1.07k stars 205 forks source link

decompiler replaces expression with _temp_local_var_X #1071

Open themabus opened 1 year ago

themabus commented 1 year ago

Describe the bug

this GMS1.4 code:

for (var i = 0; i < 10; i++) {
    array[irandom(i)]++;
    x++;
}

gets decompiled as this nonworking code:

var i, _temp_local_var_1;
for (i = 0; i < 10; i++)
{
    array[_temp_local_var_1]++
    x++
}

Reproducing steps

script0 in attached data.win bug_decomp.zip

Setup Details

GMS1.4 674c5d8

themabus commented 1 year ago

also this

repeat(x) {
    if hspeed
        y += 1;
    else
        y += 2;
    if (y>x) break;
}

gets misinterpreted by decompiler as this

var _temp_local_var_1;
_temp_local_var_1 = x
if (x <= 0)
{
}
else
{
    while (true)
    {
        if hspeed
            y += 1
        else
            y += 2
        if (y > x)
            break
        else
        {
            _temp_local_var_1 = (x - 1)
            if (x - 1)
                continue
        }
    }
}

script1 in attached data.win bug_decomp2.zip

Jacky720 commented 1 year ago

The latter is a known and, I believe, fixed bug with repeats and breaks. Can you try the bleeding edge?

Also, it's probably still possible to break it with more complicated breaks and continues. Just less likely to show up in a game.

themabus commented 1 year ago

yeah those both are from that bleeding edge from 18 days ago combined one