0

Fixes segfaults in the C extension

This should have been part of 70ef0af0 but I didn't catch these.
This commit is contained in:
Andrew Brown
2012-01-16 22:00:44 -05:00
parent 66295aabd9
commit bbe105ead7
4 changed files with 11 additions and 11 deletions

View File

@@ -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 14 #define OVERVIEWER_EXTENSION_VERSION 15
/* Python PIL, and numpy headers */ /* Python PIL, and numpy headers */
#include <Python.h> #include <Python.h>

View File

@@ -103,7 +103,7 @@ cave_occluded(void *data, RenderState *state, int x, int y, int z) {
if (z != 127) { if (z != 127) {
if ( (x == 0) && (y != 15) ) { if ( (x == 0) && (y != 15) ) {
if (state->left_blocks != Py_None) { if (state->left_blocks != NULL) {
if (!is_transparent(getArrayByte3D(state->left_blocks, 15, y, z)) && if (!is_transparent(getArrayByte3D(state->left_blocks, 15, y, z)) &&
!is_transparent(getArrayByte3D(state->blocks, x, y, z+1)) && !is_transparent(getArrayByte3D(state->blocks, x, y, z+1)) &&
!is_transparent(getArrayByte3D(state->blocks, x, y+1, z))) { !is_transparent(getArrayByte3D(state->blocks, x, y+1, z))) {
@@ -115,7 +115,7 @@ cave_occluded(void *data, RenderState *state, int x, int y, int z) {
} }
if ( (x != 0) && (y == 15) ) { if ( (x != 0) && (y == 15) ) {
if (state->right_blocks != Py_None) { if (state->right_blocks != NULL) {
if (!is_transparent(getArrayByte3D(state->blocks, x-1, y, z)) && if (!is_transparent(getArrayByte3D(state->blocks, x-1, y, z)) &&
!is_transparent(getArrayByte3D(state->right_blocks, x, 0, z)) && !is_transparent(getArrayByte3D(state->right_blocks, x, 0, z)) &&
!is_transparent(getArrayByte3D(state->blocks, x, y, z+1))) { !is_transparent(getArrayByte3D(state->blocks, x, y, z+1))) {
@@ -127,8 +127,8 @@ cave_occluded(void *data, RenderState *state, int x, int y, int z) {
} }
if ( (x == 0) && (y == 15) ) { if ( (x == 0) && (y == 15) ) {
if ((state->left_blocks != Py_None) && if ((state->left_blocks != NULL) &&
(state->right_blocks != Py_None)) { (state->right_blocks != NULL)) {
if (!is_transparent(getArrayByte3D(state->left_blocks, 15, y, z)) && if (!is_transparent(getArrayByte3D(state->left_blocks, 15, y, z)) &&
!is_transparent(getArrayByte3D(state->right_blocks, x, 0, z)) && !is_transparent(getArrayByte3D(state->right_blocks, x, 0, z)) &&
!is_transparent(getArrayByte3D(state->blocks, x, y, z+1))) { !is_transparent(getArrayByte3D(state->blocks, x, y, z+1))) {

View File

@@ -45,7 +45,7 @@ edge_lines_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, P
else if ((state->block == 78) || (state->block == 93) || (state->block == 94)) // snow, redstone repeaters (on and off) else if ((state->block == 78) || (state->block == 93) || (state->block == 94)) // snow, redstone repeaters (on and off)
increment=9; increment=9;
if ((state->x == 15) && (state->up_right_blocks != Py_None)) { if ((state->x == 15) && (state->up_right_blocks != NULL)) {
unsigned char side_block = getArrayByte3D(state->up_right_blocks, 0, state->y, state->z); unsigned char side_block = getArrayByte3D(state->up_right_blocks, 0, state->y, state->z);
if (side_block != state->block && is_transparent(side_block)) { if (side_block != state->block && is_transparent(side_block)) {
ImagingDrawLine(img_i, state->imgx+12, state->imgy+1+increment, state->imgx+22+1, state->imgy+5+1+increment, &ink, 1); ImagingDrawLine(img_i, state->imgx+12, state->imgy+1+increment, state->imgx+22+1, state->imgy+5+1+increment, &ink, 1);
@@ -61,7 +61,7 @@ edge_lines_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, P
// if y != 0 and blocks[x,y-1,z] == 0 // if y != 0 and blocks[x,y-1,z] == 0
// chunk boundries are annoying // chunk boundries are annoying
if ((state->y == 0) && (state->up_left_blocks != Py_None)) { if ((state->y == 0) && (state->up_left_blocks != NULL)) {
unsigned char side_block = getArrayByte3D(state->up_left_blocks, state->x, 15, state->z); unsigned char side_block = getArrayByte3D(state->up_left_blocks, state->x, 15, state->z);
if (side_block != state->block && is_transparent(side_block)) { if (side_block != state->block && is_transparent(side_block)) {
ImagingDrawLine(img_i, state->imgx, state->imgy+6+1+increment, state->imgx+12+1, state->imgy+1+increment, &ink, 1); ImagingDrawLine(img_i, state->imgx, state->imgy+6+1+increment, state->imgx+12+1, state->imgy+1+increment, &ink, 1);

View File

@@ -133,8 +133,8 @@ estimate_blocklevel(RenderPrimitiveLighting *self, RenderState *state,
} }
/* also, make sure we have enough info to correctly calculate lighting */ /* also, make sure we have enough info to correctly calculate lighting */
if (blocks == Py_None || blocks == NULL || if (blocks == NULL ||
blocklight == Py_None || blocklight == NULL) { blocklight == NULL) {
return 0; return 0;
} }
@@ -294,7 +294,7 @@ lighting_is_face_occluded(RenderState *state, int skip_sides, int x, int y, int
/* this face isn't visible, so don't draw anything */ /* this face isn't visible, so don't draw anything */
return 1; return 1;
} }
} else if (skip_sides && (x == -1) && (state->left_blocks != Py_None)) { } else if (skip_sides && (x == -1) && (state->left_blocks != NULL)) {
unsigned char block = getArrayByte3D(state->left_blocks, 15, state->y, state->z); unsigned char block = getArrayByte3D(state->left_blocks, 15, state->y, state->z);
if (!is_transparent(block)) { if (!is_transparent(block)) {
/* the same thing but for adjacent chunks, this solves an /* the same thing but for adjacent chunks, this solves an
@@ -303,7 +303,7 @@ lighting_is_face_occluded(RenderState *state, int skip_sides, int x, int y, int
tessellate-able */ tessellate-able */
return 1; return 1;
} }
} else if (skip_sides && (y == 16) && (state->right_blocks != Py_None)) { } else if (skip_sides && (y == 16) && (state->right_blocks != NULL)) {
unsigned char block = getArrayByte3D(state->right_blocks, state->x, 0, state->z); unsigned char block = getArrayByte3D(state->right_blocks, state->x, 0, state->z);
if (!is_transparent(block)) { if (!is_transparent(block)) {
/* the same thing but for adjacent chunks, this solves an /* the same thing but for adjacent chunks, this solves an