if (water[qX][qY] < water[x][y] && qX >= 0 && qY >= 0 && qX < room_size && qY < room_size && water[x][y] != 0) {...}
if (qX >= 0 && qY >= 0 && qX < room_size && qY < room_size)
if (water[qX][qY] < water[x][y] && water[x][y] != 0) {
...
}
if (qX >= 0 && qY >= 0)
if (qX < room_size && qY < room_size)
if (water[qX][qY] < water[x][y] && water[x][y] != 0) {
...
}
(qX >= 0 && qY >= 0 && qX < room_size && qY < room_size)
bool isInRoom(int qX, int qY, int room_size)
{
if (qX < 0)
return false;
if (qY < 0)
return false;
if (qX >= room_size)
return false;
if (qY >= room_size)
return false;
return true;
}
if (isInRoom(qX, qY, room_size) && water[qX][qY] < water[x][y] && water[x][y] != 0)
...
if (! isInRoom(qX, qY, room_size)) // проверка предусловия
return;
if (water[qX][qY] < water[x][y] && water[x][y] != 0)
...
bool CanConsumePoint();
bool IsPointValid(Point pt);
bool pointInsideRectangle = (pointX > rectXMin) && (pointX < rectXMax) && (pointY > rectYMin) && (pointY < rectYMax);
bool pointTypeCompatible = (pointType == compatible) || (pointType == force);
bool pointValid = IsPointValid(currentPoint);
if (pointInsideRectangle && pointTypeCompatible && CanConsumePoint() && pointValid)
{
...
}
if (
water[qX][qY] < water[x][y]
&&
qX >= 0
&&
qY >= 0
&&
qX < room_size
&&
qY < room_size
&&
water[x][y] != 0
) {...}
if (water[qX][qY] < water[x][y] &&
qX >= 0 && qY >= 0 &&
qX < room_size && qY < room_size &&
water[x][y] != 0) {
...
...
}