mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-02-06 17:05:04 +03:00
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:
@@ -724,13 +724,20 @@ int mapclass::area(int _rx, int _ry)
|
|||||||
bool mapclass::isexplored(const int rx, const int ry)
|
bool mapclass::isexplored(const int rx, const int ry)
|
||||||
{
|
{
|
||||||
const int roomnum = rx + ry*20;
|
const int roomnum = rx + ry*20;
|
||||||
|
if (INBOUNDS_ARR(roomnum, explored))
|
||||||
|
{
|
||||||
return explored[roomnum];
|
return explored[roomnum];
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mapclass::setexplored(const int rx, const int ry, const bool status)
|
void mapclass::setexplored(const int rx, const int ry, const bool status)
|
||||||
{
|
{
|
||||||
const int roomnum = rx + ry*20;
|
const int roomnum = rx + ry*20;
|
||||||
|
if (INBOUNDS_ARR(roomnum, explored))
|
||||||
|
{
|
||||||
explored[roomnum] = status;
|
explored[roomnum] = status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mapclass::exploretower(void)
|
void mapclass::exploretower(void)
|
||||||
|
|||||||
Reference in New Issue
Block a user