fogleman/Craft

How to increase block ID range from 8-bit to 16-bit?

fei2020 opened this issue · 0 comments

I find many places in the code w is regarded as a signed char. Such as light_fill(), map_set and etc.
MapEntry.w is char:

typedef union {
    unsigned int value;
    struct {
        unsigned char x;
        unsigned char y;
        unsigned char z;
	char w;
    } e;
} MapEntry;

It seems a lot of code and algorithms need to be modified to increase block ID range from 8-bit to 16-bit. If I modify MapEntry::e::w be short, main.c.light_fill(...) will be leaded to dead iterator. I just simply add a violent cast in light_fill, it seems works. But I know little about the algorithm of light_fill. I worry it will work wrong in some cases.

void light_fill(
    char *opaque, char *light,
    int x, int y, int z, int w, int force)
{
	w = (char)w;  //add a violent cast simply
	if (x + w < XZ_LO || z + w < XZ_LO) {
        return;
    }
......

Related:
#116
satoshinm/NetCraft#55