-void DecoSchematic::placeStructure(Map *map, v3s16 p) {
- assert(schematic != NULL);
- ManualMapVoxelManipulator *vm = new ManualMapVoxelManipulator(map);
-
- Rotation rot = (rotation == ROTATE_RAND) ?
- (Rotation)myrand_range(ROTATE_0, ROTATE_270) : rotation;
-
- v3s16 s = (rot == ROTATE_90 || rot == ROTATE_270) ?
- v3s16(size.Z, size.Y, size.X) : size;
-
- if (flags & DECO_PLACE_CENTER_X)
- p.X -= (s.X + 1) / 2;
- if (flags & DECO_PLACE_CENTER_Y)
- p.Y -= (s.Y + 1) / 2;
- if (flags & DECO_PLACE_CENTER_Z)
- p.Z -= (s.Z + 1) / 2;
-
- v3s16 bp1 = getNodeBlockPos(p);
- v3s16 bp2 = getNodeBlockPos(p + s - v3s16(1,1,1));
- vm->initialEmerge(bp1, bp2);
-
- blitToVManip(p, vm, rot, true);
-
- std::map<v3s16, MapBlock *> lighting_modified_blocks;
- std::map<v3s16, MapBlock *> modified_blocks;
- vm->blitBackAll(&modified_blocks);
-
- // TODO: Optimize this by using Mapgen::calcLighting() instead
- lighting_modified_blocks.insert(modified_blocks.begin(), modified_blocks.end());
- map->updateLighting(lighting_modified_blocks, modified_blocks);
-
- MapEditEvent event;
- event.type = MEET_OTHER;
- for (std::map<v3s16, MapBlock *>::iterator
- it = modified_blocks.begin();
- it != modified_blocks.end(); ++it)
- event.modified_blocks.insert(it->first);
-
- map->dispatchEvent(&event);
+////
+//// MapgenBasic
+////
+
+MapgenBasic::MapgenBasic(int mapgenid, MapgenParams *params, EmergeManager *emerge)
+ : Mapgen(mapgenid, params, emerge)
+{
+ this->m_emerge = emerge;
+ this->m_bmgr = emerge->biomemgr;
+
+ //// Here, 'stride' refers to the number of elements needed to skip to index
+ //// an adjacent element for that coordinate in noise/height/biome maps
+ //// (*not* vmanip content map!)
+
+ // Note there is no X stride explicitly defined. Items adjacent in the X
+ // coordinate are assumed to be adjacent in memory as well (i.e. stride of 1).
+
+ // Number of elements to skip to get to the next Y coordinate
+ this->ystride = csize.X;
+
+ // Number of elements to skip to get to the next Z coordinate
+ this->zstride = csize.X * csize.Y;
+
+ // Z-stride value for maps oversized for 1-down overgeneration
+ this->zstride_1d = csize.X * (csize.Y + 1);
+
+ // Z-stride value for maps oversized for 1-up 1-down overgeneration
+ this->zstride_1u1d = csize.X * (csize.Y + 2);
+
+ //// Allocate heightmap
+ this->heightmap = new s16[csize.X * csize.Z];
+
+ //// Initialize biome generator
+ // TODO(hmmmm): should we have a way to disable biomemanager biomes?
+ biomegen = m_bmgr->createBiomeGen(BIOMEGEN_ORIGINAL, params->bparams, csize);
+ biomemap = biomegen->biomemap;
+
+ //// Look up some commonly used content
+ c_stone = ndef->getId("mapgen_stone");
+ c_desert_stone = ndef->getId("mapgen_desert_stone");
+ c_sandstone = ndef->getId("mapgen_sandstone");
+ c_water_source = ndef->getId("mapgen_water_source");
+ c_river_water_source = ndef->getId("mapgen_river_water_source");
+ c_lava_source = ndef->getId("mapgen_lava_source");
+
+ // Fall back to more basic content if not defined
+ // river_water_source cannot fallback to water_source because river water
+ // needs to be non-renewable and have a short flow range.
+ if (c_desert_stone == CONTENT_IGNORE)
+ c_desert_stone = c_stone;
+ if (c_sandstone == CONTENT_IGNORE)
+ c_sandstone = c_stone;
+
+ //// Content used for dungeon generation
+ c_cobble = ndef->getId("mapgen_cobble");
+ c_mossycobble = ndef->getId("mapgen_mossycobble");
+ c_stair_cobble = ndef->getId("mapgen_stair_cobble");
+ c_stair_desert_stone = ndef->getId("mapgen_stair_desert_stone");
+ c_sandstonebrick = ndef->getId("mapgen_sandstonebrick");
+ c_stair_sandstone_block = ndef->getId("mapgen_stair_sandstone_block");
+
+ // Fall back to more basic content if not defined
+ if (c_mossycobble == CONTENT_IGNORE)
+ c_mossycobble = c_cobble;
+ if (c_stair_cobble == CONTENT_IGNORE)
+ c_stair_cobble = c_cobble;
+ if (c_stair_desert_stone == CONTENT_IGNORE)
+ c_stair_desert_stone = c_desert_stone;
+ if (c_sandstonebrick == CONTENT_IGNORE)
+ c_sandstonebrick = c_sandstone;
+ if (c_stair_sandstone_block == CONTENT_IGNORE)
+ c_stair_sandstone_block = c_sandstonebrick;