Skip to content

Commit

Permalink
Mapgen V7: Fix out-of-bounds array access
Browse files Browse the repository at this point in the history
  • Loading branch information
kwolekr committed Jul 6, 2013
1 parent 06266ab commit 65874c2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/mapgen_v7.cpp
Expand Up @@ -427,19 +427,19 @@ void MapgenV7::generateMountainTerrain() {
return;

MapNode n_stone(c_stone);
u32 index = 0;
u32 j = 0;

for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 y = node_min.Y; y <= node_max.Y; y++) {
u32 vi = vm->m_area.index(node_min.X, y, z);
for (s16 x = node_min.X; x <= node_max.X; x++) {
int j = (z - node_min.Z) * csize.X + (x - node_min.X);
int index = (z - node_min.Z) * csize.X + (x - node_min.X);

if (getMountainTerrainFromMap(index, j, y))
if (getMountainTerrainFromMap(j, index, y))
vm->m_data[vi] = n_stone;

vi++;
index++;
j++;
}
}
}
Expand Down Expand Up @@ -517,7 +517,9 @@ void MapgenV7::generateBiomes() {
// boundary, but the chunk above has not been generated yet
if (y == node_max.Y && c_above == CONTENT_IGNORE &&
y == heightmap[index] && c == c_stone) {
int j = z * zstride + y * ystride + x;
int j = (z - node_min.Z) * zstride +
(y - node_min.Y) * ystride +
(x - node_min.X);
have_air = !getMountainTerrainFromMap(j, index, y);
}

Expand Down

0 comments on commit 65874c2

Please sign in to comment.