0

overviewer no longer trusts ancillary data from blocks that should have none

This commit is contained in:
Aaron Griffith
2011-12-18 04:51:53 -05:00
parent 3bdf380b6f
commit debb14c48b
3 changed files with 44 additions and 28 deletions

View File

@@ -30,6 +30,7 @@ static PyObject *transparent_blocks = NULL;
static PyObject *solid_blocks = NULL;
static PyObject *fluid_blocks = NULL;
static PyObject *nospawn_blocks = NULL;
static PyObject *nodata_blocks = NULL;
PyObject *init_chunk_render(PyObject *self, PyObject *args) {
@@ -86,6 +87,9 @@ PyObject *init_chunk_render(PyObject *self, PyObject *args) {
nospawn_blocks = PyObject_GetAttrString(textures, "nospawn_blocks");
if (!nospawn_blocks)
return NULL;
nodata_blocks = PyObject_GetAttrString(textures, "nodata_blocks");
if (!nodata_blocks)
return NULL;
block_properties = calloc(max_blockid, sizeof(unsigned char));
for (i = 0; i < max_blockid; i++) {
@@ -101,6 +105,8 @@ PyObject *init_chunk_render(PyObject *self, PyObject *args) {
block_properties[i] |= 1 << FLUID;
if (PySequence_Contains(nospawn_blocks, block))
block_properties[i] |= 1 << NOSPAWN;
if (PySequence_Contains(nodata_blocks, block))
block_properties[i] |= 1 << NODATA;
Py_DECREF(block);
}
@@ -443,22 +449,30 @@ chunk_render(PyObject *self, PyObject *args) {
}
/* everything stored here will be a borrowed ref */
ancilData = getArrayByte3D(state.blockdata_expanded, state.x, state.y, state.z);
state.block_data = ancilData;
/* block that need pseudo ancildata:
* grass, water, glass, chest, restone wire,
* ice, fence, portal, iron bars, glass panes */
if ((state.block == 2) || (state.block == 9) ||
(state.block == 20) || (state.block == 54) ||
(state.block == 55) || (state.block == 79) ||
(state.block == 85) || (state.block == 90) ||
(state.block == 101) || (state.block == 102) ||
(state.block == 113)) {
ancilData = generate_pseudo_data(&state, ancilData);
state.block_pdata = ancilData;
} else {
if (block_has_property(state.block, NODATA)) {
/* block shouldn't have data associated with it, set it to 0 */
ancilData = 0;
state.block_data = 0;
state.block_pdata = 0;
} else {
/* block has associated data, use it */
ancilData = getArrayByte3D(state.blockdata_expanded, state.x, state.y, state.z);
state.block_data = ancilData;
/* block that need pseudo ancildata:
* grass, water, glass, chest, restone wire,
* ice, fence, portal, iron bars, glass panes */
if ((state.block == 2) || (state.block == 9) ||
(state.block == 20) || (state.block == 54) ||
(state.block == 55) || (state.block == 79) ||
(state.block == 85) || (state.block == 90) ||
(state.block == 101) || (state.block == 102) ||
(state.block == 113)) {
ancilData = generate_pseudo_data(&state, ancilData);
state.block_pdata = ancilData;
} else {
state.block_pdata = 0;
}
}
/* make sure our block info is in-bounds */

View File

@@ -26,7 +26,7 @@
// increment this value if you've made a change to the c extesion
// and want to force users to rebuild
#define OVERVIEWER_EXTENSION_VERSION 13
#define OVERVIEWER_EXTENSION_VERSION 14
/* Python PIL, and numpy headers */
#include <Python.h>
@@ -102,6 +102,7 @@ typedef enum
SOLID,
FLUID,
NOSPAWN,
NODATA,
} BlockProperty;
/* globals set in init_chunk_render, here because they're used
in block_has_property */