diff options
Diffstat (limited to 'src/mapnode.h')
-rw-r--r-- | src/mapnode.h | 80 |
1 files changed, 30 insertions, 50 deletions
diff --git a/src/mapnode.h b/src/mapnode.h index 32ac1b4f6..eaf37b01f 100644 --- a/src/mapnode.h +++ b/src/mapnode.h @@ -79,7 +79,8 @@ enum LightBank /* Simple rotation enum. */ -enum Rotation { +enum Rotation +{ ROTATE_0, ROTATE_90, ROTATE_180, @@ -98,22 +99,20 @@ enum Rotation { /* maximum amount of liquid in a block */ #define LIQUID_LEVEL_MAX LIQUID_LEVEL_MASK -#define LIQUID_LEVEL_SOURCE (LIQUID_LEVEL_MAX+1) +#define LIQUID_LEVEL_SOURCE (LIQUID_LEVEL_MAX + 1) -#define LIQUID_INFINITY_MASK 0x80 //0b10000000 +#define LIQUID_INFINITY_MASK 0x80 // 0b10000000 // mask for leveled nodebox param2 #define LEVELED_MASK 0x7F #define LEVELED_MAX LEVELED_MASK - struct ContentFeatures; /* This is the stuff what the whole world consists of. */ - struct MapNode { /* @@ -139,44 +138,24 @@ struct MapNode MapNode() = default; - MapNode(content_t content, u8 a_param1=0, u8 a_param2=0) noexcept - : param0(content), - param1(a_param1), - param2(a_param2) - { } + MapNode(content_t content, u8 a_param1 = 0, u8 a_param2 = 0) noexcept : + param0(content), param1(a_param1), param2(a_param2) + { + } bool operator==(const MapNode &other) const noexcept { - return (param0 == other.param0 - && param1 == other.param1 - && param2 == other.param2); + return (param0 == other.param0 && param1 == other.param1 && + param2 == other.param2); } // To be used everywhere - content_t getContent() const noexcept - { - return param0; - } - void setContent(content_t c) noexcept - { - param0 = c; - } - u8 getParam1() const noexcept - { - return param1; - } - void setParam1(u8 p) noexcept - { - param1 = p; - } - u8 getParam2() const noexcept - { - return param2; - } - void setParam2(u8 p) noexcept - { - param2 = p; - } + content_t getContent() const noexcept { return param0; } + void setContent(content_t c) noexcept { param0 = c; } + u8 getParam1() const noexcept { return param1; } + void setParam1(u8 p) noexcept { param1 = p; } + u8 getParam2() const noexcept { return param2; } + void setParam2(u8 p) noexcept { param2 = p; } /*! * Returns the color of the node. @@ -224,7 +203,7 @@ struct MapNode u8 getLightNoChecks(LightBank bank, const ContentFeatures *f) const noexcept; bool getLightBanks(u8 &lightday, u8 &lightnight, - const NodeDefManager *nodemgr) const; + const NodeDefManager *nodemgr) const; // 0 <= daylight_factor <= 1000 // 0 <= return value <= LIGHT_SUN @@ -236,7 +215,8 @@ struct MapNode return blend_light(daylight_factor, lightday, lightnight); } - u8 getFaceDir(const NodeDefManager *nodemgr, bool allow_wallmounted = false) const; + u8 getFaceDir(const NodeDefManager *nodemgr, + bool allow_wallmounted = false) const; u8 getWallMounted(const NodeDefManager *nodemgr) const; v3s16 getWallMountedDir(const NodeDefManager *nodemgr) const; @@ -253,19 +233,19 @@ struct MapNode Gets list of node boxes (used for rendering (NDT_NODEBOX)) */ void getNodeBoxes(const NodeDefManager *nodemgr, std::vector<aabb3f> *boxes, - u8 neighbors = 0) const; + u8 neighbors = 0) const; /* Gets list of selection boxes */ - void getSelectionBoxes(const NodeDefManager *nodemg, - std::vector<aabb3f> *boxes, u8 neighbors = 0) const; + void getSelectionBoxes(const NodeDefManager *nodemg, std::vector<aabb3f> *boxes, + u8 neighbors = 0) const; /* Gets list of collision boxes */ - void getCollisionBoxes(const NodeDefManager *nodemgr, - std::vector<aabb3f> *boxes, u8 neighbors = 0) const; + void getCollisionBoxes(const NodeDefManager *nodemgr, std::vector<aabb3f> *boxes, + u8 neighbors = 0) const; /* Liquid/leveled helpers @@ -290,12 +270,12 @@ struct MapNode // content_width = the number of bytes of content per node // params_width = the number of bytes of params per node // compressed = true to zlib-compress output - static void serializeBulk(std::ostream &os, int version, - const MapNode *nodes, u32 nodecount, - u8 content_width, u8 params_width, bool compressed); - static void deSerializeBulk(std::istream &is, int version, - MapNode *nodes, u32 nodecount, - u8 content_width, u8 params_width, bool compressed); + static void serializeBulk(std::ostream &os, int version, const MapNode *nodes, + u32 nodecount, u8 content_width, u8 params_width, + bool compressed); + static void deSerializeBulk(std::istream &is, int version, MapNode *nodes, + u32 nodecount, u8 content_width, u8 params_width, + bool compressed); private: // Deprecated serialization methods |