mirror of
https://github.com/minetest/minetest.git
synced 2024-12-23 22:52:25 +01:00
mapnode: add const/noexcept (#8009)
This commit is contained in:
parent
0990ddb3bb
commit
309e158fc8
@ -65,7 +65,7 @@ void MapNode::getColor(const ContentFeatures &f, video::SColor *color) const
|
||||
*color = f.color;
|
||||
}
|
||||
|
||||
void MapNode::setLight(enum LightBank bank, u8 a_light, const ContentFeatures &f)
|
||||
void MapNode::setLight(LightBank bank, u8 a_light, const ContentFeatures &f) noexcept
|
||||
{
|
||||
// If node doesn't contain light data, ignore this
|
||||
if(f.param_type != CPT_LIGHT)
|
||||
@ -84,8 +84,7 @@ void MapNode::setLight(enum LightBank bank, u8 a_light, const ContentFeatures &f
|
||||
assert("Invalid light bank" == NULL);
|
||||
}
|
||||
|
||||
void MapNode::setLight(enum LightBank bank, u8 a_light,
|
||||
const NodeDefManager *nodemgr)
|
||||
void MapNode::setLight(LightBank bank, u8 a_light, const NodeDefManager *nodemgr)
|
||||
{
|
||||
setLight(bank, a_light, nodemgr->get(*this));
|
||||
}
|
||||
@ -106,7 +105,7 @@ bool MapNode::isLightDayNightEq(const NodeDefManager *nodemgr) const
|
||||
return isEqual;
|
||||
}
|
||||
|
||||
u8 MapNode::getLight(enum LightBank bank, const NodeDefManager *nodemgr) const
|
||||
u8 MapNode::getLight(LightBank bank, const NodeDefManager *nodemgr) const
|
||||
{
|
||||
// Select the brightest of [light source, propagated light]
|
||||
const ContentFeatures &f = nodemgr->get(*this);
|
||||
@ -120,14 +119,14 @@ u8 MapNode::getLight(enum LightBank bank, const NodeDefManager *nodemgr) const
|
||||
return MYMAX(f.light_source, light);
|
||||
}
|
||||
|
||||
u8 MapNode::getLightRaw(enum LightBank bank, const ContentFeatures &f) const
|
||||
u8 MapNode::getLightRaw(LightBank bank, const ContentFeatures &f) const noexcept
|
||||
{
|
||||
if(f.param_type == CPT_LIGHT)
|
||||
return bank == LIGHTBANK_DAY ? param1 & 0x0f : (param1 >> 4) & 0x0f;
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 MapNode::getLightNoChecks(enum LightBank bank, const ContentFeatures *f) const
|
||||
u8 MapNode::getLightNoChecks(LightBank bank, const ContentFeatures *f) const noexcept
|
||||
{
|
||||
return MYMAX(f->light_source,
|
||||
bank == LIGHTBANK_DAY ? param1 & 0x0f : (param1 >> 4) & 0x0f);
|
||||
@ -530,7 +529,7 @@ static inline void getNeighborConnectingFace(
|
||||
*neighbors |= bitmask;
|
||||
}
|
||||
|
||||
u8 MapNode::getNeighbors(v3s16 p, Map *map)
|
||||
u8 MapNode::getNeighbors(v3s16 p, Map *map) const
|
||||
{
|
||||
const NodeDefManager *nodedef = map->getNodeDefManager();
|
||||
u8 neighbors = 0;
|
||||
@ -567,14 +566,14 @@ u8 MapNode::getNeighbors(v3s16 p, Map *map)
|
||||
}
|
||||
|
||||
void MapNode::getNodeBoxes(const NodeDefManager *nodemgr,
|
||||
std::vector<aabb3f> *boxes, u8 neighbors)
|
||||
std::vector<aabb3f> *boxes, u8 neighbors) const
|
||||
{
|
||||
const ContentFeatures &f = nodemgr->get(*this);
|
||||
transformNodeBox(*this, f.node_box, nodemgr, boxes, neighbors);
|
||||
}
|
||||
|
||||
void MapNode::getCollisionBoxes(const NodeDefManager *nodemgr,
|
||||
std::vector<aabb3f> *boxes, u8 neighbors)
|
||||
std::vector<aabb3f> *boxes, u8 neighbors) const
|
||||
{
|
||||
const ContentFeatures &f = nodemgr->get(*this);
|
||||
if (f.collision_box.fixed.empty())
|
||||
@ -584,7 +583,7 @@ void MapNode::getCollisionBoxes(const NodeDefManager *nodemgr,
|
||||
}
|
||||
|
||||
void MapNode::getSelectionBoxes(const NodeDefManager *nodemgr,
|
||||
std::vector<aabb3f> *boxes, u8 neighbors)
|
||||
std::vector<aabb3f> *boxes, u8 neighbors) const
|
||||
{
|
||||
const ContentFeatures &f = nodemgr->get(*this);
|
||||
transformNodeBox(*this, f.selection_box, nodemgr, boxes, neighbors);
|
||||
@ -676,7 +675,7 @@ u32 MapNode::serializedLength(u8 version)
|
||||
|
||||
return 4;
|
||||
}
|
||||
void MapNode::serialize(u8 *dest, u8 version)
|
||||
void MapNode::serialize(u8 *dest, u8 version) const
|
||||
{
|
||||
if(!ser_ver_supported(version))
|
||||
throw VersionMismatchException("ERROR: MapNode format not supported");
|
||||
|
@ -139,7 +139,7 @@ struct MapNode
|
||||
|
||||
MapNode() = default;
|
||||
|
||||
MapNode(content_t content, u8 a_param1=0, u8 a_param2=0)
|
||||
MapNode(content_t content, u8 a_param1=0, u8 a_param2=0) noexcept
|
||||
: param0(content),
|
||||
param1(a_param1),
|
||||
param2(a_param2)
|
||||
@ -150,7 +150,7 @@ struct MapNode
|
||||
MapNode(const NodeDefManager *ndef, const std::string &name,
|
||||
u8 a_param1=0, u8 a_param2=0);
|
||||
|
||||
bool operator==(const MapNode &other)
|
||||
bool operator==(const MapNode &other) const noexcept
|
||||
{
|
||||
return (param0 == other.param0
|
||||
&& param1 == other.param1
|
||||
@ -158,27 +158,27 @@ struct MapNode
|
||||
}
|
||||
|
||||
// To be used everywhere
|
||||
content_t getContent() const
|
||||
content_t getContent() const noexcept
|
||||
{
|
||||
return param0;
|
||||
}
|
||||
void setContent(content_t c)
|
||||
void setContent(content_t c) noexcept
|
||||
{
|
||||
param0 = c;
|
||||
}
|
||||
u8 getParam1() const
|
||||
u8 getParam1() const noexcept
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
void setParam1(u8 p)
|
||||
void setParam1(u8 p) noexcept
|
||||
{
|
||||
param1 = p;
|
||||
}
|
||||
u8 getParam2() const
|
||||
u8 getParam2() const noexcept
|
||||
{
|
||||
return param2;
|
||||
}
|
||||
void setParam2(u8 p)
|
||||
void setParam2(u8 p) noexcept
|
||||
{
|
||||
param2 = p;
|
||||
}
|
||||
@ -191,10 +191,9 @@ struct MapNode
|
||||
*/
|
||||
void getColor(const ContentFeatures &f, video::SColor *color) const;
|
||||
|
||||
void setLight(enum LightBank bank, u8 a_light, const ContentFeatures &f);
|
||||
void setLight(LightBank bank, u8 a_light, const ContentFeatures &f) noexcept;
|
||||
|
||||
void setLight(enum LightBank bank, u8 a_light,
|
||||
const NodeDefManager *nodemgr);
|
||||
void setLight(LightBank bank, u8 a_light, const NodeDefManager *nodemgr);
|
||||
|
||||
/**
|
||||
* Check if the light value for night differs from the light value for day.
|
||||
@ -203,17 +202,17 @@ struct MapNode
|
||||
*/
|
||||
bool isLightDayNightEq(const NodeDefManager *nodemgr) const;
|
||||
|
||||
u8 getLight(enum LightBank bank, const NodeDefManager *nodemgr) const;
|
||||
u8 getLight(LightBank bank, const NodeDefManager *nodemgr) const;
|
||||
|
||||
/*!
|
||||
* Returns the node's light level from param1.
|
||||
* If the node emits light, it is ignored.
|
||||
* \param f the ContentFeatures of this node.
|
||||
*/
|
||||
u8 getLightRaw(enum LightBank bank, const ContentFeatures &f) const;
|
||||
u8 getLightRaw(LightBank bank, const ContentFeatures &f) const noexcept;
|
||||
|
||||
/**
|
||||
* This function differs from getLight(enum LightBank bank, NodeDefManager *nodemgr)
|
||||
* This function differs from getLight(LightBank bank, NodeDefManager *nodemgr)
|
||||
* in that the ContentFeatures of the node in question are not retrieved by
|
||||
* the function itself. Thus, if you have already called nodemgr->get() to
|
||||
* get the ContentFeatures you pass it to this function instead of the
|
||||
@ -227,7 +226,7 @@ struct MapNode
|
||||
* @pre f != NULL
|
||||
* @pre f->param_type == CPT_LIGHT
|
||||
*/
|
||||
u8 getLightNoChecks(LightBank bank, const ContentFeatures *f) const;
|
||||
u8 getLightNoChecks(LightBank bank, const ContentFeatures *f) const noexcept;
|
||||
|
||||
bool getLightBanks(u8 &lightday, u8 &lightnight,
|
||||
const NodeDefManager *nodemgr) const;
|
||||
@ -242,8 +241,7 @@ 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;
|
||||
|
||||
@ -254,25 +252,25 @@ struct MapNode
|
||||
*
|
||||
* \param p coordinates of the node
|
||||
*/
|
||||
u8 getNeighbors(v3s16 p, Map *map);
|
||||
u8 getNeighbors(v3s16 p, Map *map) const;
|
||||
|
||||
/*
|
||||
Gets list of node boxes (used for rendering (NDT_NODEBOX))
|
||||
*/
|
||||
void getNodeBoxes(const NodeDefManager *nodemgr, std::vector<aabb3f> *boxes,
|
||||
u8 neighbors = 0);
|
||||
u8 neighbors = 0) const;
|
||||
|
||||
/*
|
||||
Gets list of selection boxes
|
||||
*/
|
||||
void getSelectionBoxes(const NodeDefManager *nodemg,
|
||||
std::vector<aabb3f> *boxes, u8 neighbors = 0);
|
||||
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);
|
||||
std::vector<aabb3f> *boxes, u8 neighbors = 0) const;
|
||||
|
||||
/*
|
||||
Liquid helpers
|
||||
@ -287,7 +285,7 @@ struct MapNode
|
||||
*/
|
||||
|
||||
static u32 serializedLength(u8 version);
|
||||
void serialize(u8 *dest, u8 version);
|
||||
void serialize(u8 *dest, u8 version) const;
|
||||
void deSerialize(u8 *source, u8 version);
|
||||
|
||||
// Serializes or deserializes a list of nodes in bulk format (first the
|
||||
|
Loading…
Reference in New Issue
Block a user