mirror of
https://github.com/pret/pmd-red.git
synced 2026-10-02 13:58:56 -05:00
Document OOB grid reads in dungeon gen bug
This commit is contained in:
@@ -1934,7 +1934,9 @@ static void AssignGridCellConnections(struct GridCell grid[GRID_CELL_LEN][GRID_C
|
|||||||
if (!ok)
|
if (!ok)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// This section retains the original functionality
|
// BUG: the wrong grid index is used for the validity check for CARDINAL_DIR_UP, CARDINAL_DIR_LEFT, and CARDINAL_DIR_DOWN
|
||||||
|
// This can potentially read out-of-bounds grid data, which contains uninitialized garbage.
|
||||||
|
// This makes the dungeon gen occasionally inconsistent even when using the same seed.
|
||||||
switch (cardinalDirection & CARDINAL_DIRECTION_MASK) {
|
switch (cardinalDirection & CARDINAL_DIRECTION_MASK) {
|
||||||
case CARDINAL_DIR_RIGHT:
|
case CARDINAL_DIR_RIGHT:
|
||||||
if (!grid[x + 1][y].isInvalid) {
|
if (!grid[x + 1][y].isInvalid) {
|
||||||
@@ -1944,7 +1946,6 @@ static void AssignGridCellConnections(struct GridCell grid[GRID_CELL_LEN][GRID_C
|
|||||||
more = TRUE;
|
more = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// BUG: the wrong grid index is used for the validity check
|
|
||||||
case CARDINAL_DIR_UP:
|
case CARDINAL_DIR_UP:
|
||||||
if (!grid[x + 1][y].isInvalid) {
|
if (!grid[x + 1][y].isInvalid) {
|
||||||
grid[x][y].connectedToTop = TRUE;
|
grid[x][y].connectedToTop = TRUE;
|
||||||
@@ -1953,7 +1954,6 @@ static void AssignGridCellConnections(struct GridCell grid[GRID_CELL_LEN][GRID_C
|
|||||||
more = TRUE;
|
more = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// BUG: the wrong grid index is used for the validity check
|
|
||||||
case CARDINAL_DIR_LEFT:
|
case CARDINAL_DIR_LEFT:
|
||||||
if (!grid[x + 1][y].isInvalid) {
|
if (!grid[x + 1][y].isInvalid) {
|
||||||
grid[x][y].connectedToLeft = TRUE;
|
grid[x][y].connectedToLeft = TRUE;
|
||||||
@@ -1962,7 +1962,6 @@ static void AssignGridCellConnections(struct GridCell grid[GRID_CELL_LEN][GRID_C
|
|||||||
more = TRUE;
|
more = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// BUG: the wrong grid index is used for the validity check
|
|
||||||
case CARDINAL_DIR_DOWN:
|
case CARDINAL_DIR_DOWN:
|
||||||
if (!grid[x + 1][y].isInvalid) {
|
if (!grid[x + 1][y].isInvalid) {
|
||||||
grid[x][y].connectedToBottom = TRUE;
|
grid[x][y].connectedToBottom = TRUE;
|
||||||
|
|||||||
Reference in New Issue
Block a user