universe.cpp: protect also is_splot again hole in the universe

This commit is contained in:
ALONSO Laurent
2021-10-06 15:33:38 +02:00
committed by Celtic Minstrel
parent 80c362eb60
commit a66d6ccb99

View File

@@ -899,6 +899,10 @@ bool cCurOut::is_spot(int x, int y) {
if(y >= 48) sector_y++, y -= 48;
sector_x += univ.party.outdoor_corner.x;
sector_y += univ.party.outdoor_corner.y;
// can happens if a hole allows to goes out the scenario
if (sector_x<0 || sector_x>=univ.scenario.outdoors.width() ||
sector_y<0 || sector_y>=univ.scenario.outdoors.height())
return false;
return univ.scenario.outdoors[sector_x][sector_y]->special_spot[x][y];
}
@@ -908,7 +912,7 @@ bool cCurOut::is_road(int x, int y) {
if(y >= 48) sector_y++, y -= 48;
sector_x += univ.party.outdoor_corner.x;
sector_y += univ.party.outdoor_corner.y;
// ASAN can happens if a hole allows to goes out the scenario...
// can happens if a hole allows to goes out the scenario
if (sector_x<0 || sector_x>=univ.scenario.outdoors.width() ||
sector_y<0 || sector_y>=univ.scenario.outdoors.height())
return false;