Merge branch 'posix-types' of Wunkolo (#1598)
This commit is contained in:
@@ -21,19 +21,19 @@
|
||||
#include "biomes.h"
|
||||
|
||||
typedef struct {
|
||||
int use_biomes;
|
||||
int32_t use_biomes;
|
||||
/* grasscolor and foliagecolor lookup tables */
|
||||
PyObject *grasscolor, *foliagecolor, *watercolor;
|
||||
/* biome-compatible grass/leaf textures */
|
||||
PyObject* grass_texture;
|
||||
} PrimitiveBase;
|
||||
|
||||
static int
|
||||
static bool
|
||||
base_start(void* data, RenderState* state, PyObject* support) {
|
||||
PrimitiveBase* self = (PrimitiveBase*)data;
|
||||
|
||||
if (!render_mode_parse_option(support, "biomes", "i", &(self->use_biomes)))
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
/* biome-compliant grass mask (includes sides!) */
|
||||
self->grass_texture = PyObject_GetAttrString(state->textures, "biome_grass_texture");
|
||||
@@ -43,7 +43,7 @@ base_start(void* data, RenderState* state, PyObject* support) {
|
||||
self->grasscolor = PyObject_CallMethod(state->textures, "load_grass_color", "");
|
||||
self->watercolor = PyObject_CallMethod(state->textures, "load_water_color", "");
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -56,8 +56,8 @@ base_finish(void* data, RenderState* state) {
|
||||
Py_XDECREF(self->grass_texture);
|
||||
}
|
||||
|
||||
static int
|
||||
base_occluded(void* data, RenderState* state, int x, int y, int z) {
|
||||
static bool
|
||||
base_occluded(void* data, RenderState* state, int32_t x, int32_t y, int32_t z) {
|
||||
if ((x != 0) && (y != 15) && (z != 15) &&
|
||||
!render_mode_hidden(state->rendermode, x - 1, y, z) &&
|
||||
!render_mode_hidden(state->rendermode, x, y, z + 1) &&
|
||||
@@ -65,10 +65,10 @@ base_occluded(void* data, RenderState* state, int x, int y, int z) {
|
||||
!is_transparent(getArrayShort3D(state->blocks, x - 1, y, z)) &&
|
||||
!is_transparent(getArrayShort3D(state->blocks, x, y, z + 1)) &&
|
||||
!is_transparent(getArrayShort3D(state->blocks, x, y + 1, z))) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -76,8 +76,8 @@ base_draw(void* data, RenderState* state, PyObject* src, PyObject* mask, PyObjec
|
||||
PrimitiveBase* self = (PrimitiveBase*)data;
|
||||
|
||||
/* in order to detect top parts of doublePlant grass & ferns */
|
||||
unsigned short below_block = get_data(state, BLOCKS, state->x, state->y - 1, state->z);
|
||||
unsigned char below_data = get_data(state, DATA, state->x, state->y - 1, state->z);
|
||||
mc_block_t below_block = get_data(state, BLOCKS, state->x, state->y - 1, state->z);
|
||||
uint8_t below_data = get_data(state, DATA, state->x, state->y - 1, state->z);
|
||||
|
||||
/* draw the block! */
|
||||
alpha_over(state->img, src, mask, state->imgx, state->imgy, 0, 0);
|
||||
@@ -108,9 +108,9 @@ base_draw(void* data, RenderState* state, PyObject* src, PyObject* mask, PyObjec
|
||||
(state->block == block_double_plant && below_block == block_double_plant && (below_data == 2 || below_data == 3))) {
|
||||
/* do the biome stuff! */
|
||||
PyObject* facemask = mask;
|
||||
unsigned char r = 255, g = 255, b = 255;
|
||||
uint8_t r = 255, g = 255, b = 255;
|
||||
PyObject* color_table = NULL;
|
||||
unsigned char flip_xy = 0;
|
||||
bool flip_xy = false;
|
||||
|
||||
if (state->block == block_grass) {
|
||||
/* grass needs a special facemask */
|
||||
@@ -122,20 +122,17 @@ base_draw(void* data, RenderState* state, PyObject* src, PyObject* mask, PyObjec
|
||||
color_table = self->watercolor;
|
||||
} else if (block_class_is_subset(state->block, (mc_block_t[]){block_leaves, block_leaves2}, 2)) {
|
||||
color_table = self->foliagecolor;
|
||||
if (state->block_data == 2) {
|
||||
/* birch!
|
||||
birch foliage color is flipped XY-ways */
|
||||
flip_xy = 1;
|
||||
}
|
||||
/* birch foliage color is flipped XY-ways */
|
||||
flip_xy = state->block_data == 2;
|
||||
}
|
||||
|
||||
if (color_table) {
|
||||
unsigned char biome;
|
||||
int dx, dz;
|
||||
unsigned char tablex, tabley;
|
||||
uint8_t biome;
|
||||
int32_t dx, dz;
|
||||
uint8_t tablex, tabley;
|
||||
float temp = 0.0, rain = 0.0;
|
||||
unsigned int multr = 0, multg = 0, multb = 0;
|
||||
int tmp;
|
||||
uint32_t multr = 0, multg = 0, multb = 0;
|
||||
int32_t tmp;
|
||||
PyObject* color = NULL;
|
||||
|
||||
if (self->use_biomes) {
|
||||
@@ -184,7 +181,7 @@ base_draw(void* data, RenderState* state, PyObject* src, PyObject* mask, PyObjec
|
||||
tablex = 255 - (255 * temp);
|
||||
tabley = 255 - (255 * rain);
|
||||
if (flip_xy) {
|
||||
unsigned char tmp = 255 - tablex;
|
||||
uint8_t tmp = 255 - tablex;
|
||||
tablex = 255 - tabley;
|
||||
tabley = tmp;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define DEFAULT_BIOME 4 /* forest, nice and green */
|
||||
|
||||
typedef struct {
|
||||
@@ -23,7 +25,7 @@ typedef struct {
|
||||
float temperature;
|
||||
float rainfall;
|
||||
|
||||
unsigned int r, g, b;
|
||||
uint32_t r, g, b;
|
||||
} Biome;
|
||||
|
||||
/* each entry in this table is yanked *directly* out of the minecraft source
|
||||
|
||||
@@ -19,60 +19,59 @@
|
||||
#include "../overviewer.h"
|
||||
|
||||
typedef struct {
|
||||
int only_lit;
|
||||
int32_t only_lit;
|
||||
} RenderPrimitiveCave;
|
||||
|
||||
static inline int
|
||||
touches_light(RenderState* state, DataType type, unsigned int x, unsigned int y, unsigned int z) {
|
||||
static inline bool
|
||||
touches_light(RenderState* state, DataType type, uint32_t x, uint32_t y, uint32_t z) {
|
||||
if (get_data(state, type, x, y + 1, z))
|
||||
return 1;
|
||||
|
||||
return true;
|
||||
if (get_data(state, type, x + 1, y, z))
|
||||
return 1;
|
||||
return true;
|
||||
if (get_data(state, type, x - 1, y, z))
|
||||
return 1;
|
||||
return true;
|
||||
if (get_data(state, type, x, y, z + 1))
|
||||
return 1;
|
||||
return true;
|
||||
if (get_data(state, type, x, y, z - 1))
|
||||
return 1;
|
||||
return 0;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int
|
||||
cave_occluded(void* data, RenderState* state, int x, int y, int z) {
|
||||
static bool
|
||||
cave_occluded(void* data, RenderState* state, int32_t x, int32_t y, int32_t z) {
|
||||
/* check for normal occlusion */
|
||||
/* use ajacent chunks, if not you get blocks spreaded in chunk edges */
|
||||
|
||||
if (!is_known_transparent(get_data(state, BLOCKS, x - 1, y, z)) &&
|
||||
!is_known_transparent(get_data(state, BLOCKS, x, y, z + 1)) &&
|
||||
!is_known_transparent(get_data(state, BLOCKS, x, y + 1, z))) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* special handling for section boundaries */
|
||||
if (x == 0 && (!(state->chunks[0][1].loaded) || state->chunks[0][1].sections[state->chunky].blocks == NULL))
|
||||
return 1;
|
||||
return true;
|
||||
if (y == 15 && (state->chunky + 1 >= SECTIONS_PER_CHUNK || state->chunks[1][1].sections[state->chunky + 1].blocks == NULL))
|
||||
return 1;
|
||||
return true;
|
||||
if (z == 15 && (!(state->chunks[1][2].loaded) || state->chunks[1][2].sections[state->chunky].blocks == NULL))
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int
|
||||
cave_hidden(void* data, RenderState* state, int x, int y, int z) {
|
||||
static bool
|
||||
cave_hidden(void* data, RenderState* state, int32_t x, int32_t y, int32_t z) {
|
||||
RenderPrimitiveCave* self;
|
||||
int dy = 0;
|
||||
int32_t dy = 0;
|
||||
self = (RenderPrimitiveCave*)data;
|
||||
|
||||
/* check if the block is touching skylight */
|
||||
if (touches_light(state, SKYLIGHT, x, y, z)) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (self->only_lit && !touches_light(state, BLOCKLIGHT, x, y, z)) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* check for lakes and seas and don't render them
|
||||
@@ -85,7 +84,7 @@ cave_hidden(void* data, RenderState* state, int x, int y, int z) {
|
||||
for (dy = y + 1; dy < (SECTIONS_PER_CHUNK - state->chunky) * 16; dy++) {
|
||||
/* go up and check for skylight */
|
||||
if (get_data(state, SKYLIGHT, x, dy, z) != 0) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
if (get_data(state, BLOCKS, x, dy, z) != 9) {
|
||||
/* we are out of the water! and there's no skylight
|
||||
@@ -102,15 +101,15 @@ cave_hidden(void* data, RenderState* state, int x, int y, int z) {
|
||||
return cave_occluded(data, state, x, y, z);
|
||||
}
|
||||
|
||||
static int
|
||||
static bool
|
||||
cave_start(void* data, RenderState* state, PyObject* support) {
|
||||
RenderPrimitiveCave* self;
|
||||
self = (RenderPrimitiveCave*)data;
|
||||
|
||||
if (!render_mode_parse_option(support, "only_lit", "i", &(self->only_lit)))
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
RenderPrimitiveInterface primitive_cave = {
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
#include "../overviewer.h"
|
||||
|
||||
static int
|
||||
clear_base_occluded(void* data, RenderState* state, int x, int y, int z) {
|
||||
static bool
|
||||
clear_base_occluded(void* data, RenderState* state, int32_t x, int32_t y, int32_t z) {
|
||||
if ((x != 0) && (y != 15) && (z != 127) &&
|
||||
!render_mode_hidden(state->rendermode, x - 1, y, z) &&
|
||||
!render_mode_hidden(state->rendermode, x, y, z + 1) &&
|
||||
@@ -26,10 +26,10 @@ clear_base_occluded(void* data, RenderState* state, int x, int y, int z) {
|
||||
!is_transparent(getArrayShort3D(state->blocks, x - 1, y, z)) &&
|
||||
!is_transparent(getArrayShort3D(state->blocks, x, y, z + 1)) &&
|
||||
!is_transparent(getArrayShort3D(state->blocks, x, y + 1, z))) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -23,16 +23,16 @@ typedef struct {
|
||||
PyObject* depth_colors;
|
||||
} RenderPrimitiveDepthTinting;
|
||||
|
||||
static int
|
||||
static bool
|
||||
depth_tinting_start(void* data, RenderState* state, PyObject* support) {
|
||||
RenderPrimitiveDepthTinting* self;
|
||||
self = (RenderPrimitiveDepthTinting*)data;
|
||||
|
||||
self->depth_colors = PyObject_GetAttrString(support, "depth_colors");
|
||||
if (self->depth_colors == NULL)
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -46,7 +46,7 @@ depth_tinting_finish(void* data, RenderState* state) {
|
||||
static void
|
||||
depth_tinting_draw(void* data, RenderState* state, PyObject* src, PyObject* mask, PyObject* mask_light) {
|
||||
RenderPrimitiveDepthTinting* self;
|
||||
int y, r, g, b;
|
||||
int32_t y, r, g, b;
|
||||
self = (RenderPrimitiveDepthTinting*)data;
|
||||
|
||||
y = state->chunky * 16 + state->y;
|
||||
|
||||
@@ -18,30 +18,30 @@
|
||||
#include "../overviewer.h"
|
||||
|
||||
typedef struct {
|
||||
unsigned int min;
|
||||
unsigned int max;
|
||||
uint32_t min;
|
||||
uint32_t max;
|
||||
} PrimitiveDepth;
|
||||
|
||||
static int
|
||||
static bool
|
||||
depth_start(void* data, RenderState* state, PyObject* support) {
|
||||
PrimitiveDepth* self = (PrimitiveDepth*)data;
|
||||
|
||||
if (!render_mode_parse_option(support, "min", "I", &(self->min)))
|
||||
return 1;
|
||||
return true;
|
||||
if (!render_mode_parse_option(support, "max", "I", &(self->max)))
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int
|
||||
depth_hidden(void* data, RenderState* state, int x, int y, int z) {
|
||||
static bool
|
||||
depth_hidden(void* data, RenderState* state, int32_t x, int32_t y, int32_t z) {
|
||||
PrimitiveDepth* self = (PrimitiveDepth*)data;
|
||||
y += 16 * state->chunky;
|
||||
if (y > self->max || y < self->min) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
RenderPrimitiveInterface primitive_depth = {
|
||||
|
||||
@@ -23,12 +23,12 @@ typedef struct {
|
||||
float opacity;
|
||||
} PrimitiveEdgeLines;
|
||||
|
||||
static int
|
||||
static bool
|
||||
edge_lines_start(void* data, RenderState* state, PyObject* support) {
|
||||
PrimitiveEdgeLines* self = (PrimitiveEdgeLines*)data;
|
||||
if (!render_mode_parse_option(support, "opacity", "f", &(self->opacity)))
|
||||
return 1;
|
||||
return 0;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -38,11 +38,11 @@ edge_lines_draw(void* data, RenderState* state, PyObject* src, PyObject* mask, P
|
||||
/* Draw some edge lines! */
|
||||
if (block_class_is_subset(state->block, (mc_block_t[]){block_stone_slab, block_snow_layer}, 2) || !is_transparent(state->block)) {
|
||||
Imaging img_i = imaging_python_to_c(state->img);
|
||||
unsigned char ink[] = {0, 0, 0, 255 * self->opacity};
|
||||
unsigned short side_block;
|
||||
int x = state->x, y = state->y, z = state->z;
|
||||
uint8_t ink[] = {0, 0, 0, 255 * self->opacity};
|
||||
mc_block_t side_block;
|
||||
int32_t x = state->x, y = state->y, z = state->z;
|
||||
|
||||
int increment = 0;
|
||||
int32_t increment = 0;
|
||||
if (block_class_is_subset(state->block, (mc_block_t[]){block_wooden_slab, block_stone_slab}, 2) && ((state->block_data & 0x8) == 0)) // half-steps BUT no upsidown half-steps
|
||||
increment = 6;
|
||||
else if (block_class_is_subset(state->block, (mc_block_t[]){block_snow_layer, block_unpowered_repeater, block_powered_repeater}, 3)) // snow, redstone repeaters (on and off)
|
||||
|
||||
@@ -18,32 +18,32 @@
|
||||
#include "../overviewer.h"
|
||||
|
||||
typedef struct {
|
||||
unsigned int mode; /* 0 = exposed only, 1 = unexposed only */
|
||||
uint32_t mode; /* 0 = exposed only, 1 = unexposed only */
|
||||
} PrimitiveExposed;
|
||||
|
||||
static int
|
||||
static bool
|
||||
exposed_start(void* data, RenderState* state, PyObject* support) {
|
||||
PrimitiveExposed* self = (PrimitiveExposed*)data;
|
||||
|
||||
if (!render_mode_parse_option(support, "mode", "I", &(self->mode)))
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int
|
||||
exposed_hidden(void* data, RenderState* state, int x, int y, int z) {
|
||||
static bool
|
||||
exposed_hidden(void* data, RenderState* state, int32_t x, int32_t y, int32_t z) {
|
||||
PrimitiveExposed* self = (PrimitiveExposed*)data;
|
||||
|
||||
/* Unset these flags if seeming exposure from any of these directions would
|
||||
* be due to not having data there.
|
||||
*/
|
||||
int validMinusX = 1;
|
||||
int validPlusX = 1;
|
||||
int validMinusY = 1;
|
||||
int validPlusY = 1;
|
||||
int validMinusZ = 1;
|
||||
int validPlusZ = 1;
|
||||
bool validMinusX = true;
|
||||
bool validPlusX = true;
|
||||
bool validMinusY = true;
|
||||
bool validPlusY = true;
|
||||
bool validMinusZ = true;
|
||||
bool validPlusZ = true;
|
||||
|
||||
/* special handling for section boundaries */
|
||||
/* If the neighboring section has no block data, ignore exposure from that
|
||||
@@ -51,32 +51,32 @@ exposed_hidden(void* data, RenderState* state, int x, int y, int z) {
|
||||
*/
|
||||
if (x == 0 && (!(state->chunks[0][1].loaded) || state->chunks[0][1].sections[state->chunky].blocks == NULL)) {
|
||||
/* No data in -x direction */
|
||||
validMinusX = 0;
|
||||
validMinusX = false;
|
||||
}
|
||||
|
||||
if (x == 15 && (!(state->chunks[2][1].loaded) || state->chunks[2][1].sections[state->chunky].blocks == NULL)) {
|
||||
/* No data in +x direction */
|
||||
validPlusX = 0;
|
||||
validPlusX = false;
|
||||
}
|
||||
|
||||
if (y == 0 && (state->chunky - 1 < 0 || state->chunks[1][1].sections[state->chunky - 1].blocks == NULL)) {
|
||||
/* No data in -y direction */
|
||||
validMinusY = 0;
|
||||
validMinusY = false;
|
||||
}
|
||||
|
||||
if (y == 15 && (state->chunky + 1 >= SECTIONS_PER_CHUNK || state->chunks[1][1].sections[state->chunky + 1].blocks == NULL)) {
|
||||
/* No data in +y direction */
|
||||
validPlusY = 0;
|
||||
validPlusY = false;
|
||||
}
|
||||
|
||||
if (z == 0 && (!(state->chunks[1][0].loaded) || state->chunks[1][0].sections[state->chunky].blocks == NULL)) {
|
||||
/* No data in -z direction */
|
||||
validMinusZ = 0;
|
||||
validMinusZ = false;
|
||||
}
|
||||
|
||||
if (z == 15 && (!(state->chunks[1][2].loaded) || state->chunks[1][2].sections[state->chunky].blocks == NULL)) {
|
||||
/* No data in +z direction */
|
||||
validPlusZ = 0;
|
||||
validPlusZ = false;
|
||||
}
|
||||
|
||||
/* If any of the 6 blocks adjacent to us are transparent, we're exposed */
|
||||
|
||||
@@ -20,20 +20,20 @@
|
||||
typedef struct {
|
||||
PyObject* black_color;
|
||||
PyObject* white_color;
|
||||
unsigned int sealevel;
|
||||
uint32_t sealevel;
|
||||
} PrimitiveHeightFading;
|
||||
|
||||
static int
|
||||
static bool
|
||||
height_fading_start(void* data, RenderState* state, PyObject* support) {
|
||||
PrimitiveHeightFading* self = (PrimitiveHeightFading*)data;
|
||||
|
||||
if (!render_mode_parse_option(support, "sealevel", "I", &(self->sealevel)))
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
self->black_color = PyObject_GetAttrString(support, "black_color");
|
||||
self->white_color = PyObject_GetAttrString(support, "white_color");
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -48,7 +48,7 @@ static void
|
||||
height_fading_draw(void* data, RenderState* state, PyObject* src, PyObject* mask, PyObject* mask_light) {
|
||||
float alpha;
|
||||
PrimitiveHeightFading* self = (PrimitiveHeightFading*)data;
|
||||
int y = 16 * state->chunky + state->y;
|
||||
int32_t y = 16 * state->chunky + state->y;
|
||||
|
||||
/* do some height fading */
|
||||
PyObject* height_color = self->white_color;
|
||||
|
||||
@@ -19,35 +19,35 @@
|
||||
#include "../overviewer.h"
|
||||
|
||||
struct HideRule {
|
||||
unsigned short blockid;
|
||||
unsigned char has_data;
|
||||
unsigned char data;
|
||||
mc_block_t blockid;
|
||||
bool has_data;
|
||||
uint8_t data;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct HideRule* rules;
|
||||
} RenderPrimitiveHide;
|
||||
|
||||
static int
|
||||
static bool
|
||||
hide_start(void* data, RenderState* state, PyObject* support) {
|
||||
PyObject* opt;
|
||||
RenderPrimitiveHide* self = (RenderPrimitiveHide*)data;
|
||||
self->rules = NULL;
|
||||
|
||||
if (!render_mode_parse_option(support, "blocks", "O", &(opt)))
|
||||
return 1;
|
||||
return true;
|
||||
if (opt && opt != Py_None) {
|
||||
Py_ssize_t blocks_size = 0, i;
|
||||
|
||||
if (!PyList_Check(opt)) {
|
||||
PyErr_SetString(PyExc_TypeError, "'blocks' must be a list");
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
blocks_size = PyList_GET_SIZE(opt);
|
||||
self->rules = calloc(blocks_size + 1, sizeof(struct HideRule));
|
||||
if (self->rules == NULL) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
for (i = 0; i < blocks_size; i++) {
|
||||
@@ -56,20 +56,20 @@ hide_start(void* data, RenderState* state, PyObject* support) {
|
||||
if (PyLong_Check(block)) {
|
||||
/* format 1: just a block id */
|
||||
self->rules[i].blockid = PyLong_AsLong(block);
|
||||
self->rules[i].has_data = 0;
|
||||
self->rules[i].has_data = false;
|
||||
} else if (PyArg_ParseTuple(block, "Hb", &(self->rules[i].blockid), &(self->rules[i].data))) {
|
||||
/* format 2: (blockid, data) */
|
||||
self->rules[i].has_data = 1;
|
||||
self->rules[i].has_data = true;
|
||||
} else {
|
||||
/* format not recognized */
|
||||
free(self->rules);
|
||||
self->rules = NULL;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -81,30 +81,30 @@ hide_finish(void* data, RenderState* state) {
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
hide_hidden(void* data, RenderState* state, int x, int y, int z) {
|
||||
static bool
|
||||
hide_hidden(void* data, RenderState* state, int32_t x, int32_t y, int32_t z) {
|
||||
RenderPrimitiveHide* self = (RenderPrimitiveHide*)data;
|
||||
unsigned int i;
|
||||
unsigned short block;
|
||||
uint32_t i;
|
||||
mc_block_t block;
|
||||
|
||||
if (self->rules == NULL)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
block = get_data(state, BLOCKS, x, y, z);
|
||||
for (i = 0; self->rules[i].blockid != block_air; i++) {
|
||||
if (block == self->rules[i].blockid) {
|
||||
unsigned char data;
|
||||
uint8_t data;
|
||||
|
||||
if (!(self->rules[i].has_data))
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
data = get_data(state, DATA, x, y, z);
|
||||
if (data == self->rules[i].data)
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
RenderPrimitiveInterface primitive_hide = {
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
used in lighting calculations */
|
||||
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 - OV_MAX(blocklight, skylight));
|
||||
uint8_t skylight, uint8_t blocklight,
|
||||
uint8_t* r, uint8_t* g, uint8_t* b) {
|
||||
uint8_t v = 255 * powf(0.8f, 15.0 - OV_MAX(blocklight, skylight));
|
||||
*r = v;
|
||||
*g = v;
|
||||
*b = v;
|
||||
@@ -36,10 +36,10 @@ calculate_light_color(void* data,
|
||||
/* fancy version that uses the colored light texture */
|
||||
static void
|
||||
calculate_light_color_fancy(void* data,
|
||||
unsigned char skylight, unsigned char blocklight,
|
||||
unsigned char* r, unsigned char* g, unsigned char* b) {
|
||||
uint8_t skylight, uint8_t blocklight,
|
||||
uint8_t* r, uint8_t* g, uint8_t* b) {
|
||||
RenderPrimitiveLighting* mode = (RenderPrimitiveLighting*)(data);
|
||||
unsigned int index;
|
||||
uint32_t index;
|
||||
PyObject* color;
|
||||
|
||||
blocklight = OV_MAX(blocklight, skylight);
|
||||
@@ -60,9 +60,9 @@ calculate_light_color_fancy(void* data,
|
||||
*/
|
||||
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 - OV_MAX(blocklight, skylight - 11));
|
||||
uint8_t skylight, uint8_t blocklight,
|
||||
uint8_t* r, uint8_t* g, uint8_t* b) {
|
||||
uint8_t v = 255 * powf(0.8f, 15.0 - OV_MAX(blocklight, skylight - 11));
|
||||
*r = v;
|
||||
*g = v;
|
||||
*b = v;
|
||||
@@ -71,10 +71,10 @@ calculate_light_color_night(void* data,
|
||||
/* fancy night version that uses the colored light texture */
|
||||
static void
|
||||
calculate_light_color_fancy_night(void* data,
|
||||
unsigned char skylight, unsigned char blocklight,
|
||||
unsigned char* r, unsigned char* g, unsigned char* b) {
|
||||
uint8_t skylight, uint8_t blocklight,
|
||||
uint8_t* r, uint8_t* g, uint8_t* b) {
|
||||
RenderPrimitiveLighting* mode = (RenderPrimitiveLighting*)(data);
|
||||
unsigned int index;
|
||||
uint32_t index;
|
||||
PyObject* color;
|
||||
|
||||
index = skylight + blocklight * 16;
|
||||
@@ -97,26 +97,26 @@ calculate_light_color_fancy_night(void* data,
|
||||
* may (and probably should) pass NULL.
|
||||
*/
|
||||
|
||||
unsigned char
|
||||
uint8_t
|
||||
estimate_blocklevel(RenderPrimitiveLighting* self, RenderState* state,
|
||||
int x, int y, int z, int* authoratative) {
|
||||
int32_t x, int32_t y, int32_t z, bool* authoratative) {
|
||||
|
||||
/* placeholders for later data arrays, coordinates */
|
||||
unsigned short block;
|
||||
unsigned char blocklevel;
|
||||
unsigned int average_count = 0, average_gather = 0, coeff = 0;
|
||||
mc_block_t block;
|
||||
uint8_t blocklevel;
|
||||
uint32_t average_count = 0, average_gather = 0, coeff = 0;
|
||||
|
||||
/* defaults to "guess" until told otherwise */
|
||||
if (authoratative)
|
||||
*authoratative = 0;
|
||||
*authoratative = false;
|
||||
|
||||
block = get_data(state, BLOCKS, x, y, z);
|
||||
|
||||
if (authoratative == NULL) {
|
||||
int auth;
|
||||
bool auth;
|
||||
|
||||
/* iterate through all surrounding blocks to take an average */
|
||||
int dx, dy, dz, local_block;
|
||||
int32_t dx, dy, dz, local_block;
|
||||
for (dx = -1; dx <= 1; dx += 2) {
|
||||
for (dy = -1; dy <= 1; dy += 2) {
|
||||
for (dz = -1; dz <= 1; dz += 2) {
|
||||
@@ -150,12 +150,12 @@ estimate_blocklevel(RenderPrimitiveLighting* self, RenderState* state,
|
||||
|
||||
inline void
|
||||
get_lighting_color(RenderPrimitiveLighting* self, RenderState* state,
|
||||
int x, int y, int z,
|
||||
unsigned char* r, unsigned char* g, unsigned char* b) {
|
||||
int32_t x, int32_t y, int32_t z,
|
||||
uint8_t* r, uint8_t* g, uint8_t* b) {
|
||||
|
||||
/* placeholders for later data arrays, coordinates */
|
||||
unsigned short block;
|
||||
unsigned char skylevel, blocklevel;
|
||||
mc_block_t block;
|
||||
uint8_t skylevel, blocklevel;
|
||||
|
||||
block = get_data(state, BLOCKS, x, y, z);
|
||||
skylevel = get_data(state, SKYLIGHT, x, y, z);
|
||||
@@ -164,10 +164,10 @@ get_lighting_color(RenderPrimitiveLighting* self, RenderState* state,
|
||||
/* special half-step handling, stairs handling */
|
||||
/* Anvil also needs to be here, blockid 145 */
|
||||
if (block_class_is_subset(block, block_class_alt_height, block_class_alt_height_len) || block == block_anvil) {
|
||||
unsigned int upper_block;
|
||||
uint32_t upper_block;
|
||||
|
||||
/* stairs and half-blocks take the skylevel from the upper block if it's transparent */
|
||||
int upper_counter = 0;
|
||||
int32_t upper_counter = 0;
|
||||
/* but if the upper_block is one of these special half-steps, we need to look at *its* upper_block */
|
||||
do {
|
||||
upper_counter++;
|
||||
@@ -196,35 +196,35 @@ get_lighting_color(RenderPrimitiveLighting* self, RenderState* state,
|
||||
}
|
||||
|
||||
/* does per-face occlusion checking for do_shading_with_mask */
|
||||
inline int
|
||||
lighting_is_face_occluded(RenderState* state, int skip_sides, int x, int y, int z) {
|
||||
inline bool
|
||||
lighting_is_face_occluded(RenderState* state, bool skip_sides, int32_t x, int32_t y, int32_t z) {
|
||||
/* first, check for occlusion if the block is in the local chunk */
|
||||
if (x >= 0 && x < 16 && y >= 0 && y < 16 && z >= 0 && z < 16) {
|
||||
unsigned short block = getArrayShort3D(state->blocks, x, y, z);
|
||||
mc_block_t block = getArrayShort3D(state->blocks, x, y, z);
|
||||
|
||||
if (!is_transparent(block) && !render_mode_hidden(state->rendermode, x, y, z)) {
|
||||
/* this face isn't visible, so don't draw anything */
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
} else if (!skip_sides) {
|
||||
unsigned short block = get_data(state, BLOCKS, x, y, z);
|
||||
mc_block_t block = get_data(state, BLOCKS, x, y, z);
|
||||
if (!is_transparent(block)) {
|
||||
/* the same thing but for adjacent chunks, this solves an
|
||||
ugly black doted line between chunks in night rendermode.
|
||||
This wouldn't be necessary if the textures were truly
|
||||
tessellate-able */
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* shades the drawn block with the given facemask, based on the
|
||||
lighting results from (x, y, z) */
|
||||
static inline void
|
||||
do_shading_with_mask(RenderPrimitiveLighting* self, RenderState* state,
|
||||
int x, int y, int z, PyObject* mask) {
|
||||
unsigned char r, g, b;
|
||||
int32_t x, int32_t y, int32_t z, PyObject* mask) {
|
||||
uint8_t r, g, b;
|
||||
float comp_strength;
|
||||
|
||||
/* check occlusion */
|
||||
@@ -241,20 +241,20 @@ do_shading_with_mask(RenderPrimitiveLighting* self, RenderState* state,
|
||||
tint_with_mask(state->img, r, g, b, 255, mask, state->imgx, state->imgy, 0, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
static int32_t
|
||||
lighting_start(void* data, RenderState* state, PyObject* support) {
|
||||
RenderPrimitiveLighting* self;
|
||||
self = (RenderPrimitiveLighting*)data;
|
||||
|
||||
/* don't skip sides by default */
|
||||
self->skip_sides = 0;
|
||||
self->skip_sides = false;
|
||||
|
||||
if (!render_mode_parse_option(support, "strength", "f", &(self->strength)))
|
||||
return 1;
|
||||
if (!render_mode_parse_option(support, "night", "i", &(self->night)))
|
||||
return 1;
|
||||
if (!render_mode_parse_option(support, "color", "i", &(self->color)))
|
||||
return 1;
|
||||
return true;
|
||||
if (!render_mode_parse_option(support, "night", "p", &(self->night)))
|
||||
return true;
|
||||
if (!render_mode_parse_option(support, "color", "p", &(self->color)))
|
||||
return true;
|
||||
|
||||
self->facemasks_py = PyObject_GetAttrString(support, "facemasks");
|
||||
// borrowed references, don't need to be decref'd
|
||||
@@ -273,7 +273,7 @@ lighting_start(void* data, RenderState* state, PyObject* support) {
|
||||
if (self->lightcolor == Py_None) {
|
||||
Py_DECREF(self->lightcolor);
|
||||
self->lightcolor = NULL;
|
||||
self->color = 0;
|
||||
self->color = false;
|
||||
} else {
|
||||
if (self->night) {
|
||||
self->calculate_light_color = calculate_light_color_fancy_night;
|
||||
@@ -285,7 +285,7 @@ lighting_start(void* data, RenderState* state, PyObject* support) {
|
||||
self->lightcolor = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -298,7 +298,7 @@ lighting_finish(void* data, RenderState* state) {
|
||||
static void
|
||||
lighting_draw(void* data, RenderState* state, PyObject* src, PyObject* mask, PyObject* mask_light) {
|
||||
RenderPrimitiveLighting* self;
|
||||
int x, y, z;
|
||||
int32_t x, y, z;
|
||||
|
||||
self = (RenderPrimitiveLighting*)data;
|
||||
x = state->x, y = state->y, z = state->z;
|
||||
|
||||
@@ -26,21 +26,21 @@ typedef struct {
|
||||
|
||||
/* can be overridden in derived rendermodes to control lighting
|
||||
arguments are data, skylight, blocklight, return RGB */
|
||||
void (*calculate_light_color)(void*, unsigned char, unsigned char, unsigned char*, unsigned char*, unsigned char*);
|
||||
void (*calculate_light_color)(void*, uint8_t, uint8_t, uint8_t*, uint8_t*, uint8_t*);
|
||||
|
||||
/* can be set to 0 in derived modes to indicate that lighting the chunk
|
||||
* sides is actually important. Right now, this is used in cave mode
|
||||
*/
|
||||
int skip_sides;
|
||||
bool skip_sides;
|
||||
|
||||
float strength;
|
||||
int color;
|
||||
int night;
|
||||
int32_t color;
|
||||
int32_t night;
|
||||
} RenderPrimitiveLighting;
|
||||
|
||||
/* exposed so that smooth-lighting can use them */
|
||||
extern RenderPrimitiveInterface primitive_lighting;
|
||||
int lighting_is_face_occluded(RenderState* state, int skip_sides, int x, int y, int z);
|
||||
bool lighting_is_face_occluded(RenderState* state, bool skip_sides, int32_t x, int32_t y, int32_t z);
|
||||
void get_lighting_color(RenderPrimitiveLighting* self, RenderState* state,
|
||||
int x, int y, int z,
|
||||
unsigned char* r, unsigned char* g, unsigned char* b);
|
||||
int32_t x, int32_t y, int32_t z,
|
||||
uint8_t* r, uint8_t* g, uint8_t* b);
|
||||
|
||||
@@ -22,35 +22,35 @@
|
||||
|
||||
static void
|
||||
walk_chunk(RenderState* state, RenderPrimitiveNether* data) {
|
||||
int x, y, z;
|
||||
int id;
|
||||
int32_t x, y, z;
|
||||
mc_block_t blockid;
|
||||
|
||||
for (x = -1; x < WIDTH + 1; x++) {
|
||||
for (z = -1; z < DEPTH + 1; z++) {
|
||||
id = get_data(state, BLOCKS, x, NETHER_ROOF - (state->chunky * 16), z);
|
||||
if (id == block_bedrock) {
|
||||
data->remove_block[x + 1][NETHER_ROOF][z + 1] = 1;
|
||||
id = get_data(state, BLOCKS, x, (NETHER_ROOF + 1) - (state->chunky * 16), z);
|
||||
if (id == block_brown_mushroom || id == block_red_mushroom)
|
||||
data->remove_block[x + 1][NETHER_ROOF + 1][z + 1] = 1;
|
||||
blockid = get_data(state, BLOCKS, x, NETHER_ROOF - (state->chunky * 16), z);
|
||||
if (blockid == block_bedrock) {
|
||||
data->remove_block[x + 1][NETHER_ROOF][z + 1] = true;
|
||||
blockid = get_data(state, BLOCKS, x, (NETHER_ROOF + 1) - (state->chunky * 16), z);
|
||||
if (blockid == block_brown_mushroom || blockid == block_red_mushroom)
|
||||
data->remove_block[x + 1][NETHER_ROOF + 1][z + 1] = true;
|
||||
}
|
||||
|
||||
for (y = NETHER_ROOF - 1; y >= 0; y--) {
|
||||
id = get_data(state, BLOCKS, x, y - (state->chunky * 16), z);
|
||||
if (block_class_is_subset(id, (mc_block_t[]){block_bedrock, block_netherrack, block_quartz_ore, block_lava}, 4))
|
||||
data->remove_block[x + 1][y][z + 1] = 1;
|
||||
blockid = get_data(state, BLOCKS, x, y - (state->chunky * 16), z);
|
||||
if (block_class_is_subset(blockid, (mc_block_t[]){block_bedrock, block_netherrack, block_quartz_ore, block_lava}, 4))
|
||||
data->remove_block[x + 1][y][z + 1] = true;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
data->walked_chunk = 1;
|
||||
data->walked_chunk = true;
|
||||
}
|
||||
|
||||
static int
|
||||
nether_hidden(void* data, RenderState* state, int x, int y, int z) {
|
||||
static bool
|
||||
nether_hidden(void* data, RenderState* state, int32_t x, int32_t y, int32_t z) {
|
||||
RenderPrimitiveNether* self;
|
||||
int real_y;
|
||||
int32_t real_y;
|
||||
|
||||
self = (RenderPrimitiveNether*)data;
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
// add two to these because the primative functions should expect to
|
||||
// deal with x and z values of -1 and 16
|
||||
typedef struct {
|
||||
int walked_chunk;
|
||||
bool walked_chunk;
|
||||
|
||||
int remove_block[WIDTH + 2][HEIGHT][DEPTH + 2];
|
||||
bool remove_block[WIDTH + 2][HEIGHT][DEPTH + 2];
|
||||
|
||||
} RenderPrimitiveNether;
|
||||
|
||||
@@ -17,33 +17,33 @@
|
||||
|
||||
#include "../overviewer.h"
|
||||
|
||||
static int
|
||||
netherold_hidden(void* data, RenderState* state, int x, int y, int z) {
|
||||
static bool
|
||||
netherold_hidden(void* data, RenderState* state, int32_t x, int32_t y, int32_t z) {
|
||||
/* hide all blocks above all air blocks
|
||||
|
||||
due to how the nether is currently generated, this will also count
|
||||
empty sections as 'solid'
|
||||
*/
|
||||
unsigned char missing_section = 0;
|
||||
bool missing_section = false;
|
||||
while (y < (SECTIONS_PER_CHUNK - state->chunky) * 16) {
|
||||
if (state->chunks[1][1].sections[state->chunky + (y / 16)].blocks == NULL) {
|
||||
missing_section = 1;
|
||||
missing_section = true;
|
||||
y += 16;
|
||||
continue;
|
||||
} else {
|
||||
/* if we passed through a missing section, but now are back in,
|
||||
that counts as air */
|
||||
if (missing_section)
|
||||
return 0;
|
||||
missing_section = 0;
|
||||
return false;
|
||||
missing_section = true;
|
||||
}
|
||||
|
||||
if (!missing_section && get_data(state, BLOCKS, x, y, z) == 0) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
RenderPrimitiveInterface primitive_nether_old = {
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
|
||||
#include "../overviewer.h"
|
||||
|
||||
static int
|
||||
static bool
|
||||
no_fluids_start(void* data, RenderState* state, PyObject* support) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int
|
||||
no_fluids_hidden(void* data, RenderState* state, int x, int y, int z) {
|
||||
static bool
|
||||
no_fluids_hidden(void* data, RenderState* state, int32_t x, int32_t y, int32_t z) {
|
||||
return block_has_property(state->block, FLUID);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ typedef struct {
|
||||
} RenderPrimitiveBiomes;
|
||||
|
||||
struct BiomeColor {
|
||||
unsigned char biome;
|
||||
unsigned char r, g, b;
|
||||
uint8_t biome;
|
||||
uint8_t r, g, b;
|
||||
};
|
||||
|
||||
static struct BiomeColor default_biomes[] = {
|
||||
@@ -76,18 +76,18 @@ static struct BiomeColor default_biomes[] = {
|
||||
{255, 0, 0, 0}};
|
||||
|
||||
static void get_color(void* data, RenderState* state,
|
||||
unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a) {
|
||||
uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) {
|
||||
|
||||
unsigned char biome;
|
||||
int x = state->x, z = state->z, y_max, y;
|
||||
int max_i = -1;
|
||||
uint8_t biome;
|
||||
int32_t x = state->x, z = state->z, y_max, y;
|
||||
int32_t max_i = -1;
|
||||
RenderPrimitiveBiomes* self = (RenderPrimitiveBiomes*)data;
|
||||
struct BiomeColor* biomes = (struct BiomeColor*)(self->biomes);
|
||||
*a = 0;
|
||||
|
||||
y_max = state->y + 1;
|
||||
for (y = state->chunky * -16; y <= y_max; y++) {
|
||||
int i, tmp;
|
||||
int32_t i, tmp;
|
||||
biome = get_data(state, BIOMES, x, y, z);
|
||||
|
||||
if (biome >= NUM_BIOMES) {
|
||||
@@ -110,15 +110,15 @@ static void get_color(void* data, RenderState* state,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static bool
|
||||
overlay_biomes_start(void* data, RenderState* state, PyObject* support) {
|
||||
PyObject* opt;
|
||||
RenderPrimitiveBiomes* self;
|
||||
unsigned char alpha_tmp = 0;
|
||||
uint8_t alpha_tmp = 0;
|
||||
|
||||
/* first, chain up */
|
||||
int ret = primitive_overlay.start(data, state, support);
|
||||
if (ret != 0)
|
||||
bool ret = primitive_overlay.start(data, state, support);
|
||||
if (ret != false)
|
||||
return ret;
|
||||
|
||||
/* now do custom initializations */
|
||||
@@ -126,7 +126,7 @@ overlay_biomes_start(void* data, RenderState* state, PyObject* support) {
|
||||
|
||||
// opt is a borrowed reference. do not deref
|
||||
if (!render_mode_parse_option(support, "biomes", "O", &(opt)))
|
||||
return 1;
|
||||
return true;
|
||||
if (opt && opt != Py_None) {
|
||||
struct BiomeColor* biomes = NULL;
|
||||
Py_ssize_t biomes_size = 0, i;
|
||||
@@ -134,24 +134,24 @@ overlay_biomes_start(void* data, RenderState* state, PyObject* support) {
|
||||
|
||||
if (!PyList_Check(opt)) {
|
||||
PyErr_SetString(PyExc_TypeError, "'biomes' must be a list");
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
biomes_size = PyList_GET_SIZE(opt);
|
||||
biomes = self->biomes = calloc(biomes_size + 1, sizeof(struct BiomeColor));
|
||||
if (biomes == NULL) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
for (i = 0; i < biomes_size; i++) {
|
||||
PyObject* biome = PyList_GET_ITEM(opt, i);
|
||||
char* tmpname = NULL;
|
||||
int j = 0;
|
||||
int32_t j = 0;
|
||||
|
||||
if (!PyArg_ParseTuple(biome, "s(bbb)", &tmpname, &(biomes[i].r), &(biomes[i].g), &(biomes[i].b))) {
|
||||
free(biomes);
|
||||
self->biomes = NULL;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
//printf("%s, (%d, %d, %d) ->", tmpname, biomes[i].r, biomes[i].g, biomes[i].b);
|
||||
@@ -181,7 +181,7 @@ overlay_biomes_start(void* data, RenderState* state, PyObject* support) {
|
||||
/* setup custom color */
|
||||
self->parent.get_color = get_color;
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -26,8 +26,8 @@ typedef struct {
|
||||
} RenderPrimitiveMineral;
|
||||
|
||||
struct MineralColor {
|
||||
unsigned char blockid;
|
||||
unsigned char r, g, b;
|
||||
mc_block_t block;
|
||||
uint8_t r, g, b;
|
||||
};
|
||||
|
||||
/* put more valuable ores first -- they take precedence */
|
||||
@@ -48,21 +48,21 @@ static struct MineralColor default_minerals[] = {
|
||||
{0, 0, 0, 0}};
|
||||
|
||||
static void get_color(void* data, RenderState* state,
|
||||
unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a) {
|
||||
uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) {
|
||||
|
||||
int x = state->x, z = state->z, y_max, y;
|
||||
int max_i = -1;
|
||||
int32_t x = state->x, z = state->z, y_max, y;
|
||||
int32_t max_i = -1;
|
||||
RenderPrimitiveMineral* self = (RenderPrimitiveMineral*)data;
|
||||
struct MineralColor* minerals = (struct MineralColor*)(self->minerals);
|
||||
*a = 0;
|
||||
|
||||
y_max = state->y + 1;
|
||||
for (y = state->chunky * -16; y <= y_max; y++) {
|
||||
int i, tmp;
|
||||
unsigned short blockid = get_data(state, BLOCKS, x, y, z);
|
||||
int32_t i, tmp;
|
||||
mc_block_t block = get_data(state, BLOCKS, x, y, z);
|
||||
|
||||
for (i = 0; (max_i == -1 || i < max_i) && minerals[i].blockid != block_air; i++) {
|
||||
if (minerals[i].blockid == blockid) {
|
||||
for (i = 0; (max_i == -1 || i < max_i) && minerals[i].block != block_air; i++) {
|
||||
if (minerals[i].block == block) {
|
||||
*r = minerals[i].r;
|
||||
*g = minerals[i].g;
|
||||
*b = minerals[i].b;
|
||||
@@ -77,14 +77,14 @@ static void get_color(void* data, RenderState* state,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static bool
|
||||
overlay_mineral_start(void* data, RenderState* state, PyObject* support) {
|
||||
PyObject* opt;
|
||||
RenderPrimitiveMineral* self;
|
||||
|
||||
/* first, chain up */
|
||||
int ret = primitive_overlay.start(data, state, support);
|
||||
if (ret != 0)
|
||||
bool ret = primitive_overlay.start(data, state, support);
|
||||
if (ret != false)
|
||||
return ret;
|
||||
|
||||
/* now do custom initializations */
|
||||
@@ -92,7 +92,7 @@ overlay_mineral_start(void* data, RenderState* state, PyObject* support) {
|
||||
|
||||
// opt is a borrowed reference. do not deref
|
||||
if (!render_mode_parse_option(support, "minerals", "O", &(opt)))
|
||||
return 1;
|
||||
return true;
|
||||
if (opt && opt != Py_None) {
|
||||
struct MineralColor* minerals = NULL;
|
||||
Py_ssize_t minerals_size = 0, i;
|
||||
@@ -100,21 +100,21 @@ overlay_mineral_start(void* data, RenderState* state, PyObject* support) {
|
||||
|
||||
if (!PyList_Check(opt)) {
|
||||
PyErr_SetString(PyExc_TypeError, "'minerals' must be a list");
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
minerals_size = PyList_GET_SIZE(opt);
|
||||
minerals = self->minerals = calloc(minerals_size + 1, sizeof(struct MineralColor));
|
||||
if (minerals == NULL) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
for (i = 0; i < minerals_size; i++) {
|
||||
PyObject* mineral = PyList_GET_ITEM(opt, i);
|
||||
if (!PyArg_ParseTuple(mineral, "b(bbb)", &(minerals[i].blockid), &(minerals[i].r), &(minerals[i].g), &(minerals[i].b))) {
|
||||
if (!PyArg_ParseTuple(mineral, "b(bbb)", &(minerals[i].block), &(minerals[i].r), &(minerals[i].g), &(minerals[i].b))) {
|
||||
free(minerals);
|
||||
self->minerals = NULL;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -124,7 +124,7 @@ overlay_mineral_start(void* data, RenderState* state, PyObject* support) {
|
||||
/* setup custom color */
|
||||
self->parent.get_color = get_color;
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
typedef struct {
|
||||
/* inherits from overlay */
|
||||
RenderPrimitiveOverlay parent;
|
||||
long long seed; // needs to be at least 64-bits
|
||||
int64_t seed; // needs to be at least 64-bits
|
||||
} RenderPrimitiveSlime;
|
||||
|
||||
/*
|
||||
@@ -30,49 +30,44 @@ typedef struct {
|
||||
* http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Random.html
|
||||
*/
|
||||
|
||||
static void random_set_seed(long long* seed, long long new_seed) {
|
||||
static void random_set_seed(int64_t* seed, int64_t new_seed) {
|
||||
*seed = (new_seed ^ 0x5deece66dLL) & ((1LL << 48) - 1);
|
||||
}
|
||||
|
||||
static int random_next(long long* seed, int bits) {
|
||||
static int64_t random_next(int64_t* seed, int32_t bits) {
|
||||
*seed = (*seed * 0x5deece66dLL + 0xbL) & ((1LL << 48) - 1);
|
||||
return (int)(*seed >> (48 - bits));
|
||||
return (int64_t)(*seed >> (48 - bits));
|
||||
}
|
||||
|
||||
static int random_next_int(long long* seed, int n) {
|
||||
int bits, val;
|
||||
static int64_t random_next_int(int64_t* seed, uint32_t modulo) {
|
||||
int64_t bits, val;
|
||||
|
||||
if (n <= 0) {
|
||||
/* invalid */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((n & -n) == n) {
|
||||
/* n is a power of two */
|
||||
return (int)((n * (long long)random_next(seed, 31)) >> 31);
|
||||
if ((modulo & -modulo) == modulo) {
|
||||
/* modulo is a power of two */
|
||||
return (int64_t)((modulo * (int64_t)random_next(seed, 31)) >> 31);
|
||||
}
|
||||
|
||||
do {
|
||||
bits = random_next(seed, 31);
|
||||
val = bits % n;
|
||||
} while (bits - val + (n - 1) < 0);
|
||||
val = bits % modulo;
|
||||
} while (bits - val + (modulo - 1) < 0);
|
||||
return val;
|
||||
}
|
||||
|
||||
static int is_slime(long long map_seed, int chunkx, int chunkz) {
|
||||
static bool is_slime(int64_t map_seed, int32_t chunkx, int32_t chunkz) {
|
||||
/* lots of magic numbers, but they're all correct! I swear! */
|
||||
long long seed;
|
||||
int64_t seed;
|
||||
random_set_seed(&seed, (map_seed +
|
||||
(long long)(chunkx * chunkx * 0x4c1906) +
|
||||
(long long)(chunkx * 0x5ac0db) +
|
||||
(long long)(chunkz * chunkz * 0x4307a7LL) +
|
||||
(long long)(chunkz * 0x5f24f)) ^
|
||||
(int64_t)(chunkx * chunkx * 0x4c1906) +
|
||||
(int64_t)(chunkx * 0x5ac0db) +
|
||||
(int64_t)(chunkz * chunkz * 0x4307a7LL) +
|
||||
(int64_t)(chunkz * 0x5f24f)) ^
|
||||
0x3ad8025f);
|
||||
return (random_next_int(&seed, 10) == 0);
|
||||
}
|
||||
|
||||
static void get_color(void* data, RenderState* state,
|
||||
unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a) {
|
||||
uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) {
|
||||
RenderPrimitiveSlime* self = (RenderPrimitiveSlime*)data;
|
||||
|
||||
/* set a nice, pretty green color */
|
||||
@@ -89,14 +84,14 @@ static void get_color(void* data, RenderState* state,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static bool
|
||||
overlay_slime_start(void* data, RenderState* state, PyObject* support) {
|
||||
RenderPrimitiveSlime* self;
|
||||
PyObject* pyseed;
|
||||
|
||||
/* first, chain up */
|
||||
int ret = primitive_overlay.start(data, state, support);
|
||||
if (ret != 0)
|
||||
bool ret = primitive_overlay.start(data, state, support);
|
||||
if (ret != false)
|
||||
return ret;
|
||||
|
||||
/* now do custom initializations */
|
||||
@@ -110,13 +105,13 @@ overlay_slime_start(void* data, RenderState* state, PyObject* support) {
|
||||
|
||||
pyseed = PyObject_GetAttrString(state->world, "seed");
|
||||
if (!pyseed)
|
||||
return 1;
|
||||
return true;
|
||||
self->seed = PyLong_AsLongLong(pyseed);
|
||||
Py_DECREF(pyseed);
|
||||
if (PyErr_Occurred())
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -24,11 +24,11 @@ typedef struct {
|
||||
} RenderPrimitiveSpawn;
|
||||
|
||||
static void get_color(void* data, RenderState* state,
|
||||
unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a) {
|
||||
uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) {
|
||||
RenderPrimitiveSpawn* self = (RenderPrimitiveSpawn*)data;
|
||||
int x = state->x, y = state->y, z = state->z;
|
||||
int y_light = y + 1;
|
||||
unsigned char blocklight, skylight;
|
||||
int32_t x = state->x, y = state->y, z = state->z;
|
||||
int32_t y_light = y + 1;
|
||||
uint8_t blocklight, skylight;
|
||||
|
||||
/* set a nice, pretty red color */
|
||||
*r = self->parent.color->r;
|
||||
@@ -55,13 +55,13 @@ static void get_color(void* data, RenderState* state,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
static bool
|
||||
overlay_spawn_start(void* data, RenderState* state, PyObject* support) {
|
||||
RenderPrimitiveSpawn* self;
|
||||
|
||||
/* first, chain up */
|
||||
int ret = primitive_overlay.start(data, state, support);
|
||||
if (ret != 0)
|
||||
bool ret = primitive_overlay.start(data, state, support);
|
||||
if (ret != false)
|
||||
return ret;
|
||||
|
||||
/* now do custom initializations */
|
||||
@@ -73,7 +73,7 @@ overlay_spawn_start(void* data, RenderState* state, PyObject* support) {
|
||||
self->parent.default_color.b = 38;
|
||||
self->parent.default_color.a = 0;
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -18,38 +18,35 @@
|
||||
#include "../mc_id.h"
|
||||
#include "overlay.h"
|
||||
|
||||
typedef enum { false,
|
||||
true } bool;
|
||||
|
||||
typedef struct {
|
||||
/* inherits from overlay */
|
||||
RenderPrimitiveOverlay parent;
|
||||
void* structures;
|
||||
int numcolors;
|
||||
int32_t numcolors;
|
||||
} RenderPrimitiveStructure;
|
||||
|
||||
struct Condition {
|
||||
int relx, rely, relz;
|
||||
unsigned short block;
|
||||
int32_t relx, rely, relz;
|
||||
mc_block_t block;
|
||||
};
|
||||
|
||||
struct Color {
|
||||
int numconds;
|
||||
int32_t numconds;
|
||||
struct Condition* conditions;
|
||||
unsigned char r, g, b, a;
|
||||
uint8_t r, g, b, a;
|
||||
};
|
||||
|
||||
static void get_color(void* data,
|
||||
RenderState* state,
|
||||
unsigned char* r,
|
||||
unsigned char* g,
|
||||
unsigned char* b,
|
||||
unsigned char* a) {
|
||||
uint8_t* r,
|
||||
uint8_t* g,
|
||||
uint8_t* b,
|
||||
uint8_t* a) {
|
||||
/**
|
||||
* Calculate the color at the current position and store the values to r,g,b,a.
|
||||
**/
|
||||
RenderPrimitiveStructure* self = (RenderPrimitiveStructure*)data;
|
||||
int x = state->x, z = state->z, y_max, y, col, cond;
|
||||
int32_t x = state->x, z = state->z, y_max, y, col, cond;
|
||||
struct Color* structures = (struct Color*)(self->structures);
|
||||
struct Condition* c = NULL;
|
||||
bool all = true;
|
||||
@@ -86,7 +83,7 @@ static void get_color(void* data,
|
||||
return;
|
||||
}
|
||||
|
||||
static int overlay_structure_start(void* data, RenderState* state, PyObject* support) {
|
||||
static bool overlay_structure_start(void* data, RenderState* state, PyObject* support) {
|
||||
/**
|
||||
* Initializing the search for structures by parsing the arguments and storing them into
|
||||
* appropriate structures. If no arguments are passed create and use default values.
|
||||
@@ -95,8 +92,8 @@ static int overlay_structure_start(void* data, RenderState* state, PyObject* sup
|
||||
RenderPrimitiveStructure* self;
|
||||
|
||||
/* first, chain up */
|
||||
int ret = primitive_overlay.start(data, state, support);
|
||||
if (ret != 0)
|
||||
bool ret = primitive_overlay.start(data, state, support);
|
||||
if (ret != false)
|
||||
return ret;
|
||||
|
||||
/* now do custom initializations */
|
||||
@@ -105,7 +102,7 @@ static int overlay_structure_start(void* data, RenderState* state, PyObject* sup
|
||||
// opt is a borrowed reference. do not deref
|
||||
// store the structures python object into opt.
|
||||
if (!render_mode_parse_option(support, "structures", "O", &(opt)))
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
/**
|
||||
* Check if a sane option was passed.
|
||||
@@ -119,7 +116,7 @@ static int overlay_structure_start(void* data, RenderState* state, PyObject* sup
|
||||
opt = PySequence_Fast(opt, "expected a sequence");
|
||||
if (!opt) {
|
||||
PyErr_SetString(PyExc_TypeError, "'structures' must be a a sequence");
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
structures_size = PySequence_Fast_GET_SIZE(opt);
|
||||
@@ -128,7 +125,7 @@ static int overlay_structure_start(void* data, RenderState* state, PyObject* sup
|
||||
self->numcolors = structures_size;
|
||||
if (structures == NULL) {
|
||||
PyErr_SetString(PyExc_MemoryError, "failed to allocate memory");
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,7 +144,7 @@ static int overlay_structure_start(void* data, RenderState* state, PyObject* sup
|
||||
// Exception set automatically
|
||||
free(structures);
|
||||
self->structures = NULL;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Parse colorpy into a c-struct.
|
||||
@@ -158,7 +155,7 @@ static int overlay_structure_start(void* data, RenderState* state, PyObject* sup
|
||||
&structures[i].a)) {
|
||||
free(structures);
|
||||
self->structures = NULL;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Convert condspy to a fast sequence
|
||||
@@ -166,7 +163,7 @@ static int overlay_structure_start(void* data, RenderState* state, PyObject* sup
|
||||
if (condspy == NULL) {
|
||||
free(structures);
|
||||
self->structures = NULL;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// get the number of conditions.
|
||||
@@ -179,7 +176,7 @@ static int overlay_structure_start(void* data, RenderState* state, PyObject* sup
|
||||
PyErr_SetString(PyExc_MemoryError, "failed to allocate memory");
|
||||
free(structures);
|
||||
self->structures = NULL;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// iterate over all the conditions and read them.
|
||||
@@ -190,13 +187,13 @@ static int overlay_structure_start(void* data, RenderState* state, PyObject* sup
|
||||
&cond[n].rely,
|
||||
&cond[n].relz,
|
||||
&cond[n].block)) {
|
||||
int x = 0;
|
||||
int32_t x = 0;
|
||||
for (x = 0; x < structures_size; x++) {
|
||||
free(structures[x].conditions);
|
||||
}
|
||||
free(structures);
|
||||
self->structures = NULL;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,13 +203,13 @@ static int overlay_structure_start(void* data, RenderState* state, PyObject* sup
|
||||
/* setup custom color */
|
||||
self->parent.get_color = get_color;
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void overlay_structure_finish(void* data, RenderState* state) {
|
||||
/* first free all *our* stuff */
|
||||
RenderPrimitiveStructure* self = (RenderPrimitiveStructure*)data;
|
||||
int i = 0;
|
||||
int32_t i = 0;
|
||||
|
||||
if (self->structures) {
|
||||
// freeing the nested structure
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "../mc_id.h"
|
||||
|
||||
static void get_color(void* data, RenderState* state,
|
||||
unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a) {
|
||||
uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) {
|
||||
RenderPrimitiveOverlay* self = (RenderPrimitiveOverlay*)data;
|
||||
|
||||
*r = self->color->r;
|
||||
@@ -28,7 +28,7 @@ static void get_color(void* data, RenderState* state,
|
||||
*a = self->color->a;
|
||||
}
|
||||
|
||||
static int
|
||||
static int32_t
|
||||
overlay_start(void* data, RenderState* state, PyObject* support) {
|
||||
PyObject* opt = NULL;
|
||||
OverlayColor* color = NULL;
|
||||
@@ -41,7 +41,7 @@ overlay_start(void* data, RenderState* state, PyObject* support) {
|
||||
color = self->color = calloc(1, sizeof(OverlayColor));
|
||||
|
||||
if (color == NULL) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
self->default_color.r = 200;
|
||||
@@ -58,12 +58,12 @@ overlay_start(void* data, RenderState* state, PyObject* support) {
|
||||
if (render_mode_parse_option(support, "overlay_color", "O", &(opt))) {
|
||||
// If it is an object, check to see if it is None, if it is, use the default.
|
||||
if (opt && opt != Py_None) {
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -80,11 +80,11 @@ overlay_finish(void* data, RenderState* state) {
|
||||
|
||||
void overlay_draw(void* data, RenderState* state, PyObject* src, PyObject* mask, PyObject* mask_light) {
|
||||
RenderPrimitiveOverlay* self = (RenderPrimitiveOverlay*)data;
|
||||
unsigned char r, g, b, a;
|
||||
unsigned short top_block;
|
||||
uint8_t r, g, b, a;
|
||||
mc_block_t top_block;
|
||||
|
||||
// exactly analogous to edge-line code for these special blocks
|
||||
int increment = 0;
|
||||
int32_t increment = 0;
|
||||
if (state->block == block_stone_slab) // half-step
|
||||
increment = 6;
|
||||
else if (state->block == block_snow_layer) // snow
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "../overviewer.h"
|
||||
|
||||
typedef struct {
|
||||
unsigned char r, g, b, a;
|
||||
uint8_t r, g, b, a;
|
||||
} OverlayColor;
|
||||
|
||||
typedef struct {
|
||||
@@ -33,7 +33,7 @@ typedef struct {
|
||||
overlay alpha and color
|
||||
last four vars are r, g, b, a out */
|
||||
void (*get_color)(void*, RenderState*,
|
||||
unsigned char*, unsigned char*, unsigned char*, unsigned char*);
|
||||
uint8_t*, uint8_t*, uint8_t*, uint8_t*);
|
||||
} RenderPrimitiveOverlay;
|
||||
extern RenderPrimitiveInterface primitive_overlay;
|
||||
|
||||
|
||||
@@ -29,29 +29,29 @@ typedef struct {
|
||||
/* structure representing one corner of a face (see below) */
|
||||
struct SmoothLightingCorner {
|
||||
/* where this corner shows up on each block texture */
|
||||
int imgx, imgy;
|
||||
int32_t imgx, imgy;
|
||||
|
||||
/* the two block offsets that (together) determine the 4 blocks to use */
|
||||
int dx1, dy1, dz1;
|
||||
int dx2, dy2, dz2;
|
||||
int32_t dx1, dy1, dz1;
|
||||
int32_t dx2, dy2, dz2;
|
||||
};
|
||||
|
||||
/* structure for rule table handling lighting */
|
||||
struct SmoothLightingFace {
|
||||
/* offset from current coordinate to the block this face points towards
|
||||
used for occlusion calculations, and as a base for later */
|
||||
int dx, dy, dz;
|
||||
int32_t dx, dy, dz;
|
||||
|
||||
/* the points that form the corners of this face */
|
||||
struct SmoothLightingCorner corners[4];
|
||||
|
||||
/* pairs of (x,y) in order, as touch-up points, or NULL for none */
|
||||
int* touch_up_points;
|
||||
unsigned int num_touch_up_points;
|
||||
uint32_t num_touch_up_points;
|
||||
};
|
||||
|
||||
/* top face touchups, pulled from textures.py (_build_block) */
|
||||
static int top_touchups[] = {1, 5, 3, 4, 5, 3, 7, 2, 9, 1, 11, 0};
|
||||
static int32_t top_touchups[] = {1, 5, 3, 4, 5, 3, 7, 2, 9, 1, 11, 0};
|
||||
|
||||
/* the lighting face rule list! */
|
||||
static struct SmoothLightingFace lighting_rules[] = {
|
||||
@@ -110,17 +110,17 @@ enum {
|
||||
|
||||
static void
|
||||
do_shading_with_rule(RenderPrimitiveSmoothLighting* self, RenderState* state, struct SmoothLightingFace face) {
|
||||
int i;
|
||||
int32_t i;
|
||||
RenderPrimitiveLighting* lighting = (RenderPrimitiveLighting*)self;
|
||||
int x = state->imgx, y = state->imgy;
|
||||
int32_t x = state->imgx, y = state->imgy;
|
||||
struct SmoothLightingCorner* pts = face.corners;
|
||||
float comp_shade_strength = 1.0 - lighting->strength;
|
||||
unsigned char pts_r[4] = {0, 0, 0, 0};
|
||||
unsigned char pts_g[4] = {0, 0, 0, 0};
|
||||
unsigned char pts_b[4] = {0, 0, 0, 0};
|
||||
int cx = state->x + face.dx;
|
||||
int cy = state->y + face.dy;
|
||||
int cz = state->z + face.dz;
|
||||
uint8_t pts_r[4] = {0, 0, 0, 0};
|
||||
uint8_t pts_g[4] = {0, 0, 0, 0};
|
||||
uint8_t pts_b[4] = {0, 0, 0, 0};
|
||||
int32_t cx = state->x + face.dx;
|
||||
int32_t cy = state->y + face.dy;
|
||||
int32_t cz = state->z + face.dz;
|
||||
|
||||
/* first, check for occlusion if the block is in the local chunk */
|
||||
if (lighting_is_face_occluded(state, 0, cx, cy, cz))
|
||||
@@ -128,8 +128,8 @@ do_shading_with_rule(RenderPrimitiveSmoothLighting* self, RenderState* state, st
|
||||
|
||||
/* calculate the lighting colors for each point */
|
||||
for (i = 0; i < 4; i++) {
|
||||
unsigned char r, g, b;
|
||||
unsigned int rgather = 0, ggather = 0, bgather = 0;
|
||||
uint8_t r, g, b;
|
||||
uint32_t rgather = 0, ggather = 0, bgather = 0;
|
||||
|
||||
get_lighting_color(lighting, state, cx, cy, cz,
|
||||
&r, &g, &b);
|
||||
@@ -181,13 +181,13 @@ do_shading_with_rule(RenderPrimitiveSmoothLighting* self, RenderState* state, st
|
||||
x, y, NULL, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
static bool
|
||||
smooth_lighting_start(void* data, RenderState* state, PyObject* support) {
|
||||
/* first, chain up */
|
||||
int ret = primitive_lighting.start(data, state, support);
|
||||
if (ret != 0)
|
||||
bool ret = primitive_lighting.start(data, state, support);
|
||||
if (ret != false)
|
||||
return ret;
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -198,9 +198,9 @@ smooth_lighting_finish(void* data, RenderState* state) {
|
||||
|
||||
static void
|
||||
smooth_lighting_draw(void* data, RenderState* state, PyObject* src, PyObject* mask, PyObject* mask_light) {
|
||||
int light_top = 1;
|
||||
int light_left = 1;
|
||||
int light_right = 1;
|
||||
bool light_top = true;
|
||||
bool light_left = true;
|
||||
bool light_right = true;
|
||||
RenderPrimitiveSmoothLighting* self = (RenderPrimitiveSmoothLighting*)data;
|
||||
|
||||
/* special case for leaves, water 8, water 9, ice 79
|
||||
@@ -216,11 +216,11 @@ smooth_lighting_draw(void* data, RenderState* state, PyObject* src, PyObject* ma
|
||||
/* special code for water */
|
||||
if (state->block == block_water) {
|
||||
if (!(state->block_pdata & (1 << 4)))
|
||||
light_top = 0;
|
||||
light_top = false;
|
||||
if (!(state->block_pdata & (1 << 1)))
|
||||
light_left = 0;
|
||||
light_left = false;
|
||||
if (!(state->block_pdata & (1 << 2)))
|
||||
light_right = 0;
|
||||
light_right = false;
|
||||
}
|
||||
|
||||
if (light_top)
|
||||
|
||||
Reference in New Issue
Block a user