World/Block: return colors as struct instead of uint32_t

Gets rid of a useless byte switch, and removes the arpa/inet.h include,
which is not available on Windows.
This commit is contained in:
Matthias Schiffer 2018-07-26 23:14:03 +02:00
parent 12b5cb4f4e
commit de04cce993
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C
3 changed files with 11 additions and 8 deletions

View file

@ -31,9 +31,9 @@
namespace MinedMap {
namespace World {
uint32_t Block::getColor() const {
Block::Color Block::getColor() const {
if (!type || !type->opaque)
return 0;
return Color {};
float r = type->color.r;
float g = type->color.g;
@ -63,7 +63,7 @@ uint32_t Block::getColor() const {
if (g > 255) g = 255;
if (b > 255) b = 255;
return ((unsigned)r << 24) | ((unsigned)g << 16) | ((unsigned)b << 8) | 0xff;
return Color {uint8_t(r), uint8_t(g), uint8_t(b), 0xff};
}
}

View file

@ -34,13 +34,17 @@ namespace MinedMap {
namespace World {
struct Block {
struct Color {
uint8_t r, g, b, a;
};
const Resource::BlockType *type;
unsigned height;
uint8_t blockLight;
uint8_t biome;
uint32_t getColor() const;
Color getColor() const;
operator bool() const {
return type;