From 1dfc536b0fdf1309fad2d1f83d620a0c548c2f5e Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 4 Jul 2020 18:58:13 -0700 Subject: [PATCH] Fix infinite loop pressing left/right in tele menu w/ no teles unlocked This infinite loop would occur because once you pressed left or right, the game keeps searching through all the list of teleporters until it finds one that is unlocked. But if there's none that are unlocked, then the game goes into an infinite loop, which brings up the Not Responding dialog on Windows so you can kill it. Normally, you're not supposed to have no teleporters unlocked while being able to access a teleporter, but you can achieve this by going to Class Dismissed from a custom level (while making sure you don't start in 0,0, because there's a teleporter there that you would unlock). The solution is to make sure at least one teleporter is unlocked before doing any searching. --- desktop_version/src/Input.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index b71e6003..c9e01726 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -2335,7 +2335,22 @@ void teleporterinput() game.jumpheld = true; } - if (game.press_left) + bool any_tele_unlocked = false; + if (game.press_left || game.press_right) + { + for (size_t i = 0; i < map.teleporters.size(); i++) + { + point& tele = map.teleporters[i]; + + if (map.explored[tele.x + tele.y*20]) + { + any_tele_unlocked = true; + break; + } + } + } + + if (game.press_left && any_tele_unlocked) { do { @@ -2346,7 +2361,7 @@ void teleporterinput() } while (map.explored[tempx + (20 * tempy)] == 0); } - else if (game.press_right) + else if (game.press_right && any_tele_unlocked) { do {