size_t DecorationManager::placeAllDecos(Mapgen *mg, u32 blockseed,
- v3s16 nmin, v3s16 nmax)
+ v3s16 nmin, v3s16 nmax, s16 deco_zero_level)
{
size_t nplaced = 0;
if (!deco)
continue;
- nplaced += deco->placeDeco(mg, blockseed, nmin, nmax);
+ nplaced += deco->placeDeco(mg, blockseed, nmin, nmax, deco_zero_level);
blockseed++;
}
///////////////////////////////////////////////////////////////////////////////
-
-Decoration::Decoration()
-{
- mapseed = 0;
- fill_ratio = 0;
- sidelen = 1;
- flags = 0;
-}
-
-
-Decoration::~Decoration()
-{
-}
-
-
void Decoration::resolveNodeNames()
{
getIdsFromNrBacklog(&c_place_on);
}
-size_t Decoration::placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
+size_t Decoration::placeDeco(Mapgen *mg, u32 blockseed,
+ v3s16 nmin, v3s16 nmax, s16 deco_zero_level)
{
+ // Decoration y_min / y_max is displaced by deco_zero_level or remains
+ // unchanged. Any decoration with a limit at +-MAX_MAP_GENERATION_LIMIT is
+ // considered to have that limit at +-infinity, so we do not alter that limit.
+ s32 y_min_disp = (y_min <= -MAX_MAP_GENERATION_LIMIT) ?
+ -MAX_MAP_GENERATION_LIMIT : y_min + deco_zero_level;
+
+ s32 y_max_disp = (y_max >= MAX_MAP_GENERATION_LIMIT) ?
+ MAX_MAP_GENERATION_LIMIT : y_max + deco_zero_level;
+
PcgRandom ps(blockseed + 53);
int carea_size = nmax.X - nmin.X + 1;
else
y = mg->findGroundLevel(v2s16(x, z), nmin.Y, nmax.Y);
- if (y < nmin.Y || y > nmax.Y ||
- y < y_min || y > y_max)
+ if (y < y_min_disp || y > y_max_disp || y < nmin.Y || y > nmax.Y)
continue;
if (y + getHeight() > mg->vm->m_area.MaxEdge.Y) {
#endif
}
- if (mg->biomemap) {
- UNORDERED_SET<u8>::iterator iter;
-
- if (!biomes.empty()) {
- iter = biomes.find(mg->biomemap[mapindex]);
- if (iter == biomes.end())
- continue;
- }
+ if (mg->biomemap && !biomes.empty()) {
+ std::unordered_set<u8>::const_iterator iter =
+ biomes.find(mg->biomemap[mapindex]);
+ if (iter == biomes.end())
+ continue;
}
v3s16 pos(x, y, z);
bool force_placement = (flags & DECO_FORCE_PLACEMENT);
- v3s16 em = vm->m_area.getExtent();
+ const v3s16 &em = vm->m_area.getExtent();
u32 vi = vm->m_area.index(p);
for (int i = 0; i < height; i++) {
vm->m_area.add_y(em, vi, 1);
///////////////////////////////////////////////////////////////////////////////
-
-DecoSchematic::DecoSchematic()
-{
- schematic = NULL;
-}
-
-
size_t DecoSchematic::generate(MMVManip *vm, PcgRandom *pr, v3s16 p)
{
// Schematic could have been unloaded but not the decoration