0

Fix C extension build warnings the painful way

Some bad distributions (Debian) apparently are not good enough to
have a Pillow version from this decade packaged.

Therefore, we need to do it the painful way of prefixing our
symbols and refactoring everything to use them.

A new header file called "utils.h" has been added for this purpose,
and it is included in "overviewer.h".

The following macros have been prefixed with "OV_":
- MIN
- MAX
- CLAMP
- BLEND
- MULDIV255

Additionally, the C extension version was bumped to 56 because 55
was reverted back to 54.
This commit is contained in:
Nicolas F
2019-02-22 12:53:47 +01:00
parent 53fa463838
commit b70f1a012f
8 changed files with 65 additions and 61 deletions

View File

@@ -220,8 +220,8 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
rain *= temp;
/* make sure they're sane */
temp = CLAMP(temp, 0.0, 1.0);
rain = CLAMP(rain, 0.0, 1.0);
temp = OV_CLAMP(temp, 0.0, 1.0);
rain = OV_CLAMP(rain, 0.0, 1.0);
/* convert to x/y coordinates in color table */
tablex = 255 - (255 * temp);
@@ -240,9 +240,9 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
Py_DECREF(color);
/* do the after-coloration */
r = MULDIV255(r, multr, tmp);
g = MULDIV255(g, multg, tmp);
b = MULDIV255(b, multb, tmp);
r = OV_MULDIV255(r, multr, tmp);
g = OV_MULDIV255(g, multg, tmp);
b = OV_MULDIV255(b, multb, tmp);
}
/* final coloration */

View File

@@ -25,7 +25,7 @@ static void
calculate_light_color(void *data,
unsigned char skylight, unsigned char blocklight,
unsigned char *r, unsigned char *g, unsigned char *b) {
unsigned char v = 255 * powf(0.8f, 15.0 - MAX(blocklight, skylight));
unsigned char v = 255 * powf(0.8f, 15.0 - OV_MAX(blocklight, skylight));
*r = v;
*g = v;
*b = v;
@@ -40,7 +40,7 @@ calculate_light_color_fancy(void *data,
unsigned int index;
PyObject *color;
blocklight = MAX(blocklight, skylight);
blocklight = OV_MAX(blocklight, skylight);
index = skylight + blocklight * 16;
color = PySequence_GetItem(mode->lightcolor, index);
@@ -60,7 +60,7 @@ static void
calculate_light_color_night(void *data,
unsigned char skylight, unsigned char blocklight,
unsigned char *r, unsigned char *g, unsigned char *b) {
unsigned char v = 255 * powf(0.8f, 15.0 - MAX(blocklight, skylight - 11));
unsigned char v = 255 * powf(0.8f, 15.0 - OV_MAX(blocklight, skylight - 11));
*r = v;
*g = v;
*b = v;
@@ -194,7 +194,7 @@ get_lighting_color(RenderPrimitiveLighting *self, RenderState *state,
return;
}
self->calculate_light_color(self, MIN(skylevel, 15), MIN(blocklevel, 15), r, g, b);
self->calculate_light_color(self, OV_MIN(skylevel, 15), OV_MIN(blocklevel, 15), r, g, b);
}
/* does per-face occlusion checking for do_shading_with_mask */

View File

@@ -68,7 +68,7 @@ static void get_color(void *data, RenderState *state,
*b = minerals[i].b;
tmp = (128 - y_max + y) * 2 - 40;
*a = MIN(MAX(0, tmp), 255);
*a = OV_MIN(OV_MAX(0, tmp), 255);
max_i = i;
break;

View File

@@ -46,10 +46,10 @@ static void get_color(void *data, RenderState *state,
blocklight = get_data(state, BLOCKLIGHT, x, y_light, z);
skylight = get_data(state, SKYLIGHT, x, y_light, z);
if (MAX(blocklight, skylight) <= 7) {
if (OV_MAX(blocklight, skylight) <= 7) {
/* hostile mobs spawn in daylight */
*a = 240;
} else if (MAX(blocklight, skylight - 11) <= 7) {
} else if (OV_MAX(blocklight, skylight - 11) <= 7) {
/* hostile mobs spawn at night */
*a = 150;
}