Fixed nether rendering crash
The nether rendering mode was not properly handling x and z values outside of the range 0 to 15. This was causing an out-of-bounds segfault when accessing the remove_block array. Fixes #881 Fixes #851 Fixes #852
This commit is contained in:
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
// increment this value if you've made a change to the c extesion
|
// increment this value if you've made a change to the c extesion
|
||||||
// and want to force users to rebuild
|
// and want to force users to rebuild
|
||||||
#define OVERVIEWER_EXTENSION_VERSION 41
|
#define OVERVIEWER_EXTENSION_VERSION 42
|
||||||
|
|
||||||
/* Python PIL, and numpy headers */
|
/* Python PIL, and numpy headers */
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
|||||||
@@ -23,20 +23,20 @@ walk_chunk(RenderState *state, RenderPrimitiveNether *data) {
|
|||||||
int x, y, z;
|
int x, y, z;
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
for (x = 0; x < WIDTH; x++) {
|
for (x = -1; x < WIDTH + 1; x++) {
|
||||||
for (z = 0; z < DEPTH; z++) {
|
for (z = -1; z < DEPTH + 1; z++) {
|
||||||
id = get_data(state, BLOCKS, x, NETHER_ROOF - (state->chunky * 16), z);
|
id = get_data(state, BLOCKS, x, NETHER_ROOF - (state->chunky * 16), z);
|
||||||
if (id == 7) {
|
if (id == 7) {
|
||||||
data->remove_block[x][NETHER_ROOF][z] = 1;
|
data->remove_block[x+1][NETHER_ROOF][z+1] = 1;
|
||||||
id = get_data(state, BLOCKS, x, (NETHER_ROOF + 1) - (state->chunky * 16), z);
|
id = get_data(state, BLOCKS, x, (NETHER_ROOF + 1) - (state->chunky * 16), z);
|
||||||
if (id == 39 || id == 40)
|
if (id == 39 || id == 40)
|
||||||
data->remove_block[x][NETHER_ROOF + 1][z] = 1;
|
data->remove_block[x+1][NETHER_ROOF + 1][z+1] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (y = NETHER_ROOF-1; y>=0; y--) {
|
for (y = NETHER_ROOF-1; y>=0; y--) {
|
||||||
id = get_data(state, BLOCKS, x, y - (state->chunky * 16), z);
|
id = get_data(state, BLOCKS, x, y - (state->chunky * 16), z);
|
||||||
if (id == 7 || id == 87)
|
if (id == 7 || id == 87)
|
||||||
data->remove_block[x][y][z] = 1;
|
data->remove_block[x+1][y][z+1] = 1;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ nether_hidden(void *data, RenderState *state, int x, int y, int z) {
|
|||||||
walk_chunk(state, self);
|
walk_chunk(state, self);
|
||||||
|
|
||||||
real_y = y + (state->chunky * 16);
|
real_y = y + (state->chunky * 16);
|
||||||
return self->remove_block[x][real_y][z];
|
return self->remove_block[x+1][real_y][z+1];
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderPrimitiveInterface primitive_nether = {
|
RenderPrimitiveInterface primitive_nether = {
|
||||||
|
|||||||
@@ -22,9 +22,11 @@
|
|||||||
#define DEPTH 16
|
#define DEPTH 16
|
||||||
#define HEIGHT 256
|
#define HEIGHT 256
|
||||||
|
|
||||||
|
// add two to these because the primative functions should expect to
|
||||||
|
// deal with x and z values of -1 and 16
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int walked_chunk;
|
int walked_chunk;
|
||||||
|
|
||||||
int remove_block[WIDTH][HEIGHT][DEPTH];
|
int remove_block[WIDTH+2][HEIGHT][DEPTH+2];
|
||||||
|
|
||||||
} RenderPrimitiveNether;
|
} RenderPrimitiveNether;
|
||||||
|
|||||||
Reference in New Issue
Block a user