#include "server.h"
#include <iostream>
#include <queue>
+#include "jthread/jevent.h"
#include "map.h"
#include "environment.h"
#include "util/container.h"
mapgen_debug_info = g_settings->getBool("enable_mapgen_debug_info");
- queuemutex.Init();
int nthreads;
if (g_settings->get("num_emerge_threads").empty()) {
if (!mgparams)
return NULL;
+ std::string seedstr = settings->get(settings == g_settings ?
+ "fixed_map_seed" : "seed");
+
mgparams->mg_name = mg_name;
- mgparams->seed = settings->getU64(settings == g_settings ? "fixed_map_seed" : "seed");
+ mgparams->seed = read_seed(seedstr.c_str());
mgparams->water_level = settings->getS16("water_level");
mgparams->chunksize = settings->getS16("chunksize");
mgparams->flags = settings->getFlagStr("mg_flags", flagdesc_mapgen);
}
-////////////////////////////// Emerge Thread //////////////////////////////////
+////////////////////////////// Emerge Thread //////////////////////////////////
bool EmergeThread::popBlockEmerge(v3s16 *pos, u8 *flags) {
std::map<v3s16, BlockEmergeData *>::iterator iter;
*pos = p;
iter = emerge->blocks_enqueued.find(p);
- if (iter == emerge->blocks_enqueued.end())
+ if (iter == emerge->blocks_enqueued.end())
return false; //uh oh, queue and map out of sync!!
BlockEmergeData *bedata = iter->second;
}
-bool EmergeThread::getBlockOrStartGen(v3s16 p, MapBlock **b,
+bool EmergeThread::getBlockOrStartGen(v3s16 p, MapBlock **b,
BlockMakeData *data, bool allow_gen) {
v2s16 p2d(p.X, p.Z);
//envlock: usually takes <=1ms, sometimes 90ms or ~400ms to acquire
- JMutexAutoLock envlock(m_server->m_env_mutex);
+ JMutexAutoLock envlock(m_server->m_env_mutex);
// Load sector if it isn't loaded
if (map->getSectorNoGenerateNoEx(p2d) == NULL)
if (!block || block->isDummy() || !block->isGenerated()) {
EMERGE_DBG_OUT("not in memory, attempting to load from disk");
block = map->loadBlock(p);
+ if (block && block->isGenerated())
+ map->prepareBlock(block);
}
// If could not load and allowed to generate,
{
//envlock: usually 0ms, but can take either 30 or 400ms to acquire
- JMutexAutoLock envlock(m_server->m_env_mutex);
+ JMutexAutoLock envlock(m_server->m_env_mutex);
ScopeProfiler sp(g_profiler, "EmergeThread: after "
"Mapgen::makeChunk (envlock)", SPT_AVG);
// Ignore map edit events, they will not need to be sent
// to anybody because the block hasn't been sent to anybody
- MapEditEventAreaIgnorer
+ MapEditEventAreaIgnorer
ign(&m_server->m_ignore_map_edit_events_area,
VoxelArea(minp, maxp));
{ // takes about 90ms with -O1 on an e3-1230v2
- m_server->getScriptIface()->
- environment_OnGenerated(
+ m_server->getScriptIface()->environment_OnGenerated(
minp, maxp, emerge->getBlockSeed(minp));
}
if (block)
modified_blocks[p] = block;
- // Update weather data in mapblock
- for(std::map<v3s16, MapBlock *>::iterator
- i = modified_blocks.begin();
- i != modified_blocks.end(); ++i) {
- map->getHeat(m_server->m_env, MAP_BLOCKSIZE*i->first ,i->second);
- map->getHumidity(m_server->m_env, MAP_BLOCKSIZE*i->first, i->second);
- }
-
// Set the modified blocks unsent for all the clients
for (std::map<u16, RemoteClient*>::iterator
i = m_server->m_clients.begin();