0

Initial Python 3 port

Many things work, some don't. Notably, genPOI doesn't work, and
there's some signedness comparison stuff going on in the C extension.

This also completely drops support for Python 2, as maintaining a C
extension for both Python 2 and 3 is a pain and not worth it for the
9 months that Python 2 is still going to be supported upstream.

The documentation needs to be adjusted as well.

All of the few tests we have pass, and rendering a map works, both
with a configuration file and without. We can also use optimizeimages.

Concerns #1528.
This commit is contained in:
Nicolas F
2019-03-16 20:43:25 +01:00
parent 99eebd5b69
commit e348a548b6
33 changed files with 369 additions and 625 deletions

View File

@@ -234,9 +234,9 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
/* look up color! */
color = PySequence_GetItem(color_table, tabley * 256 + tablex);
r = PyInt_AsLong(PyTuple_GET_ITEM(color, 0));
g = PyInt_AsLong(PyTuple_GET_ITEM(color, 1));
b = PyInt_AsLong(PyTuple_GET_ITEM(color, 2));
r = PyLong_AsLong(PyTuple_GET_ITEM(color, 0));
g = PyLong_AsLong(PyTuple_GET_ITEM(color, 1));
b = PyLong_AsLong(PyTuple_GET_ITEM(color, 2));
Py_DECREF(color);
/* do the after-coloration */

View File

@@ -56,9 +56,9 @@ depth_tinting_draw(void *data, RenderState *state, PyObject *src, PyObject *mask
y = (y * 128) / (16 * SECTIONS_PER_CHUNK);
/* get the colors and tint and tint */
r = PyInt_AsLong(PyList_GetItem(self->depth_colors, 0 + y*3));
g = PyInt_AsLong(PyList_GetItem(self->depth_colors, 1 + y*3));
b = PyInt_AsLong(PyList_GetItem(self->depth_colors, 2 + y*3));
r = PyLong_AsLong(PyList_GetItem(self->depth_colors, 0 + y*3));
g = PyLong_AsLong(PyList_GetItem(self->depth_colors, 1 + y*3));
b = PyLong_AsLong(PyList_GetItem(self->depth_colors, 2 + y*3));
tint_with_mask(state->img, r, g, b, 255, mask, state->imgx, state->imgy, 0, 0);
}

View File

@@ -52,9 +52,9 @@ hide_start(void *data, RenderState *state, PyObject *support) {
for (i = 0; i < blocks_size; i++) {
PyObject *block = PyList_GET_ITEM(opt, i);
if (PyInt_Check(block)) {
if (PyLong_Check(block)) {
/* format 1: just a block id */
self->rules[i].blockid = PyInt_AsLong(block);
self->rules[i].blockid = PyLong_AsLong(block);
self->rules[i].has_data = 0;
} else if (PyArg_ParseTuple(block, "Hb", &(self->rules[i].blockid), &(self->rules[i].data))) {
/* format 2: (blockid, data) */

View File

@@ -45,9 +45,9 @@ calculate_light_color_fancy(void *data,
index = skylight + blocklight * 16;
color = PySequence_GetItem(mode->lightcolor, index);
*r = PyInt_AsLong(PyTuple_GET_ITEM(color, 0));
*g = PyInt_AsLong(PyTuple_GET_ITEM(color, 1));
*b = PyInt_AsLong(PyTuple_GET_ITEM(color, 2));
*r = PyLong_AsLong(PyTuple_GET_ITEM(color, 0));
*g = PyLong_AsLong(PyTuple_GET_ITEM(color, 1));
*b = PyLong_AsLong(PyTuple_GET_ITEM(color, 2));
Py_DECREF(color);
}
@@ -78,9 +78,9 @@ calculate_light_color_fancy_night(void *data,
index = skylight + blocklight * 16;
color = PySequence_GetItem(mode->lightcolor, index);
*r = PyInt_AsLong(PyTuple_GET_ITEM(color, 0));
*g = PyInt_AsLong(PyTuple_GET_ITEM(color, 1));
*b = PyInt_AsLong(PyTuple_GET_ITEM(color, 2));
*r = PyLong_AsLong(PyTuple_GET_ITEM(color, 0));
*g = PyLong_AsLong(PyTuple_GET_ITEM(color, 1));
*b = PyLong_AsLong(PyTuple_GET_ITEM(color, 2));
Py_DECREF(color);
}