From ad6adcb3c0cded0b7dde4dc51c9247fc2b046937 Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 2 May 2020 14:10:22 -0700 Subject: [PATCH] Refactor how "hidden names" work By "hidden names", I'm referring to "Dimension VVVVVV" and "The Ship" popping up on the quit/pause/teleporter screens, even though those rooms don't have any roomnames. Apparently my commit to fix roomname re-draw bleed on the quit/pause/teleporter screens exposed yet another hardreset()-caused bug. The issue here is that since hardreset() sets game.roomx and game.roomy to 0, map.area() will no longer work properly, and since the hidden roomname check is based on map.area(), it will no longer display "Dimension VVVVVV" or "The Ship" once you press ACTION to quit. It used to do this due to the re-draw bleed, but now it doesn't. I saw that roomnames didn't get reset in hardreset(), so the solution here is to re-factor hidden names to be an actual variable, instead of being implicit. map.hiddenname is a variable that's set in mapclass::loadlevel(), and if isn't empty, it will be drawn on the quit/pause/teleporter screens. That way it will still display "Dimension VVVVVV" and "The Ship" when you press ACTION to quit to the menu. EDIT: Since PR #230 got merged, this commit is no longer strictly necessary, but it's still good to refactor hidden names like this. --- desktop_version/src/Map.cpp | 10 ++++++++++ desktop_version/src/Map.h | 1 + desktop_version/src/Render.cpp | 21 +++------------------ 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/desktop_version/src/Map.cpp b/desktop_version/src/Map.cpp index 2c393b6f..2112fec2 100644 --- a/desktop_version/src/Map.cpp +++ b/desktop_version/src/Map.cpp @@ -1144,6 +1144,7 @@ void mapclass::loadlevel(int rx, int ry) obj.vertplatforms = false; obj.horplatforms = false; roomname = ""; + hiddenname = ""; background = 1; warpx = false; warpy = false; @@ -1283,6 +1284,15 @@ void mapclass::loadlevel(int rx, int ry) roomtexton = true; roomtext = std::vector(otherlevel.roomtext); } + + if (game.roomx >= 102 && game.roomx <= 104 && game.roomy >= 110 && game.roomy <= 111) + { + hiddenname = "The Ship"; + } + else + { + hiddenname = "Dimension VVVVVV"; + } break; case 2: //The Lab contents = lablevel.loadlevel(rx, ry); diff --git a/desktop_version/src/Map.h b/desktop_version/src/Map.h index 1ed4cc48..5ef7e64d 100644 --- a/desktop_version/src/Map.h +++ b/desktop_version/src/Map.h @@ -94,6 +94,7 @@ public: std::string roomname; + std::string hiddenname; //Special tower stuff bool towermode; diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 83ed12a2..4bbc65af 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -1631,17 +1631,9 @@ void maprender() //draw screen alliteration //Roomname: - int temp = map.area(game.roomx, game.roomy); - if (temp < 2 && !map.custommode && graphics.fademode==0) + if (map.hiddenname != "") { - if (game.roomx >= 102 && game.roomx <= 104 && game.roomy >= 110 && game.roomy <= 111) - { - graphics.Print(5, 2, "The Ship", 196, 196, 255 - help.glow, true); - } - else - { - graphics.Print(5, 2, "Dimension VVVVVV", 196, 196, 255 - help.glow, true); - } + graphics.Print(5, 2, map.hiddenname, 196, 196, 255 - help.glow, true); } else { @@ -2402,14 +2394,7 @@ void teleporterrender() int temp = map.area(game.roomx, game.roomy); if (temp < 2 && !map.custommode && graphics.fademode==0) { - if (game.roomx >= 102 && game.roomx <= 104 && game.roomy >= 110 && game.roomy <= 111) - { - graphics.Print(5, 2, "The Ship", 196, 196, 255 - help.glow, true); - } - else - { - graphics.Print(5, 2, "Dimension VVVVVV", 196, 196, 255 - help.glow, true); - } + graphics.Print(5, 2, map.hiddenname, 196, 196, 255 - help.glow, true); } else {