mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-07-05 15:19:07 +02:00
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:
parent
12b5cb4f4e
commit
de04cce993
3 changed files with 11 additions and 8 deletions
|
@ -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};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue