aboutsummaryrefslogtreecommitdiff
path: root/src/nodedef.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nodedef.h')
-rw-r--r--src/nodedef.h103
1 files changed, 47 insertions, 56 deletions
diff --git a/src/nodedef.h b/src/nodedef.h
index b1492588a..cf03abaae 100644
--- a/src/nodedef.h
+++ b/src/nodedef.h
@@ -31,8 +31,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class Client;
#endif
#include "itemgroup.h"
-#include "sound.h" // SimpleSoundSpec
-#include "constants.h" // BS
+#include "sound.h" // SimpleSoundSpec
+#include "constants.h" // BS
#include "texture_override.h" // TextureOverride
#include "tileanimation.h"
@@ -87,11 +87,10 @@ enum LiquidType
enum NodeBoxType
{
- NODEBOX_REGULAR, // Regular block; allows buildable_to
- NODEBOX_FIXED, // Static separately defined box(es)
+ NODEBOX_REGULAR, // Regular block; allows buildable_to
+ NODEBOX_FIXED, // Static separately defined box(es)
NODEBOX_WALLMOUNTED, // Box for wall mounted nodes; (top, bottom, side)
- NODEBOX_LEVELED, // Same as fixed, but with dynamic height from param2. for snow,
- // ...
+ NODEBOX_LEVELED, // Same as fixed, but with dynamic height from param2. for snow, ...
NODEBOX_CONNECTED, // optionally draws nodeboxes if a neighbor node attaches
};
@@ -121,7 +120,8 @@ struct NodeBox
std::vector<aabb3f> disconnected;
std::vector<aabb3f> disconnected_sides;
- NodeBox() { reset(); }
+ NodeBox()
+ { reset(); }
void reset();
void serialize(std::ostream &os, u16 protocol_version) const;
@@ -131,30 +131,26 @@ struct NodeBox
struct MapNode;
class NodeMetadata;
-enum LeavesStyle
-{
+enum LeavesStyle {
LEAVES_FANCY,
LEAVES_SIMPLE,
LEAVES_OPAQUE,
};
-enum AutoScale : u8
-{
+enum AutoScale : u8 {
AUTOSCALE_DISABLE,
AUTOSCALE_ENABLE,
AUTOSCALE_FORCE,
};
-enum WorldAlignMode : u8
-{
+enum WorldAlignMode : u8 {
WORLDALIGN_DISABLE,
WORLDALIGN_ENABLE,
WORLDALIGN_FORCE,
WORLDALIGN_FORCE_NODEBOX,
};
-class TextureSettings
-{
+class TextureSettings {
public:
LeavesStyle leaves_style;
WorldAlignMode world_aligned_mode;
@@ -218,12 +214,11 @@ enum NodeDrawType
};
// Mesh options for NDT_PLANTLIKE with CPT2_MESHOPTIONS
-static const u8 MO_MASK_STYLE = 0x07;
-static const u8 MO_BIT_RANDOM_OFFSET = 0x08;
-static const u8 MO_BIT_SCALE_SQRT2 = 0x10;
+static const u8 MO_MASK_STYLE = 0x07;
+static const u8 MO_BIT_RANDOM_OFFSET = 0x08;
+static const u8 MO_BIT_SCALE_SQRT2 = 0x10;
static const u8 MO_BIT_RANDOM_OFFSET_Y = 0x20;
-enum PlantlikeStyle
-{
+enum PlantlikeStyle {
PLANT_STYLE_CROSS,
PLANT_STYLE_CROSS2,
PLANT_STYLE_STAR,
@@ -231,8 +226,7 @@ enum PlantlikeStyle
PLANT_STYLE_HASH2,
};
-enum AlignStyle : u8
-{
+enum AlignStyle : u8 {
ALIGN_STYLE_NODE,
ALIGN_STYLE_WORLD,
ALIGN_STYLE_USER_DEFINED,
@@ -257,11 +251,14 @@ struct TileDef
struct TileAnimationParams animation;
- TileDef() { animation.type = TAT_NONE; }
+ TileDef()
+ {
+ animation.type = TAT_NONE;
+ }
void serialize(std::ostream &os, u16 protocol_version) const;
void deSerialize(std::istream &is, u8 contentfeatures_version,
- NodeDrawType drawtype);
+ NodeDrawType drawtype);
};
#define CF_SPECIAL_COUNT 6
@@ -278,7 +275,7 @@ struct ContentFeatures
// Special tiles
// - Currently used for flowing liquids
TileSpec special_tiles[CF_SPECIAL_COUNT];
- u8 solidness; // Used when choosing which face is drawn
+ u8 solidness; // Used when choosing which face is drawn
u8 visual_solidness; // When solidness=0, this tells how it looks like
bool backface_culling;
#endif
@@ -294,7 +291,7 @@ struct ContentFeatures
// --- GENERAL PROPERTIES ---
- std::string name; // "" = undefined node
+ std::string name; // "" = undefined node
ItemGroupList groups; // Same as in itemdef
// Type of MapNode::param1
ContentParamType param_type;
@@ -428,11 +425,11 @@ struct ContentFeatures
/*
Some handy methods
*/
- bool isLiquid() const { return (liquid_type != LIQUID_NONE); }
- bool sameLiquid(const ContentFeatures &f) const
- {
- if (!isLiquid() || !f.isLiquid())
- return false;
+ bool isLiquid() const{
+ return (liquid_type != LIQUID_NONE);
+ }
+ bool sameLiquid(const ContentFeatures &f) const{
+ if(!isLiquid() || !f.isLiquid()) return false;
return (liquid_alternative_flowing_id == f.liquid_alternative_flowing_id);
}
@@ -443,8 +440,7 @@ struct ContentFeatures
#ifndef SERVER
void updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc,
- scene::IMeshManipulator *meshmanip, Client *client,
- const TextureSettings &tsettings);
+ scene::IMeshManipulator *meshmanip, Client *client, const TextureSettings &tsettings);
#endif
};
@@ -460,8 +456,7 @@ struct ContentFeatures
* functions only get `const` pointers to it, to prevent modification of
* registered nodes.
*/
-class NodeDefManager
-{
+class NodeDefManager {
public:
/*!
* Creates a NodeDefManager, and registers three ContentFeatures:
@@ -476,11 +471,10 @@ public:
* @return properties of the given content type, or \ref CONTENT_UNKNOWN
* if the given content type is not registered.
*/
- inline const ContentFeatures &get(content_t c) const
- {
- return c < m_content_features.size()
- ? m_content_features[c]
- : m_content_features[CONTENT_UNKNOWN];
+ inline const ContentFeatures& get(content_t c) const {
+ return
+ c < m_content_features.size() ?
+ m_content_features[c] : m_content_features[CONTENT_UNKNOWN];
}
/*!
@@ -489,8 +483,7 @@ public:
* @return properties of the given node or @ref CONTENT_UNKNOWN if the
* given content type is not registered.
*/
- inline const ContentFeatures &get(const MapNode &n) const
- {
+ inline const ContentFeatures& get(const MapNode &n) const {
return get(n.getContent());
}
@@ -500,7 +493,7 @@ public:
* @return properties of the given node or @ref CONTENT_UNKNOWN if
* not found
*/
- const ContentFeatures &get(const std::string &name) const;
+ const ContentFeatures& get(const std::string &name) const;
/*!
* Returns the content ID for the given name.
@@ -533,8 +526,7 @@ public:
* contains all nodes' selection boxes. The returned box might be larger
* than the minimal size if the largest node is removed from the manager.
*/
- inline core::aabbox3d<s16> getSelectionBoxIntUnion() const
- {
+ inline core::aabbox3d<s16> getSelectionBoxIntUnion() const {
return m_selection_box_int_union;
}
@@ -547,7 +539,8 @@ public:
* Bits: +y (least significant), -y, -z, -x, +z, +x (most significant).
* @return true if the node connects, false otherwise
*/
- bool nodeboxConnects(MapNode from, MapNode to, u8 connect_face) const;
+ bool nodeboxConnects(MapNode from, MapNode to,
+ u8 connect_face) const;
/*!
* Registers a NodeResolver to wait for the registration of
@@ -612,9 +605,8 @@ public:
* @param progress_cbk_args passed to the callback function
*/
void updateTextures(IGameDef *gamedef,
- void (*progress_cbk)(void *progress_args, u32 progress,
- u32 max_progress),
- void *progress_cbk_args);
+ void (*progress_cbk)(void *progress_args, u32 progress, u32 max_progress),
+ void *progress_cbk_args);
/*!
* Writes the content of this manager to the given output stream.
@@ -633,8 +625,7 @@ public:
* Used to indicate that node registration has finished.
* @param completed tells whether registration is complete
*/
- inline void setNodeRegistrationStatus(bool completed)
- {
+ inline void setNodeRegistrationStatus(bool completed) {
m_node_registration_complete = completed;
}
@@ -747,8 +738,7 @@ private:
NodeDefManager *createNodeDefManager();
-class NodeResolver
-{
+class NodeResolver {
public:
NodeResolver();
virtual ~NodeResolver();
@@ -757,10 +747,11 @@ public:
// required because this class is used as mixin for ObjDef
void cloneTo(NodeResolver *res) const;
- bool getIdFromNrBacklog(content_t *result_out, const std::string &node_alt,
- content_t c_fallback, bool error_on_fallback = true);
+ bool getIdFromNrBacklog(content_t *result_out,
+ const std::string &node_alt, content_t c_fallback,
+ bool error_on_fallback = true);
bool getIdsFromNrBacklog(std::vector<content_t> *result_out,
- bool all_required = false, content_t c_fallback = CONTENT_IGNORE);
+ bool all_required = false, content_t c_fallback = CONTENT_IGNORE);
void nodeResolveInternal();