UnderminersTeam / UndertaleModTool

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

break; inside a repeat makes repeat() detection fail. #292

Open nkrapivin opened 4 years ago

nkrapivin commented 4 years ago

Let's imagine we have this weird piece of code.

///Test.

var t;
t = 0;
repeat (20)
{
    t = get_timer();
    if (t)
    {
        break;
    }
}

In theory this should decompile to:

var t
t = 0
repeat (20)
{
    t = get_timer()
    if t break
}

but in reality it decompiles to:

var t, _temp_local_var_1;
t = 0
_temp_local_var_1 = 20
if (20 <= 0)
{
}
else
{
    while (true)
    {
        t = get_timer()
        if t
        {
        }
        else
        {
            _temp_local_var_1 = (20 - 1)
            if (20 - 1)
                continue
        }
    }
}

I suppose it's because of a break; statement inside a repeat (which is absent in the decompilation btw). Docs say that it's totally legal to break; from a repeat, so idk.

colinator27 commented 4 years ago

We probably won't be fixing any more decompiler issues since we're rewriting the entire thing anyway.