From d76a22e020a03f90845ad87d40ab8d4a520c8b9e Mon Sep 17 00:00:00 2001 From: Nicolas F Date: Thu, 9 Mar 2017 17:28:18 +0100 Subject: [PATCH] Fix deprecated NumPy API warnings --- overviewer_core/src/iterate.c | 20 ++++++++++---------- overviewer_core/src/overviewer.h | 14 ++++++++------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/overviewer_core/src/iterate.c b/overviewer_core/src/iterate.c index 8915064..9d1d7e0 100644 --- a/overviewer_core/src/iterate.c +++ b/overviewer_core/src/iterate.c @@ -104,10 +104,10 @@ PyObject *init_chunk_render(void) { /* helper for load_chunk, loads a section into a chunk */ static inline void load_chunk_section(ChunkData *dest, int i, PyObject *section) { - dest->sections[i].blocks = PyDict_GetItemString(section, "Blocks"); - dest->sections[i].data = PyDict_GetItemString(section, "Data"); - dest->sections[i].skylight = PyDict_GetItemString(section, "SkyLight"); - dest->sections[i].blocklight = PyDict_GetItemString(section, "BlockLight"); + dest->sections[i].blocks = (PyArrayObject*) PyDict_GetItemString(section, "Blocks"); + dest->sections[i].data = (PyArrayObject*) PyDict_GetItemString(section, "Data"); + dest->sections[i].skylight = (PyArrayObject*) PyDict_GetItemString(section, "SkyLight"); + dest->sections[i].blocklight = (PyArrayObject*) PyDict_GetItemString(section, "BlockLight"); Py_INCREF(dest->sections[i].blocks); Py_INCREF(dest->sections[i].data); Py_INCREF(dest->sections[i].skylight); @@ -166,7 +166,7 @@ int load_chunk(RenderState* state, int x, int z, unsigned char required) { return 1; } - dest->biomes = PyDict_GetItemString(chunk, "Biomes"); + dest->biomes = (PyArrayObject*) PyDict_GetItemString(chunk, "Biomes"); Py_INCREF(dest->biomes); for (i = 0; i < PySequence_Fast_GET_SIZE(sections); i++) { @@ -586,11 +586,11 @@ chunk_render(PyObject *self, PyObject *args) { PyObject *imgsize, *imgsize0_py, *imgsize1_py; int imgsize0, imgsize1; - PyObject *blocks_py; - PyObject *left_blocks_py; - PyObject *right_blocks_py; - PyObject *up_left_blocks_py; - PyObject *up_right_blocks_py; + PyArrayObject *blocks_py; + PyArrayObject *left_blocks_py; + PyArrayObject *right_blocks_py; + PyArrayObject *up_left_blocks_py; + PyArrayObject *up_right_blocks_py; RenderMode *rendermode; diff --git a/overviewer_core/src/overviewer.h b/overviewer_core/src/overviewer.h index 267bce5..5041fdc 100644 --- a/overviewer_core/src/overviewer.h +++ b/overviewer_core/src/overviewer.h @@ -28,10 +28,12 @@ #define WINVER 0x0601 #define _WIN32_WINNT 0x0601 +#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION + // increment this value if you've made a change to the c extesion // and want to force users to rebuild -#define OVERVIEWER_EXTENSION_VERSION 51 +#define OVERVIEWER_EXTENSION_VERSION 52 /* Python PIL, and numpy headers */ #include @@ -88,11 +90,11 @@ typedef struct { /* whether this chunk is loaded: use load_chunk to load */ int loaded; /* chunk biome array */ - PyObject *biomes; + PyArrayObject *biomes; /* all the sections in a given chunk */ struct { /* all there is to know about each section */ - PyObject *blocks, *data, *skylight, *blocklight; + PyArrayObject *blocks, *data, *skylight, *blocklight; } sections[SECTIONS_PER_CHUNK]; } ChunkData; typedef struct { @@ -118,8 +120,8 @@ typedef struct { unsigned short block_pdata; /* useful information about this, and neighboring, chunks */ - PyObject *blockdatas; - PyObject *blocks; + PyArrayObject *blockdatas; + PyArrayObject *blocks; /* 3x3 array of this and neighboring chunk columns */ ChunkData chunks[3][3]; @@ -168,7 +170,7 @@ typedef enum static inline unsigned int get_data(RenderState *state, DataType type, int x, int y, int z) { int chunkx = 1, chunky = state->chunky, chunkz = 1; - PyObject *data_array = NULL; + PyArrayObject *data_array = NULL; unsigned int def = 0; if (type == SKYLIGHT) def = 15;