// Create directly from a nodename
// If name is unknown, sets CONTENT_IGNORE
// Create directly from a nodename
// If name is unknown, sets CONTENT_IGNORE
u8 a_param1, u8 a_param2)
{
content_t id = CONTENT_IGNORE;
u8 a_param1, u8 a_param2)
{
content_t id = CONTENT_IGNORE;
-void MapNode::setLight(enum LightBank bank, u8 a_light, INodeDefManager *nodemgr)
+void MapNode::setLight(enum LightBank bank, u8 a_light,
+ const NodeDefManager *nodemgr)
{
// Select the brightest of [light source, propagated light]
const ContentFeatures &f = nodemgr->get(*this);
{
// Select the brightest of [light source, propagated light]
const ContentFeatures &f = nodemgr->get(*this);
-bool MapNode::getLightBanks(u8 &lightday, u8 &lightnight, INodeDefManager *nodemgr) const
+bool MapNode::getLightBanks(u8 &lightday, u8 &lightnight,
+ const NodeDefManager *nodemgr) const
{
// Select the brightest of [light source, propagated light]
const ContentFeatures &f = nodemgr->get(*this);
{
// Select the brightest of [light source, propagated light]
const ContentFeatures &f = nodemgr->get(*this);
{
const ContentFeatures &f = nodemgr->get(*this);
if (f.param_type_2 == CPT2_FACEDIR ||
f.param_type_2 == CPT2_COLORED_FACEDIR)
return (getParam2() & 0x1F) % 24;
{
const ContentFeatures &f = nodemgr->get(*this);
if (f.param_type_2 == CPT2_FACEDIR ||
f.param_type_2 == CPT2_COLORED_FACEDIR)
return (getParam2() & 0x1F) % 24;
{
std::vector<aabb3f> &boxes = *p_boxes;
if (nodebox.type == NODEBOX_FIXED || nodebox.type == NODEBOX_LEVELED) {
const std::vector<aabb3f> &fixed = nodebox.fixed;
{
std::vector<aabb3f> &boxes = *p_boxes;
if (nodebox.type == NODEBOX_FIXED || nodebox.type == NODEBOX_LEVELED) {
const std::vector<aabb3f> &fixed = nodebox.fixed;
- for(std::vector<aabb3f>::const_iterator
- i = fixed.begin();
- i != fixed.end(); ++i)
- {
- aabb3f box = *i;
-
- if (nodebox.type == NODEBOX_LEVELED) {
- box.MaxEdge.Y = -BS/2 + BS*((float)1/LEVELED_MAX) * n.getLevel(nodemgr);
- }
+ for (aabb3f box : fixed) {
+ if (nodebox.type == NODEBOX_LEVELED)
+ box.MaxEdge.Y = (-0.5f + n.getLevel(nodemgr) / 64.0f) * BS;
- boxes.push_back(aabb3f(-BS/2,-BS/2,-BS/2,BS/2,BS/2,BS/2));
+ boxes.emplace_back(-BS/2,-BS/2,-BS/2,BS/2,BS/2,BS/2);
Map *map, MapNode n, u8 bitmask, u8 *neighbors)
{
MapNode n2 = map->getNodeNoEx(p);
Map *map, MapNode n, u8 bitmask, u8 *neighbors)
{
MapNode n2 = map->getNodeNoEx(p);
-void MapNode::getNodeBoxes(INodeDefManager *nodemgr, std::vector<aabb3f> *boxes, u8 neighbors)
+void MapNode::getNodeBoxes(const NodeDefManager *nodemgr,
+ std::vector<aabb3f> *boxes, u8 neighbors)
{
const ContentFeatures &f = nodemgr->get(*this);
transformNodeBox(*this, f.node_box, nodemgr, boxes, neighbors);
}
{
const ContentFeatures &f = nodemgr->get(*this);
transformNodeBox(*this, f.node_box, nodemgr, boxes, neighbors);
}
-void MapNode::getCollisionBoxes(INodeDefManager *nodemgr, std::vector<aabb3f> *boxes, u8 neighbors)
+void MapNode::getCollisionBoxes(const NodeDefManager *nodemgr,
+ std::vector<aabb3f> *boxes, u8 neighbors)
transformNodeBox(*this, f.collision_box, nodemgr, boxes, neighbors);
}
transformNodeBox(*this, f.collision_box, nodemgr, boxes, neighbors);
}
-void MapNode::getSelectionBoxes(INodeDefManager *nodemgr, std::vector<aabb3f> *boxes, u8 neighbors)
+void MapNode::getSelectionBoxes(const NodeDefManager *nodemgr,
+ std::vector<aabb3f> *boxes, u8 neighbors)
{
const ContentFeatures &f = nodemgr->get(*this);
transformNodeBox(*this, f.selection_box, nodemgr, boxes, neighbors);
}
{
const ContentFeatures &f = nodemgr->get(*this);
transformNodeBox(*this, f.selection_box, nodemgr, boxes, neighbors);
}
{
const ContentFeatures &f = nodemgr->get(*this);
// todo: after update in all games leave only if (f.param_type_2 ==
{
const ContentFeatures &f = nodemgr->get(*this);
// todo: after update in all games leave only if (f.param_type_2 ==
{
const ContentFeatures &f = nodemgr->get(*this);
// todo: after update in all games leave only if (f.param_type_2 ==
{
const ContentFeatures &f = nodemgr->get(*this);
// todo: after update in all games leave only if (f.param_type_2 ==
if(!ser_ver_supported(version))
throw VersionMismatchException("ERROR: MapNode format not supported");
if(!ser_ver_supported(version))
throw VersionMismatchException("ERROR: MapNode format not supported");
const MapNode *nodes, u32 nodecount,
u8 content_width, u8 params_width, bool compressed)
{
const MapNode *nodes, u32 nodecount,
u8 content_width, u8 params_width, bool compressed)
{
throw VersionMismatchException("ERROR: MapNode format not supported");
sanity_check(content_width == 2);
throw VersionMismatchException("ERROR: MapNode format not supported");
sanity_check(content_width == 2);
// Can't do this anymore; we have 16-bit dynamically allocated node IDs
// in memory; conversion just won't work in this direction.
// Can't do this anymore; we have 16-bit dynamically allocated node IDs
// in memory; conversion just won't work in this direction.
- for(u32 i=0; i<nodecount; i++)
+
+ // Serialize content
+ for (u32 i = 0; i < nodecount; i++) {
+ writeU16(&databuf[i * 2], nodes[i].param0);
+ writeU8(&databuf[start1 + i], nodes[i].param1);