Implement standard C boolean type
This commit is contained in:
@@ -121,14 +121,14 @@ static inline void load_chunk_section(ChunkData* dest, int32_t i, PyObject* sect
|
||||
* if required is true, failure to load the chunk will raise a python
|
||||
* exception and return true.
|
||||
*/
|
||||
int32_t load_chunk(RenderState* state, int32_t x, int32_t z, uint8_t required) {
|
||||
bool load_chunk(RenderState* state, int32_t x, int32_t z, uint8_t required) {
|
||||
ChunkData* dest = &(state->chunks[1 + x][1 + z]);
|
||||
int32_t i;
|
||||
PyObject* chunk = NULL;
|
||||
PyObject* sections = NULL;
|
||||
|
||||
if (dest->loaded)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
/* set up reasonable defaults */
|
||||
dest->biomes = NULL;
|
||||
@@ -150,7 +150,7 @@ int32_t load_chunk(RenderState* state, int32_t x, int32_t z, uint8_t required) {
|
||||
if (!required) {
|
||||
PyErr_Clear();
|
||||
}
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
sections = PyDict_GetItemString(chunk, "Sections");
|
||||
@@ -163,7 +163,7 @@ int32_t load_chunk(RenderState* state, int32_t x, int32_t z, uint8_t required) {
|
||||
if (!required) {
|
||||
PyErr_Clear();
|
||||
}
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
dest->biomes = (PyArrayObject*)PyDict_GetItemString(chunk, "Biomes");
|
||||
@@ -184,7 +184,7 @@ int32_t load_chunk(RenderState* state, int32_t x, int32_t z, uint8_t required) {
|
||||
Py_DECREF(sections);
|
||||
Py_DECREF(chunk);
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* helper to unload all loaded chunks */
|
||||
|
||||
@@ -121,7 +121,7 @@ typedef struct {
|
||||
} RenderState;
|
||||
PyObject* init_chunk_render(void);
|
||||
/* returns true on error, x,z relative */
|
||||
int32_t load_chunk(RenderState* state, int32_t x, int32_t z, uint8_t required);
|
||||
bool load_chunk(RenderState* state, int32_t x, int32_t z, uint8_t required);
|
||||
PyObject* chunk_render(PyObject* self, PyObject* args);
|
||||
typedef enum {
|
||||
KNOWN,
|
||||
@@ -141,8 +141,8 @@ block_has_property(mc_block_t b, BlockProperty prop) {
|
||||
if (b >= max_blockid || !(block_properties[b] & (1 << KNOWN))) {
|
||||
/* block is unknown, return defaults */
|
||||
if (prop == TRANSPARENT)
|
||||
return 1;
|
||||
return 0;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return block_properties[b] & (1 << prop);
|
||||
|
||||
@@ -28,12 +28,12 @@ typedef struct {
|
||||
PyObject* grass_texture;
|
||||
} PrimitiveBase;
|
||||
|
||||
static int32_t
|
||||
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,7 +56,7 @@ base_finish(void* data, RenderState* state) {
|
||||
Py_DECREF(self->grass_texture);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
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) &&
|
||||
@@ -65,10 +65,10 @@ base_occluded(void* data, RenderState* state, int32_t x, int32_t y, int32_t 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
|
||||
@@ -110,7 +110,7 @@ base_draw(void* data, RenderState* state, PyObject* src, PyObject* mask, PyObjec
|
||||
PyObject* facemask = mask;
|
||||
uint8_t r = 255, g = 255, b = 255;
|
||||
PyObject* color_table = NULL;
|
||||
uint8_t flip_xy = 0;
|
||||
bool flip_xy = false;
|
||||
|
||||
if (state->block == block_grass) {
|
||||
/* grass needs a special facemask */
|
||||
@@ -122,11 +122,8 @@ 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) {
|
||||
|
||||
@@ -22,23 +22,22 @@ typedef struct {
|
||||
int32_t only_lit;
|
||||
} RenderPrimitiveCave;
|
||||
|
||||
static inline int32_t
|
||||
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 int32_t
|
||||
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 */
|
||||
@@ -46,21 +45,21 @@ cave_occluded(void* data, RenderState* state, int32_t x, int32_t y, int32_t z) {
|
||||
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 int32_t
|
||||
static bool
|
||||
cave_hidden(void* data, RenderState* state, int32_t x, int32_t y, int32_t z) {
|
||||
RenderPrimitiveCave* self;
|
||||
int32_t dy = 0;
|
||||
@@ -68,11 +67,11 @@ cave_hidden(void* data, RenderState* state, int32_t x, int32_t y, int32_t z) {
|
||||
|
||||
/* 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, int32_t x, int32_t y, int32_t 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, int32_t x, int32_t y, int32_t z) {
|
||||
return cave_occluded(data, state, x, y, z);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
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,7 +17,7 @@
|
||||
|
||||
#include "../overviewer.h"
|
||||
|
||||
static int32_t
|
||||
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) &&
|
||||
@@ -26,10 +26,10 @@ clear_base_occluded(void* data, RenderState* state, int32_t x, int32_t y, int32_
|
||||
!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 int32_t
|
||||
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
|
||||
|
||||
@@ -22,26 +22,26 @@ typedef struct {
|
||||
uint32_t max;
|
||||
} PrimitiveDepth;
|
||||
|
||||
static int32_t
|
||||
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 int32_t
|
||||
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 int32_t
|
||||
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
|
||||
|
||||
@@ -21,29 +21,29 @@ typedef struct {
|
||||
uint32_t mode; /* 0 = exposed only, 1 = unexposed only */
|
||||
} PrimitiveExposed;
|
||||
|
||||
static int32_t
|
||||
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 int32_t
|
||||
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.
|
||||
*/
|
||||
int32_t validMinusX = 1;
|
||||
int32_t validPlusX = 1;
|
||||
int32_t validMinusY = 1;
|
||||
int32_t validPlusY = 1;
|
||||
int32_t validMinusZ = 1;
|
||||
int32_t 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, int32_t x, int32_t y, int32_t 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 */
|
||||
|
||||
@@ -23,17 +23,17 @@ typedef struct {
|
||||
uint32_t sealevel;
|
||||
} PrimitiveHeightFading;
|
||||
|
||||
static int32_t
|
||||
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
|
||||
|
||||
@@ -28,26 +28,26 @@ typedef struct {
|
||||
struct HideRule* rules;
|
||||
} RenderPrimitiveHide;
|
||||
|
||||
static int32_t
|
||||
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++) {
|
||||
@@ -64,12 +64,12 @@ hide_start(void* data, RenderState* state, PyObject* support) {
|
||||
/* format not recognized */
|
||||
free(self->rules);
|
||||
self->rules = NULL;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -81,14 +81,14 @@ hide_finish(void* data, RenderState* state) {
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t
|
||||
static bool
|
||||
hide_hidden(void* data, RenderState* state, int32_t x, int32_t y, int32_t z) {
|
||||
RenderPrimitiveHide* self = (RenderPrimitiveHide*)data;
|
||||
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++) {
|
||||
@@ -96,15 +96,15 @@ hide_hidden(void* data, RenderState* state, int32_t x, int32_t y, int32_t z) {
|
||||
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 = {
|
||||
|
||||
@@ -99,7 +99,7 @@ calculate_light_color_fancy_night(void* data,
|
||||
|
||||
uint8_t
|
||||
estimate_blocklevel(RenderPrimitiveLighting* self, RenderState* state,
|
||||
int32_t x, int32_t y, int32_t z, int* authoratative) {
|
||||
int32_t x, int32_t y, int32_t z, bool* authoratative) {
|
||||
|
||||
/* placeholders for later data arrays, coordinates */
|
||||
mc_block_t block;
|
||||
@@ -108,12 +108,12 @@ estimate_blocklevel(RenderPrimitiveLighting* self, RenderState* state,
|
||||
|
||||
/* defaults to "guess" until told otherwise */
|
||||
if (authoratative)
|
||||
*authoratative = 0;
|
||||
*authoratative = false;
|
||||
|
||||
block = get_data(state, BLOCKS, x, y, z);
|
||||
|
||||
if (authoratative == NULL) {
|
||||
int32_t auth;
|
||||
bool auth;
|
||||
|
||||
/* iterate through all surrounding blocks to take an average */
|
||||
int32_t dx, dy, dz, local_block;
|
||||
@@ -196,15 +196,15 @@ get_lighting_color(RenderPrimitiveLighting* self, RenderState* state,
|
||||
}
|
||||
|
||||
/* does per-face occlusion checking for do_shading_with_mask */
|
||||
inline int32_t
|
||||
lighting_is_face_occluded(RenderState* state, int32_t skip_sides, int32_t x, int32_t y, int32_t 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) {
|
||||
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) {
|
||||
mc_block_t block = get_data(state, BLOCKS, x, y, z);
|
||||
@@ -213,10 +213,10 @@ lighting_is_face_occluded(RenderState* state, int32_t skip_sides, int32_t x, int
|
||||
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
|
||||
@@ -247,14 +247,14 @@ lighting_start(void* data, RenderState* state, PyObject* support) {
|
||||
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
|
||||
|
||||
@@ -31,7 +31,7 @@ typedef struct {
|
||||
/* 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
|
||||
*/
|
||||
int32_t skip_sides;
|
||||
bool skip_sides;
|
||||
|
||||
float strength;
|
||||
int32_t color;
|
||||
@@ -40,7 +40,7 @@ typedef struct {
|
||||
|
||||
/* exposed so that smooth-lighting can use them */
|
||||
extern RenderPrimitiveInterface primitive_lighting;
|
||||
int32_t lighting_is_face_occluded(RenderState* state, int32_t skip_sides, int32_t x, int32_t y, int32_t 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,
|
||||
int32_t x, int32_t y, int32_t z,
|
||||
uint8_t* r, uint8_t* g, uint8_t* b);
|
||||
|
||||
@@ -23,31 +23,31 @@
|
||||
static void
|
||||
walk_chunk(RenderState* state, RenderPrimitiveNether* data) {
|
||||
int32_t x, y, z;
|
||||
int32_t id;
|
||||
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 int32_t
|
||||
static bool
|
||||
nether_hidden(void* data, RenderState* state, int32_t x, int32_t y, int32_t z) {
|
||||
RenderPrimitiveNether* self;
|
||||
int32_t real_y;
|
||||
|
||||
@@ -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 {
|
||||
int32_t walked_chunk;
|
||||
bool walked_chunk;
|
||||
|
||||
int32_t remove_block[WIDTH + 2][HEIGHT][DEPTH + 2];
|
||||
bool remove_block[WIDTH + 2][HEIGHT][DEPTH + 2];
|
||||
|
||||
} RenderPrimitiveNether;
|
||||
|
||||
@@ -17,33 +17,33 @@
|
||||
|
||||
#include "../overviewer.h"
|
||||
|
||||
static int32_t
|
||||
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'
|
||||
*/
|
||||
uint8_t 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,12 +17,12 @@
|
||||
|
||||
#include "../overviewer.h"
|
||||
|
||||
static int32_t
|
||||
static bool
|
||||
no_fluids_start(void* data, RenderState* state, PyObject* support) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int32_t
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -110,15 +110,15 @@ static void get_color(void* data, RenderState* state,
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t
|
||||
static bool
|
||||
overlay_biomes_start(void* data, RenderState* state, PyObject* support) {
|
||||
PyObject* opt;
|
||||
RenderPrimitiveBiomes* self;
|
||||
uint8_t alpha_tmp = 0;
|
||||
|
||||
/* first, chain up */
|
||||
int32_t 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,13 +134,13 @@ 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++) {
|
||||
@@ -151,7 +151,7 @@ overlay_biomes_start(void* data, RenderState* state, PyObject* support) {
|
||||
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,7 +26,7 @@ typedef struct {
|
||||
} RenderPrimitiveMineral;
|
||||
|
||||
struct MineralColor {
|
||||
uint8_t blockid;
|
||||
mc_block_t block;
|
||||
uint8_t r, g, b;
|
||||
};
|
||||
|
||||
@@ -59,10 +59,10 @@ static void get_color(void* data, RenderState* state,
|
||||
y_max = state->y + 1;
|
||||
for (y = state->chunky * -16; y <= y_max; y++) {
|
||||
int32_t i, tmp;
|
||||
mc_block_t blockid = get_data(state, BLOCKS, x, y, z);
|
||||
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 int32_t
|
||||
static bool
|
||||
overlay_mineral_start(void* data, RenderState* state, PyObject* support) {
|
||||
PyObject* opt;
|
||||
RenderPrimitiveMineral* self;
|
||||
|
||||
/* first, chain up */
|
||||
int32_t 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,43 +30,38 @@ 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 int32_t random_next(long long* seed, int32_t 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 int32_t random_next_int(long long* seed, int32_t n) {
|
||||
int32_t 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 int32_t is_slime(long long map_seed, int32_t chunkx, int32_t 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);
|
||||
}
|
||||
@@ -89,14 +84,14 @@ static void get_color(void* data, RenderState* state,
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t
|
||||
static bool
|
||||
overlay_slime_start(void* data, RenderState* state, PyObject* support) {
|
||||
RenderPrimitiveSlime* self;
|
||||
PyObject* pyseed;
|
||||
|
||||
/* first, chain up */
|
||||
int32_t 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
|
||||
|
||||
@@ -55,13 +55,13 @@ static void get_color(void* data, RenderState* state,
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t
|
||||
static bool
|
||||
overlay_spawn_start(void* data, RenderState* state, PyObject* support) {
|
||||
RenderPrimitiveSpawn* self;
|
||||
|
||||
/* first, chain up */
|
||||
int32_t 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
|
||||
|
||||
@@ -83,7 +83,7 @@ static void get_color(void* data,
|
||||
return;
|
||||
}
|
||||
|
||||
static int32_t 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.
|
||||
@@ -92,8 +92,8 @@ static int32_t overlay_structure_start(void* data, RenderState* state, PyObject*
|
||||
RenderPrimitiveStructure* self;
|
||||
|
||||
/* first, chain up */
|
||||
int32_t 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 */
|
||||
@@ -102,7 +102,7 @@ static int32_t overlay_structure_start(void* data, RenderState* state, PyObject*
|
||||
// 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.
|
||||
@@ -116,7 +116,7 @@ static int32_t overlay_structure_start(void* data, RenderState* state, PyObject*
|
||||
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);
|
||||
@@ -125,7 +125,7 @@ static int32_t overlay_structure_start(void* data, RenderState* state, PyObject*
|
||||
self->numcolors = structures_size;
|
||||
if (structures == NULL) {
|
||||
PyErr_SetString(PyExc_MemoryError, "failed to allocate memory");
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +144,7 @@ static int32_t overlay_structure_start(void* data, RenderState* state, PyObject*
|
||||
// Exception set automatically
|
||||
free(structures);
|
||||
self->structures = NULL;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Parse colorpy into a c-struct.
|
||||
@@ -155,7 +155,7 @@ static int32_t overlay_structure_start(void* data, RenderState* state, PyObject*
|
||||
&structures[i].a)) {
|
||||
free(structures);
|
||||
self->structures = NULL;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Convert condspy to a fast sequence
|
||||
@@ -163,7 +163,7 @@ static int32_t overlay_structure_start(void* data, RenderState* state, PyObject*
|
||||
if (condspy == NULL) {
|
||||
free(structures);
|
||||
self->structures = NULL;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// get the number of conditions.
|
||||
@@ -176,7 +176,7 @@ static int32_t overlay_structure_start(void* data, RenderState* state, PyObject*
|
||||
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.
|
||||
@@ -193,7 +193,7 @@ static int32_t overlay_structure_start(void* data, RenderState* state, PyObject*
|
||||
}
|
||||
free(structures);
|
||||
self->structures = NULL;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,7 +203,7 @@ static int32_t overlay_structure_start(void* data, RenderState* state, PyObject*
|
||||
/* setup custom color */
|
||||
self->parent.get_color = get_color;
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void overlay_structure_finish(void* data, RenderState* state) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -181,13 +181,13 @@ do_shading_with_rule(RenderPrimitiveSmoothLighting* self, RenderState* state, st
|
||||
x, y, NULL, 0);
|
||||
}
|
||||
|
||||
static int32_t
|
||||
static bool
|
||||
smooth_lighting_start(void* data, RenderState* state, PyObject* support) {
|
||||
/* first, chain up */
|
||||
int32_t 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) {
|
||||
int32_t light_top = 1;
|
||||
int32_t light_left = 1;
|
||||
int32_t 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)
|
||||
|
||||
@@ -129,9 +129,9 @@ void render_mode_destroy(RenderMode* self) {
|
||||
free(self);
|
||||
}
|
||||
|
||||
int32_t render_mode_occluded(RenderMode* self, int32_t x, int32_t y, int32_t z) {
|
||||
bool render_mode_occluded(RenderMode* self, int32_t x, int32_t y, int32_t z) {
|
||||
uint32_t i;
|
||||
int32_t occluded = 0;
|
||||
bool occluded = false;
|
||||
for (i = 0; i < self->num_primitives; i++) {
|
||||
RenderPrimitive* prim = self->primitives[i];
|
||||
if (prim->iface->occluded) {
|
||||
@@ -144,9 +144,9 @@ int32_t render_mode_occluded(RenderMode* self, int32_t x, int32_t y, int32_t z)
|
||||
return occluded;
|
||||
}
|
||||
|
||||
int32_t render_mode_hidden(RenderMode* self, int32_t x, int32_t y, int32_t z) {
|
||||
bool render_mode_hidden(RenderMode* self, int32_t x, int32_t y, int32_t z) {
|
||||
uint32_t i;
|
||||
int32_t hidden = 0;
|
||||
bool hidden = false;
|
||||
for (i = 0; i < self->num_primitives; i++) {
|
||||
RenderPrimitive* prim = self->primitives[i];
|
||||
if (prim->iface->hidden) {
|
||||
@@ -170,22 +170,22 @@ void render_mode_draw(RenderMode* self, PyObject* img, PyObject* mask, PyObject*
|
||||
}
|
||||
|
||||
/* options parse helper */
|
||||
int32_t render_mode_parse_option(PyObject* support, const char* name, const char* format, ...) {
|
||||
bool render_mode_parse_option(PyObject* support, const char* name, const char* format, ...) {
|
||||
va_list ap;
|
||||
PyObject *item, *dict;
|
||||
int32_t ret;
|
||||
bool ret;
|
||||
|
||||
if (support == NULL || name == NULL)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
dict = PyObject_GetAttrString(support, "option_values");
|
||||
if (!dict)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
item = PyDict_GetItemString(dict, name);
|
||||
if (item == NULL) {
|
||||
Py_DECREF(dict);
|
||||
return 0;
|
||||
return false;
|
||||
};
|
||||
|
||||
/* make sure the item we're parsing is a tuple
|
||||
|
||||
@@ -51,14 +51,14 @@ typedef struct {
|
||||
/* the size of the local storage for this rendermode */
|
||||
uint32_t data_size;
|
||||
|
||||
/* may return non-zero on error, last arg is the python support object */
|
||||
int32_t (*start)(void*, RenderState*, PyObject*);
|
||||
/* may return true on error, last arg is the python support object */
|
||||
bool (*start)(void*, RenderState*, PyObject*);
|
||||
void (*finish)(void*, RenderState*);
|
||||
/* returns non-zero to skip rendering this block because it's not visible */
|
||||
int32_t (*occluded)(void*, RenderState*, int, int, int);
|
||||
/* returns non-zero to skip rendering this block because the user doesn't
|
||||
/* returns true to skip rendering this block because it's not visible */
|
||||
bool (*occluded)(void*, RenderState*, int, int, int);
|
||||
/* returns true to skip rendering this block because the user doesn't
|
||||
* want it visible */
|
||||
int32_t (*hidden)(void*, RenderState*, int, int, int);
|
||||
bool (*hidden)(void*, RenderState*, int, int, int);
|
||||
/* last two arguments are img and mask, from texture lookup */
|
||||
void (*draw)(void*, RenderState*, PyObject*, PyObject*, PyObject*);
|
||||
} RenderPrimitiveInterface;
|
||||
@@ -94,12 +94,12 @@ struct _RenderMode {
|
||||
/* functions for creating / using rendermodes */
|
||||
RenderMode* render_mode_create(PyObject* mode, RenderState* state);
|
||||
void render_mode_destroy(RenderMode* self);
|
||||
int32_t render_mode_occluded(RenderMode* self, int32_t x, int32_t y, int32_t z);
|
||||
int32_t render_mode_hidden(RenderMode* self, int32_t x, int32_t y, int32_t z);
|
||||
bool render_mode_occluded(RenderMode* self, int32_t x, int32_t y, int32_t z);
|
||||
bool render_mode_hidden(RenderMode* self, int32_t x, int32_t y, int32_t z);
|
||||
void render_mode_draw(RenderMode* self, PyObject* img, PyObject* mask, PyObject* mask_light);
|
||||
|
||||
/* helper function for reading in rendermode options
|
||||
works like PyArg_ParseTuple on a support object */
|
||||
int32_t render_mode_parse_option(PyObject* support, const char* name, const char* format, ...);
|
||||
bool render_mode_parse_option(PyObject* support, const char* name, const char* format, ...);
|
||||
|
||||
#endif /* __RENDERMODES_H_INCLUDED__ */
|
||||
|
||||
Reference in New Issue
Block a user