De-duplicate script.running checks

While I was working on #535, I noticed that all the call sites of
script.run() have the exact same code, namely:

    if (script.running)
    {
        script.run();
    }

I figured, why not move the script.running check into the function
itself? That way, we won't have to duplicate the check every single
time, and we don't risk forgetting to add the check and causing a bug
because of that.

The check was already duplicated once since 2.0 (it's used in both
GAMEMODE and TELEPORTERMODE), and with the fix of the two-frame delay in
2.3, it's now duplicated twice, leading to THREE instances of this check
in the code, when there should be only one.
This commit is contained in:
Misa authored and Ethan Lee committed 2020-12-24 12:01:37 -05:00
1 parent cbf3da312f
commit e3aa768034
3 files changed
+9 -10

No files matched your search

+2 -5
View File
@@ -2101,9 +2101,6 @@ void mapclass::twoframedelayfix()
game.state = 0;
game.statedelay = 0;
script.load(game.newscript);
if (script.running)
{
script.run();
script.dontrunnextframe = true;
}
script.run();
script.dontrunnextframe = true;
}