mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-09 10:29:45 +01:00
Use proper do-while for teleporter searching loop
A do-while is just a while-loop, but the inner block will always run once before the conditional is checked. It looks like in order to achieve this desired behavior (always run the block once before checking the conditional), instead of using a do-while loop, Terry just used a normal while-loop and copy-pasted the inner block on the outside. So I'm de-duplicating the code.
This commit is contained in:
parent
7f61147973
commit
aa873ce172
1 changed files with 4 additions and 10 deletions
|
@ -2337,31 +2337,25 @@ void teleporterinput()
|
|||
|
||||
if (game.press_left)
|
||||
{
|
||||
game.teleport_to_teleporter--;
|
||||
if (game.teleport_to_teleporter < 0) game.teleport_to_teleporter = map.teleporters.size() - 1;
|
||||
tempx = map.teleporters[game.teleport_to_teleporter].x;
|
||||
tempy = map.teleporters[game.teleport_to_teleporter].y;
|
||||
while (map.explored[tempx + (20 * tempy)] == 0)
|
||||
do
|
||||
{
|
||||
game.teleport_to_teleporter--;
|
||||
if (game.teleport_to_teleporter < 0) game.teleport_to_teleporter = map.teleporters.size() - 1;
|
||||
tempx = map.teleporters[game.teleport_to_teleporter].x;
|
||||
tempy = map.teleporters[game.teleport_to_teleporter].y;
|
||||
}
|
||||
while (map.explored[tempx + (20 * tempy)] == 0);
|
||||
}
|
||||
else if (game.press_right)
|
||||
{
|
||||
game.teleport_to_teleporter++;
|
||||
if (game.teleport_to_teleporter >= (int) map.teleporters.size()) game.teleport_to_teleporter = 0;
|
||||
tempx = map.teleporters[game.teleport_to_teleporter].x;
|
||||
tempy = map.teleporters[game.teleport_to_teleporter].y;
|
||||
while (map.explored[tempx + (20 * tempy)] == 0)
|
||||
do
|
||||
{
|
||||
game.teleport_to_teleporter++;
|
||||
if (game.teleport_to_teleporter >= (int) map.teleporters.size()) game.teleport_to_teleporter = 0;
|
||||
tempx = map.teleporters[game.teleport_to_teleporter].x;
|
||||
tempy = map.teleporters[game.teleport_to_teleporter].y;
|
||||
}
|
||||
while (map.explored[tempx + (20 * tempy)] == 0);
|
||||
}
|
||||
|
||||
if (game.press_map)
|
||||
|
|
Loading…
Reference in a new issue