0

Convert case switch to block_class_is_subset

This commit is contained in:
Wunkolo
2019-03-17 17:57:18 -07:00
parent ee9a3411ba
commit 5ff6a6400e
3 changed files with 68 additions and 69 deletions

View File

@@ -22,7 +22,7 @@
#include <immintrin.h>
#endif
bool block_class_is_subset(
extern inline bool block_class_is_subset(
mc_block_t block,
const mc_block_t block_class[],
size_t block_class_len

View File

@@ -1,50 +1,50 @@
/*
* This file is part of the Minecraft Overviewer.
*
* Minecraft Overviewer is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Minecraft Overviewer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __BLOCK_CLASS_H_INCLUDED__
#define __BLOCK_CLASS_H_INCLUDED__
#include <stdbool.h>
#include <stddef.h>
#include "mc_id.h"
bool block_class_is_subset(
mc_block_t block,
const mc_block_t block_class[],
size_t block_class_len
);
extern const mc_block_t block_class_stair[];
extern const size_t block_class_stair_len;
extern const mc_block_t block_class_door[];
extern const size_t block_class_door_len;
extern const mc_block_t block_class_fence[];
extern const size_t block_class_fence_len;
extern const mc_block_t block_class_fence_gate[];
extern const size_t block_class_fence_gate_len;
extern const mc_block_t block_class_ancil[];
extern const size_t block_class_ancil_len;
extern const mc_block_t block_class_alt_height[];
extern const size_t block_class_alt_height_len;
/*
* This file is part of the Minecraft Overviewer.
*
* Minecraft Overviewer is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Minecraft Overviewer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __BLOCK_CLASS_H_INCLUDED__
#define __BLOCK_CLASS_H_INCLUDED__
#include <stdbool.h>
#include <stddef.h>
#include "mc_id.h"
bool block_class_is_subset(
mc_block_t block,
const mc_block_t block_class[],
size_t block_class_len
);
extern const mc_block_t block_class_stair[];
extern const size_t block_class_stair_len;
extern const mc_block_t block_class_door[];
extern const size_t block_class_door_len;
extern const mc_block_t block_class_fence[];
extern const size_t block_class_fence_len;
extern const mc_block_t block_class_fence_gate[];
extern const size_t block_class_fence_gate_len;
extern const mc_block_t block_class_ancil[];
extern const size_t block_class_ancil_len;
extern const mc_block_t block_class_alt_height[];
extern const size_t block_class_alt_height_len;
#endif

View File

@@ -125,23 +125,25 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
/* grass needs a special facemask */
facemask = self->grass_texture;
}
switch (state->block) {
case block_grass:
case block_tallgrass:
case block_pumpkin_stem:
case block_melon_stem:
case block_vine:
case block_waterlily:
case block_double_plant:
if(block_class_is_subset(state->block,(mc_block_t[]){
block_grass,
block_tallgrass,
block_pumpkin_stem,
block_melon_stem,
block_vine,
block_waterlily,
block_double_plant
},7)) {
color_table = self->grasscolor;
break;
case block_flowing_water:
case block_water:
}
else if(block_class_is_subset(state->block,(mc_block_t[]){
block_flowing_water,block_water
},2)) {
color_table = self->watercolor;
break;
case block_leaves:
case block_leaves2:
}
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)
{
@@ -149,10 +151,7 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
birch foliage color is flipped XY-ways */
flip_xy = 1;
}
break;
default:
break;
};
}
if (color_table) {
unsigned char biome;