mirror of
https://github.com/thepigeongenerator/tetris_clone.git
synced 2025-12-18 22:45:48 +01:00
fix: add out of bounds checks to tetris_intersect
This commit is contained in:
@@ -62,7 +62,11 @@ int tetris_intersect(const u8 *restrict const *restrict rows, u8 tetromino, uint
|
||||
uint *pos = (uint[8]){x, y, x, y, x, y, x, y};
|
||||
uint *end = pos + 8;
|
||||
tetris_get_blocks(tetromino, pos);
|
||||
while (pos < end && !rows[*(pos + 1)][*pos]) pos += 2;
|
||||
for (; pos < end; pos += 2) {
|
||||
if (*(pos + 0) >= TET_WIDTH) break;
|
||||
if (*(pos + 1) >= TET_HEIGHT) break;
|
||||
if (rows[*(pos + 1)][*pos]) break;
|
||||
}
|
||||
return pos < end;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user