Refactor explored rooms to use setters and getters

This makes it easier to add bounds checks to all accesses of
map.explored. Also, all manually-written existing bounds checks have
been removed, because they're going to go into the new getters and
setters.

The getter is mapclass::isexplored() and the setter is
mapclass::setexplored().
This commit is contained in:
Misa
2021-03-24 12:12:39 -07:00
committed by Ethan Lee
parent b340a6ccc4
commit c5e999c1d5
5 changed files with 66 additions and 61 deletions

View File

@@ -2413,7 +2413,7 @@ void teleporterinput(void)
{
point& tele = map.teleporters[i];
if (map.explored[tele.x + tele.y*20])
if (map.isexplored(tele.x, tele.y))
{
any_tele_unlocked = true;
break;
@@ -2430,7 +2430,7 @@ void teleporterinput(void)
tempx = map.teleporters[game.teleport_to_teleporter].x;
tempy = map.teleporters[game.teleport_to_teleporter].y;
}
while (map.explored[tempx + (20 * tempy)] == 0);
while (!map.isexplored(tempx, tempy));
}
else if (game.press_right && any_tele_unlocked)
{
@@ -2441,7 +2441,7 @@ void teleporterinput(void)
tempx = map.teleporters[game.teleport_to_teleporter].x;
tempy = map.teleporters[game.teleport_to_teleporter].y;
}
while (map.explored[tempx + (20 * tempy)] == 0);
while (!map.isexplored(tempx, tempy));
}
if (game.press_map)