Fix cycling title BG more than once per frame

This can happen if you select an option in a menu that (A) returns to
the previous menu and (B) saves settings. If the settings save fails,
this will create another menu on the same frame that cycles the tower BG
after it's already been cycled for that frame. Examples are the slowdown
and glitchrunner menus.

I could fix this by creating a new function that copy-pastes all of
Game::savestatsandsettings_menu() except for the map.nexttowercolour()
at the end. But that's copy-pasting code.

Instead what I've done is added a variable to signal if the color has
already been cycled this frame, so we don't cycle it again. This also
covers cases of possible double-cycling in the future as well.
This commit is contained in:
Misa authored and Ethan Lee committed 2021-08-05 21:42:59 -04:00
1 parent b9202dee8b
commit 45dd7c39b7
3 files changed
+11 -1

No files matched your search

+9
View File
@@ -82,6 +82,8 @@ mapclass::mapclass(void)
cameraseek = 0;
minitowermode = false;
roomtexton = false;
nexttowercolour_set = false;
}
//Areamap starts at 100,100 and extends 20x20
@@ -631,6 +633,13 @@ void mapclass::updatetowerglow(TowerBG& bg_obj)
void mapclass::nexttowercolour(void)
{
/* Prevent cycling title BG more than once per frame. */
if (nexttowercolour_set)
{
return;
}
nexttowercolour_set = true;
graphics.titlebg.colstate+=5;
if (graphics.titlebg.colstate >= 30) graphics.titlebg.colstate = 0;