#endif
}
-void ServerMap::initBlockMake(BlockMakeData *data, v3s16 blockpos)
+void ServerMap::initBlockMake(mapgen::BlockMakeData *data, v3s16 blockpos)
{
/*dstream<<"initBlockMake(): ("<<blockpos.X<<","<<blockpos.Y<<","
<<blockpos.Z<<")"<<std::endl;*/
v3s16 bigarea_blocks_min = blockpos - v3s16(1,1,1);
v3s16 bigarea_blocks_max = blockpos + v3s16(1,1,1);
- data->vmanip.setMap(this);
+ data->vmanip = new ManualMapVoxelManipulator(this);
+ //data->vmanip->setMap(this);
// Add the area
{
//TimeTaker timer("initBlockMake() initialEmerge");
- data->vmanip.initialEmerge(bigarea_blocks_min, bigarea_blocks_max);
+ data->vmanip->initialEmerge(bigarea_blocks_min, bigarea_blocks_max);
}
// Data is ready now.
}
-MapBlock* ServerMap::finishBlockMake(BlockMakeData *data,
+MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data,
core::map<v3s16, MapBlock*> &changed_blocks)
{
v3s16 blockpos = data->blockpos;
{
// 70ms @cs=8
//TimeTaker timer("finishBlockMake() blitBackAll");
- data->vmanip.blitBackAll(&changed_blocks);
+ data->vmanip->blitBackAll(&changed_blocks);
}
#if 1
dstream<<"finishBlockMake: changed_blocks.size()="
/*
Create block make data
*/
- BlockMakeData data;
+ mapgen::BlockMakeData data;
initBlockMake(&data, p);
/*
#include "mapchunk.h"
#include "nodemetadata.h"
+namespace mapgen{
+ struct BlockMakeData;
+};
+
/*
MapEditEvent
*/
This is the only map class that is able to generate map.
*/
-//struct ChunkMakeData;
-
-struct BlockMakeData;
-
class ServerMap : public Map
{
public:
/*
Blocks are generated by using these and makeBlock().
*/
- void initBlockMake(BlockMakeData *data, v3s16 blockpos);
- MapBlock* finishBlockMake(BlockMakeData *data,
+ void initBlockMake(mapgen::BlockMakeData *data, v3s16 blockpos);
+ MapBlock* finishBlockMake(mapgen::BlockMakeData *data,
core::map<v3s16, MapBlock*> &changed_blocks);
// A non-threaded wrapper to the above
bool m_create_area;
};
-#if 0
-struct ChunkMakeData
-{
- bool no_op;
- ManualMapVoxelManipulator vmanip;
- u64 seed;
- v2s16 chunkpos;
- s16 y_blocks_min;
- s16 y_blocks_max;
- v2s16 sectorpos_base;
- s16 sectorpos_base_size;
- v2s16 sectorpos_bigbase;
- s16 sectorpos_bigbase_size;
- s16 max_spread_amount;
- UniqueQueue<v3s16> transforming_liquid;
-
- ChunkMakeData():
- no_op(false),
- vmanip(NULL),
- seed(0)
- {}
-};
-
-void makeChunk(ChunkMakeData *data);
-#endif
-
-struct BlockMakeData
-{
- bool no_op;
- ManualMapVoxelManipulator vmanip;
- u64 seed;
- v3s16 blockpos;
- UniqueQueue<v3s16> transforming_liquid;
-
- BlockMakeData():
- no_op(false),
- vmanip(NULL),
- seed(0)
- {}
-};
-
-void makeBlock(BlockMakeData *data);
-
#endif
TODO: No perlin noises here, they should be outsourced
and buffered
+ NOTE: The speed of these actually isn't terrible
*/
bool val_is_ground(double ground_noise1_val, v3s16 p, u64 seed)
{
double h = WATER_LEVEL + 10 * noise2d_perlin(
0.5+(float)p.X/250, 0.5+(float)p.Z/250,
seed+84174, 4, 0.5);
+ /*double f = 1;
+ double h = 0;*/
return ((double)p.Y - h < ground_noise1_val * f);
}
/*dstream<<"makeBlock(): ("<<blockpos.X<<","<<blockpos.Y<<","
<<blockpos.Z<<")"<<std::endl;*/
- ManualMapVoxelManipulator &vmanip = data->vmanip;
+ ManualMapVoxelManipulator &vmanip = *(data->vmanip);
v3s16 blockpos_min = blockpos - v3s16(1,1,1);
v3s16 blockpos_max = blockpos + v3s16(1,1,1);
// Area of center block
vmanip.m_data[i] = MapNode(CONTENT_AIR);
}
- data->vmanip.m_area.add_y(em, i, 1);
+ data->vmanip->m_area.add_y(em, i, 1);
}
}
}
vmanip.m_data[i] = MapNode(CONTENT_STONE);
}
- data->vmanip.m_area.add_y(em, i, 1);
+ data->vmanip->m_area.add_y(em, i, 1);
}
}
}
}
}
- data->vmanip.m_area.add_y(em, i, -1);
+ data->vmanip->m_area.add_y(em, i, -1);
}
}
}
&& node_min.Y < approx_groundlevel)
{
// Dungeon generator doesn't modify places which have this set
- data->vmanip.clearFlag(VMANIP_FLAG_DUNGEON_INSIDE
+ data->vmanip->clearFlag(VMANIP_FLAG_DUNGEON_INSIDE
| VMANIP_FLAG_DUNGEON_PRESERVE);
// Set all air and water to be untouchable to make dungeons open
vmanip.m_flags[i] |= VMANIP_FLAG_DUNGEON_PRESERVE;
else if(vmanip.m_data[i].d == CONTENT_WATERSOURCE)
vmanip.m_flags[i] |= VMANIP_FLAG_DUNGEON_PRESERVE;
- data->vmanip.m_area.add_y(em, i, -1);
+ data->vmanip->m_area.add_y(em, i, -1);
}
}
}
PseudoRandom random(blockseed+2);
// Add it
- make_dungeon1(data->vmanip, random);
+ make_dungeon1(vmanip, random);
// Convert some cobble to mossy cobble
for(s16 x=full_node_min.X; x<=full_node_max.X; x++)
if(wetness > 1.2)
vmanip.m_data[i].d = CONTENT_MUD;
}*/
- data->vmanip.m_area.add_y(em, i, -1);
+ data->vmanip->m_area.add_y(em, i, -1);
}
}
}
}
}
- data->vmanip.m_area.add_y(em, i, -1);
+ data->vmanip->m_area.add_y(em, i, -1);
}
}
}
else if(current_depth != 0)
break;
- data->vmanip.m_area.add_y(em, i, -1);
+ data->vmanip->m_area.add_y(em, i, -1);
}
}
}
bool found = false;
for(; p.Y >= y-6; p.Y--)
{
- u32 i = data->vmanip.m_area.index(p);
- MapNode *n = &data->vmanip.m_data[i];
+ u32 i = data->vmanip->m_area.index(p);
+ MapNode *n = &data->vmanip->m_data[i];
if(n->d != CONTENT_AIR && n->d != CONTENT_IGNORE)
{
found = true;
Trees grow only on mud and grass
*/
{
- u32 i = data->vmanip.m_area.index(p);
- MapNode *n = &data->vmanip.m_data[i];
+ u32 i = data->vmanip->m_area.index(p);
+ MapNode *n = &data->vmanip->m_data[i];
if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS)
continue;
}
// Tree will be placed one higher
p.Y++;
// Make a tree
- make_tree(data->vmanip, p);
+ make_tree(vmanip, p);
}
#if 0
v3s16 p(x,y,z);
// Filter placement
/*{
- u32 i = data->vmanip.m_area.index(v3s16(p));
- MapNode *n = &data->vmanip.m_data[i];
+ u32 i = data->vmanip->m_area.index(v3s16(p));
+ MapNode *n = &data->vmanip->m_data[i];
if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS)
continue;
}*/
v3s16 p(x,y,z);
// Filter placement
/*{
- u32 i = data->vmanip.m_area.index(v3s16(p));
- MapNode *n = &data->vmanip.m_data[i];
+ u32 i = data->vmanip->m_area.index(v3s16(p));
+ MapNode *n = &data->vmanip->m_data[i];
if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS)
continue;
}*/
}
+BlockMakeData::BlockMakeData():
+ no_op(false),
+ vmanip(NULL),
+ seed(0)
+{}
+
+BlockMakeData::~BlockMakeData()
+{
+ delete vmanip;
+}
+
}; // namespace mapgen