// This 'roof' is removed when the mapchunk above is generated.
for (s16 y = nmax.Y; y >= nmin.Y - 1; y--,
index3d -= m_ystride,
- vm->m_area.add_y(em, vi, -1)) {
+ VoxelArea::add_y(em, vi, -1)) {
content_t c = vm->m_data[vi].getContent();
if (c == CONTENT_AIR || c == biome->c_water_top ||
// This 'roof' is excavated when the mapchunk above is generated.
for (s16 y = nmax.Y; y >= nmin.Y - 1; y--,
index3d -= m_ystride,
- vm->m_area.add_y(em, vi, -1),
+ VoxelArea::add_y(em, vi, -1),
cavern_amp_index++) {
content_t c = vm->m_data[vi].getContent();
float n_absamp_cavern = fabs(noise_cavern->result[index3d]) *
if (ndef->get(n).walkable)
break;
- vm->m_area.add_y(em, i, -1);
+ VoxelArea::add_y(em, i, -1);
}
return (y >= y_nodes_min) ? y : y_nodes_min - 1;
}
if (ndef->get(n).walkable)
break;
- vm->m_area.add_y(em, i, -1);
+ VoxelArea::add_y(em, i, -1);
}
return (y >= ymin) ? y : -MAX_MAP_GENERATION_LIMIT;
}
if (ndef->get(n).isLiquid())
break;
- vm->m_area.add_y(em, i, -1);
+ VoxelArea::add_y(em, i, -1);
}
return (y >= ymin) ? y : -MAX_MAP_GENERATION_LIMIT;
}
u32 vi = vm->m_area.index(p2d.X, ymax, p2d.Y);
MapNode mn_max = vm->m_data[vi];
bool walkable_above = ndef->get(mn_max).walkable;
- vm->m_area.add_y(em, vi, -1);
+ VoxelArea::add_y(em, vi, -1);
for (s16 y = ymax - 1; y >= ymin; y--) {
MapNode mn = vm->m_data[vi];
ceilings.push_back(y + 1);
}
- vm->m_area.add_y(em, vi, -1);
+ VoxelArea::add_y(em, vi, -1);
walkable_above = is_walkable;
}
}
inline bool Mapgen::isLiquidHorizontallyFlowable(u32 vi, v3s16 em)
{
u32 vi_neg_x = vi;
- vm->m_area.add_x(em, vi_neg_x, -1);
+ VoxelArea::add_x(em, vi_neg_x, -1);
if (vm->m_data[vi_neg_x].getContent() != CONTENT_IGNORE) {
const ContentFeatures &c_nx = ndef->get(vm->m_data[vi_neg_x]);
if (c_nx.floodable && !c_nx.isLiquid())
return true;
}
u32 vi_pos_x = vi;
- vm->m_area.add_x(em, vi_pos_x, +1);
+ VoxelArea::add_x(em, vi_pos_x, +1);
if (vm->m_data[vi_pos_x].getContent() != CONTENT_IGNORE) {
const ContentFeatures &c_px = ndef->get(vm->m_data[vi_pos_x]);
if (c_px.floodable && !c_px.isLiquid())
return true;
}
u32 vi_neg_z = vi;
- vm->m_area.add_z(em, vi_neg_z, -1);
+ VoxelArea::add_z(em, vi_neg_z, -1);
if (vm->m_data[vi_neg_z].getContent() != CONTENT_IGNORE) {
const ContentFeatures &c_nz = ndef->get(vm->m_data[vi_neg_z]);
if (c_nz.floodable && !c_nz.isLiquid())
return true;
}
u32 vi_pos_z = vi;
- vm->m_area.add_z(em, vi_pos_z, +1);
+ VoxelArea::add_z(em, vi_pos_z, +1);
if (vm->m_data[vi_pos_z].getContent() != CONTENT_IGNORE) {
const ContentFeatures &c_pz = ndef->get(vm->m_data[vi_pos_z]);
if (c_pz.floodable && !c_pz.isLiquid())
} else {
// This is the topmost node below a liquid column
u32 vi_above = vi;
- vm->m_area.add_y(em, vi_above, 1);
+ VoxelArea::add_y(em, vi_above, 1);
if (!waspushed && (ndef->get(vm->m_data[vi]).floodable ||
(!waschecked && isLiquidHorizontallyFlowable(vi_above, em)))) {
// Push back the lowest node in the column which is one
wasliquid = isliquid;
wasignored = isignored;
- vm->m_area.add_y(em, vi, -1);
+ VoxelArea::add_y(em, vi, -1);
}
}
}
propagate_shadow) {
continue;
}
- vm->m_area.add_y(em, i, -1);
+ VoxelArea::add_y(em, i, -1);
for (int y = a.MaxEdge.Y; y >= a.MinEdge.Y; y--) {
MapNode &n = vm->m_data[i];
if (!ndef->get(n).sunlight_propagates)
break;
n.param1 = LIGHT_SUN;
- vm->m_area.add_y(em, i, -1);
+ VoxelArea::add_y(em, i, -1);
}
}
}
water_above = false;
}
- vm->m_area.add_y(em, vi, -1);
+ VoxelArea::add_y(em, vi, -1);
}
}
if (vm->m_data[vi].getContent() != CONTENT_AIR)
break;
- vm->m_area.add_y(em, vi, -1);
+ VoxelArea::add_y(em, vi, -1);
}
content_t c = vm->m_data[vi].getContent();
dtype == NDT_GLASSLIKE_FRAMED ||
dtype == NDT_ALLFACES) &&
ndef->get(c).walkable && c != biome->c_dust) {
- vm->m_area.add_y(em, vi, 1);
+ VoxelArea::add_y(em, vi, 1);
vm->m_data[vi] = MapNode(biome->c_dust);
}
}
vm->m_data[vi] = n_air;
}
}
- vm->m_area.add_y(em, vi, 1);
+ VoxelArea::add_y(em, vi, 1);
}
}
if (c != CONTENT_IGNORE && (c == c_stone || c == c_desert_stone))
break;
- vm->m_area.add_y(em, i, -1);
+ VoxelArea::add_y(em, i, -1);
}
return (y >= y_nodes_min) ? y : y_nodes_min - 1;
}
vm->m_data[i] = n_air;
}
}
- vm->m_area.add_y(em, i, 1);
+ VoxelArea::add_y(em, i, 1);
}
}
vm->m_data[i] = addnode;
mudcount++;
- vm->m_area.add_y(em, i, 1);
+ VoxelArea::add_y(em, i, 1);
}
}
}
n->getContent() == c_gravel)
break;
- vm->m_area.add_y(em, i, -1);
+ VoxelArea::add_y(em, i, -1);
}
// Stop if out of area
// Don't flow it if the stuff under it is not mud
{
u32 i2 = i;
- vm->m_area.add_y(em, i2, -1);
+ VoxelArea::add_y(em, i2, -1);
// Cancel if out of area
if (!vm->m_area.contains(i2))
continue;
}
}
- v3s16 dirs4[4] = {
+ static const v3s16 dirs4[4] = {
v3s16(0, 0, 1), // back
v3s16(1, 0, 0), // right
v3s16(0, 0, -1), // front
// Check that upper is walkable. Cancel
// dropping if upper keeps it in place.
u32 i3 = i;
- vm->m_area.add_y(em, i3, 1);
+ VoxelArea::add_y(em, i3, 1);
MapNode *n3 = NULL;
if (vm->m_area.contains(i3)) {
for (const v3s16 &dirp : dirs4) {
u32 i2 = i;
// Move to side
- vm->m_area.add_p(em, i2, dirp);
+ VoxelArea::add_p(em, i2, dirp);
// Fail if out of area
if (!vm->m_area.contains(i2))
continue;
if (ndef->get(*n2).walkable)
continue;
// Check that under side is air
- vm->m_area.add_y(em, i2, -1);
+ VoxelArea::add_y(em, i2, -1);
if (!vm->m_area.contains(i2))
continue;
n2 = &vm->m_data[i2];
// Loop further down until not air
bool dropped_to_unknown = false;
do {
- vm->m_area.add_y(em, i2, -1);
+ VoxelArea::add_y(em, i2, -1);
n2 = &vm->m_data[i2];
// if out of known area
if (!vm->m_area.contains(i2) ||
}
} while (!ndef->get(*n2).walkable);
// Loop one up so that we're in air
- vm->m_area.add_y(em, i2, 1);
+ VoxelArea::add_y(em, i2, 1);
// Move mud to new place. Outside mapchunk remove
// any decorations above removed or placed mud.
vm->m_data[above_remove_index].getContent() != c_water_source &&
vm->m_data[above_remove_index].getContent() != CONTENT_IGNORE) {
vm->m_data[above_remove_index] = n_air;
- vm->m_area.add_y(em, above_remove_index, 1);
+ VoxelArea::add_y(em, above_remove_index, 1);
}
// Mud placed may have partially-buried a stacked decoration, search
// above and remove.
- vm->m_area.add_y(em, place_index, 1);
+ VoxelArea::add_y(em, place_index, 1);
while (vm->m_area.contains(place_index) &&
vm->m_data[place_index].getContent() != CONTENT_AIR &&
vm->m_data[place_index].getContent() != c_water_source &&
vm->m_data[place_index].getContent() != CONTENT_IGNORE) {
vm->m_data[place_index] = n_air;
- vm->m_area.add_y(em, place_index, 1);
+ VoxelArea::add_y(em, place_index, 1);
}
}
}
u32 vi = vm->m_area.index(x, y, z);
// place on dirt_with_grass, since we know it is exposed to sunlight
if (vm->m_data[vi].getContent() == c_dirt_with_grass) {
- vm->m_area.add_y(em, vi, 1);
+ VoxelArea::add_y(em, vi, 1);
vm->m_data[vi] = n_junglegrass;
}
}
ndef->get(n).liquid_type != LIQUID_NONE ||
n.getContent() == c_ice)
break;
- vm->m_area.add_y(em, i, -1);
+ VoxelArea::add_y(em, i, -1);
}
surface_y = (y >= full_node_min.Y) ? y : full_node_min.Y;
}
} else if (bt == BT_TUNDRA) {
if (c == c_dirt) {
vm->m_data[i] = n_snowblock;
- vm->m_area.add_y(em, i, -1);
+ VoxelArea::add_y(em, i, -1);
vm->m_data[i] = n_dirt_with_snow;
} else if (c == c_stone && surface_y < node_max.Y) {
- vm->m_area.add_y(em, i, 1);
+ VoxelArea::add_y(em, i, 1);
vm->m_data[i] = n_snowblock;
}
} else if (c == c_dirt) {
vm->m_data[vi] = n_air;
}
}
- vm->m_area.add_y(em, vi, 1);
+ VoxelArea::add_y(em, vi, 1);
index3d += ystride;
}
}
}
}
- vm->m_area.add_y(em, index_data, 1);
+ VoxelArea::add_y(em, index_data, 1);
index_3d += ystride;
}
// This 'roof' is removed when the mapchunk above is generated.
for (s16 y = node_max.Y; y >= node_min.Y - 1; y--,
index_3d -= ystride,
- vm->m_area.add_y(em, index_data, -1)) {
+ VoxelArea::add_y(em, index_data, -1)) {
float terrain = noise_terrain_height->result[index_2d];
// at the tunnel floor
s16 sr = ps.range(0, 39);
u32 j = index_data;
- vm->m_area.add_y(em, j, 1);
+ VoxelArea::add_y(em, j, 1);
if (sr > terrain - y) {
// Put biome nodes in tunnels near the surface
if (ceiling) {
// Ceiling decorations
// 'place offset y' is inverted
- vm->m_area.add_y(em, vi, -place_offset_y);
+ VoxelArea::add_y(em, vi, -place_offset_y);
for (int i = 0; i < height; i++) {
- vm->m_area.add_y(em, vi, -1);
+ VoxelArea::add_y(em, vi, -1);
content_t c = vm->m_data[vi].getContent();
if (c != CONTENT_AIR && c != CONTENT_IGNORE && !force_placement)
break;
vm->m_data[vi] = MapNode(c_place, 0, param2);
}
} else { // Heightmap and floor decorations
- vm->m_area.add_y(em, vi, place_offset_y);
+ VoxelArea::add_y(em, vi, place_offset_y);
for (int i = 0; i < height; i++) {
- vm->m_area.add_y(em, vi, 1);
+ VoxelArea::add_y(em, vi, 1);
content_t c = vm->m_data[vi].getContent();
if (c != CONTENT_AIR && c != CONTENT_IGNORE && !force_placement)
break;
}
/**
- * Retrieve the next free activeobject ID
- * @return free activeobject ID or zero if not free ID found
+ * Retrieve the first free ActiveObject ID
+ * @return free activeobject ID or 0 if none was found
*/
u16 ServerEnvironment::getFreeServerActiveObjectId()
{
bool isFreeServerActiveObjectId(u16 id) const;
/**
- * Retrieve the next free activeobject ID
- * @return free activeobject ID or zero if not free ID found
+ * Retrieve the first free ActiveObject ID
+ * @return free activeobject ID or 0 if none was found
*/
u16 getFreeServerActiveObjectId();
return index(p.X, p.Y, p.Z);
}
- // Translate index in the X coordinate
- void add_x(const v3s16 &extent, u32 &i, s16 a)
+ /**
+ * Translate index in the X coordinate
+ */
+ static void add_x(const v3s16 &extent, u32 &i, s16 a)
{
i += a;
}
- // Translate index in the Y coordinate
- void add_y(const v3s16 &extent, u32 &i, s16 a)
+
+ /**
+ * Translate index in the Y coordinate
+ */
+ static void add_y(const v3s16 &extent, u32 &i, s16 a)
{
i += a * extent.X;
}
- // Translate index in the Z coordinate
- void add_z(const v3s16 &extent, u32 &i, s16 a)
+
+ /**
+ * Translate index in the Z coordinate
+ */
+ static void add_z(const v3s16 &extent, u32 &i, s16 a)
{
- i += a * extent.X*extent.Y;
+ i += a * extent.X * extent.Y;
}
- // Translate index in space
- void add_p(const v3s16 &extent, u32 &i, v3s16 a)
+
+ /**
+ * Translate index in space
+ */
+ static void add_p(const v3s16 &extent, u32 &i, v3s16 a)
{
- i += a.Z*extent.X*extent.Y + a.Y*extent.X + a.X;
+ i += a.Z * extent.X * extent.Y + a.Y * extent.X + a.X;
}
/*
for (relpos.Y = a.MinEdge.Y; relpos.Y <= a.MaxEdge.Y; relpos.Y++) {
// Get old and new node
- MapNode oldnode = block->getNodeNoCheck(relpos.X, relpos.Y, relpos.Z, &is_valid);
+ MapNode oldnode = block->getNodeNoCheck(relpos, &is_valid);
const ContentFeatures &oldf = ndef->get(oldnode);
MapNode newnode = vm->getNodeNoExNoEmerge(relpos + offset);
const ContentFeatures &newf = oldnode == newnode ? oldf :
for (relpos.Y = a.MinEdge.Y; relpos.Y <= a.MaxEdge.Y; relpos.Y++) {
// Get node
- MapNode node = block->getNodeNoCheck(relpos.X, relpos.Y, relpos.Z, &is_valid);
+ MapNode node = block->getNodeNoCheck(relpos, &is_valid);
const ContentFeatures &f = ndef->get(node);
// For each light bank
for (size_t b = 0; b < 2; b++) {