Add bounds checks to room explored getter and setter

This means you can no longer cause Undefined Behavior by exploring a
room that is outside the array of explored room statuses.
This commit is contained in:
Misa 2021-03-24 12:14:28 -07:00 committed by Ethan Lee
parent c5e999c1d5
commit 423c79b572
1 changed files with 9 additions and 2 deletions

View File

@ -724,13 +724,20 @@ int mapclass::area(int _rx, int _ry)
bool mapclass::isexplored(const int rx, const int ry)
{
const int roomnum = rx + ry*20;
return explored[roomnum];
if (INBOUNDS_ARR(roomnum, explored))
{
return explored[roomnum];
}
return false;
}
void mapclass::setexplored(const int rx, const int ry, const bool status)
{
const int roomnum = rx + ry*20;
explored[roomnum] = status;
if (INBOUNDS_ARR(roomnum, explored))
{
explored[roomnum] = status;
}
}
void mapclass::exploretower(void)