aboutsummaryrefslogtreecommitdiff
path: root/util
Commit message (Expand)AuthorAge
...
* Fix clang-format Columns WidthLoic Blot2017-03-31
* clang-format: add a whitelist (#5459)Loïc Blot2017-03-27
* clang-format: fix counter increment & output (#5456)Loïc Blot2017-03-26
* clang-format: limit diff to 50 files to prevent exceding the maximum travis o...Loïc Blot2017-03-26
* Add clang format & skip build if no source file modified (#5433)Loïc Blot2017-03-25
* CI: Add memleak checking using valgrind (#5350)Loïc Blot2017-03-06
* Travis: Build server too for UNIXLoïc Blot2017-01-04
* Buildbot: Update Gettext version (#4971)sfan52016-12-29
* Buildbot: Update LuaJIT versionsfan52016-12-08
* Travis: Only trigger a compile, when C/C++ related files were touched (#4284)Tim2016-10-15
* Fix macosx build by disabling postgresql upgradeLoic Blot2016-10-06
* Travis: build matrix improvements + CPP11 buildLoic Blot2016-10-06
* Update library versions in buildbotsfan52016-09-21
* buildbot: retrieve short commit hash properlyFernando Carmona Varo2016-07-29
* Implement a PostgreSQL backendLoic Blot2016-05-22
* Upgrade Android build to Gradle build systemShadowNinja2016-04-28
* Tweak travis scriptShadowNinja2016-03-19
* Implement OSX Travis buildsPavel Puchkin2016-02-04
* Update URLs for buildbot & travissfan52015-12-26
* Make travis work againest312015-12-05
* Re-add "file" type for --add-location for xgettext callest312015-10-17
* New settings tab contain all possible settingsPilzAdam2015-10-17
* Don't add line number to comment when running updatepo.shest312015-09-02
* Add fgettext_ne as keyword to updatepo.shest312015-08-25
* Update toolchain_mingw64.cmakeRui2015-07-18
* Add LibGMPest312015-05-11
* Replaced libjpeg dependency on apt-get, it should be libjpeg-dev instead of l...Megaf2015-05-11
* Make Git version detection use VERSION_STRING instead of tagsShadowNinja2015-05-05
* Clean up and tweak build systemShadowNinja2015-03-27
* Rename --do-unittests to --run-unittests as @Zeno- and @sfan5 requestedLoic Blot2015-02-24
* Unit tests must be done at integration process.Loic Blot2015-02-21
* Add LevelDB and redis to Travis Linux buildssfan52015-02-16
* Reduce gettext wide/narrow and string/char* conversionsShadowNinja2015-02-05
* Add wstrgettext to list of translation update keywordsShadowNinja2015-02-05
* Add SQLite3 libraries to buildbotsfan52015-01-08
* Fix buildbot (was broken by 04a1a446cf845a0db80d39fd0e42771aa07e4492)sfan52015-01-06
* Add util/bump_version.shKahrl2014-12-30
* Update MinGW toolchain downloads used by travissfan52014-12-23
* Build for win32 & win64 on Travis toosfan52014-12-06
* Update the cURL the buildbot uses to 7.38.0sfan52014-10-19
* updatepo.sh: Find all filesDiego Martínez2014-09-30
* Add ZLIBWAPI_DLL and LEVELDB_DLL CMake options Remove legacy MINGWM10_DLL CMa...sfan52014-07-29
* Move master server to seperate repositoryShadowNinja2014-06-30
* Masterserver: Fix compiling servers.jstproller2014-06-30
* Masterserver: Fix undefined playersproller2014-06-28
* Update buildbot scripts and add 64-bit buildbotsfan52014-06-18
* Fix null string escapeproller2014-02-24
* Send long announce as POST, show OS in useragentproller2014-01-07
* Rename names -> can_see_far_names in announceproller2013-12-03
* Remove link to #, add unlimited_player_transfer_distance to announceproller2013-12-03
span>(server, OBJDEF_BIOME) { m_server = server; // Create default biome to be used in case none exist Biome *b = new Biome; b->name = "default"; b->flags = 0; b->depth_top = 0; b->depth_filler = -MAX_MAP_GENERATION_LIMIT; b->depth_water_top = 0; b->depth_riverbed = 0; b->min_pos = v3s16(-MAX_MAP_GENERATION_LIMIT, -MAX_MAP_GENERATION_LIMIT, -MAX_MAP_GENERATION_LIMIT); b->max_pos = v3s16(MAX_MAP_GENERATION_LIMIT, MAX_MAP_GENERATION_LIMIT, MAX_MAP_GENERATION_LIMIT); b->heat_point = 0.0; b->humidity_point = 0.0; b->vertical_blend = 0; b->m_nodenames.emplace_back("mapgen_stone"); b->m_nodenames.emplace_back("mapgen_stone"); b->m_nodenames.emplace_back("mapgen_stone"); b->m_nodenames.emplace_back("mapgen_water_source"); b->m_nodenames.emplace_back("mapgen_water_source"); b->m_nodenames.emplace_back("mapgen_river_water_source"); b->m_nodenames.emplace_back("mapgen_stone"); b->m_nodenames.emplace_back("ignore"); b->m_nodenames.emplace_back("ignore"); b->m_nnlistsizes.push_back(1); b->m_nodenames.emplace_back("ignore"); b->m_nodenames.emplace_back("ignore"); b->m_nodenames.emplace_back("ignore"); m_ndef->pendNodeResolve(b); add(b); } void BiomeManager::clear() { EmergeManager *emerge = m_server->getEmergeManager(); // Remove all dangling references in Decorations DecorationManager *decomgr = emerge->decomgr; for (size_t i = 0; i != decomgr->getNumObjects(); i++) { Decoration *deco = (Decoration *)decomgr->getRaw(i); deco->biomes.clear(); } // Don't delete the first biome for (size_t i = 1; i < m_objects.size(); i++) delete (Biome *)m_objects[i]; m_objects.resize(1); } // For BiomeGen type 'BiomeGenOriginal' float BiomeManager::getHeatAtPosOriginal(v3s16 pos, NoiseParams &np_heat, NoiseParams &np_heat_blend, u64 seed) { return NoisePerlin2D(&np_heat, pos.X, pos.Z, seed) + NoisePerlin2D(&np_heat_blend, pos.X, pos.Z, seed); } // For BiomeGen type 'BiomeGenOriginal' float BiomeManager::getHumidityAtPosOriginal(v3s16 pos, NoiseParams &np_humidity, NoiseParams &np_humidity_blend, u64 seed) { return NoisePerlin2D(&np_humidity, pos.X, pos.Z, seed) + NoisePerlin2D(&np_humidity_blend, pos.X, pos.Z, seed); } // For BiomeGen type 'BiomeGenOriginal' Biome *BiomeManager::getBiomeFromNoiseOriginal(float heat, float humidity, v3s16 pos) { Biome *biome_closest = nullptr; Biome *biome_closest_blend = nullptr; float dist_min = FLT_MAX; float dist_min_blend = FLT_MAX; for (size_t i = 1; i < getNumObjects(); i++) { Biome *b = (Biome *)getRaw(i); if (!b || pos.Y < b->min_pos.Y || pos.Y > b->max_pos.Y + b->vertical_blend || pos.X < b->min_pos.X || pos.X > b->max_pos.X || pos.Z < b->min_pos.Z || pos.Z > b->max_pos.Z) continue; float d_heat = heat - b->heat_point; float d_humidity = humidity - b->humidity_point; float dist = (d_heat * d_heat) + (d_humidity * d_humidity); if (pos.Y <= b->max_pos.Y) { // Within y limits of biome b if (dist < dist_min) { dist_min = dist; biome_closest = b; } } else if (dist < dist_min_blend) { // Blend area above biome b dist_min_blend = dist; biome_closest_blend = b; } } mysrand(pos.Y + (heat + humidity) * 0.9f); if (biome_closest_blend && dist_min_blend <= dist_min && myrand_range(0, biome_closest_blend->vertical_blend) >= pos.Y - biome_closest_blend->max_pos.Y) return biome_closest_blend; return (biome_closest) ? biome_closest : (Biome *)getRaw(BIOME_NONE); } //////////////////////////////////////////////////////////////////////////////// void BiomeParamsOriginal::readParams(const Settings *settings) { settings->getNoiseParams("mg_biome_np_heat", np_heat); settings->getNoiseParams("mg_biome_np_heat_blend", np_heat_blend); settings->getNoiseParams("mg_biome_np_humidity", np_humidity); settings->getNoiseParams("mg_biome_np_humidity_blend", np_humidity_blend); } void BiomeParamsOriginal::writeParams(Settings *settings) const { settings->setNoiseParams("mg_biome_np_heat", np_heat); settings->setNoiseParams("mg_biome_np_heat_blend", np_heat_blend); settings->setNoiseParams("mg_biome_np_humidity", np_humidity); settings->setNoiseParams("mg_biome_np_humidity_blend", np_humidity_blend); } //////////////////////////////////////////////////////////////////////////////// BiomeGenOriginal::BiomeGenOriginal(BiomeManager *biomemgr, BiomeParamsOriginal *params, v3s16 chunksize) { m_bmgr = biomemgr; m_params = params; m_csize = chunksize; noise_heat = new Noise(&params->np_heat, params->seed, m_csize.X, m_csize.Z); noise_humidity = new Noise(&params->np_humidity, params->seed, m_csize.X, m_csize.Z); noise_heat_blend = new Noise(&params->np_heat_blend, params->seed, m_csize.X, m_csize.Z); noise_humidity_blend = new Noise(&params->np_humidity_blend, params->seed, m_csize.X, m_csize.Z); heatmap = noise_heat->result; humidmap = noise_humidity->result; biomemap = new biome_t[m_csize.X * m_csize.Z]; // Initialise with the ID of 'BIOME_NONE' so that cavegen can get the // fallback biome when biome generation (which calculates the biomemap IDs) // is disabled. memset(biomemap, 0, sizeof(biome_t) * m_csize.X * m_csize.Z); } BiomeGenOriginal::~BiomeGenOriginal() { delete []biomemap; delete noise_heat; delete noise_humidity; delete noise_heat_blend; delete noise_humidity_blend; } // Only usable in a mapgen thread Biome *BiomeGenOriginal::calcBiomeAtPoint(v3s16 pos) const { float heat = NoisePerlin2D(&m_params->np_heat, pos.X, pos.Z, m_params->seed) + NoisePerlin2D(&m_params->np_heat_blend, pos.X, pos.Z, m_params->seed); float humidity = NoisePerlin2D(&m_params->np_humidity, pos.X, pos.Z, m_params->seed) + NoisePerlin2D(&m_params->np_humidity_blend, pos.X, pos.Z, m_params->seed); return calcBiomeFromNoise(heat, humidity, pos); } void BiomeGenOriginal::calcBiomeNoise(v3s16 pmin) { m_pmin = pmin; noise_heat->perlinMap2D(pmin.X, pmin.Z); noise_humidity->perlinMap2D(pmin.X, pmin.Z); noise_heat_blend->perlinMap2D(pmin.X, pmin.Z); noise_humidity_blend->perlinMap2D(pmin.X, pmin.Z); for (s32 i = 0; i < m_csize.X * m_csize.Z; i++) { noise_heat->result[i] += noise_heat_blend->result[i]; noise_humidity->result[i] += noise_humidity_blend->result[i]; } } biome_t *BiomeGenOriginal::getBiomes(s16 *heightmap, v3s16 pmin) { for (s16 zr = 0; zr < m_csize.Z; zr++) for (s16 xr = 0; xr < m_csize.X; xr++) { s32 i = zr * m_csize.X + xr; Biome *biome = calcBiomeFromNoise( noise_heat->result[i], noise_humidity->result[i], v3s16(pmin.X + xr, heightmap[i], pmin.Z + zr)); biomemap[i] = biome->index; } return biomemap; } Biome *BiomeGenOriginal::getBiomeAtPoint(v3s16 pos) const { return getBiomeAtIndex( (pos.Z - m_pmin.Z) * m_csize.X + (pos.X - m_pmin.X), pos); } Biome *BiomeGenOriginal::getBiomeAtIndex(size_t index, v3s16 pos) const { return calcBiomeFromNoise( noise_heat->result[index], noise_humidity->result[index], pos); } Biome *BiomeGenOriginal::calcBiomeFromNoise(float heat, float humidity, v3s16 pos) const { Biome *biome_closest = nullptr; Biome *biome_closest_blend = nullptr; float dist_min = FLT_MAX; float dist_min_blend = FLT_MAX; for (size_t i = 1; i < m_bmgr->getNumObjects(); i++) { Biome *b = (Biome *)m_bmgr->getRaw(i); if (!b || pos.Y < b->min_pos.Y || pos.Y > b->max_pos.Y + b->vertical_blend || pos.X < b->min_pos.X || pos.X > b->max_pos.X || pos.Z < b->min_pos.Z || pos.Z > b->max_pos.Z) continue; float d_heat = heat - b->heat_point; float d_humidity = humidity - b->humidity_point; float dist = (d_heat * d_heat) + (d_humidity * d_humidity); if (pos.Y <= b->max_pos.Y) { // Within y limits of biome b if (dist < dist_min) { dist_min = dist; biome_closest = b; } } else if (dist < dist_min_blend) { // Blend area above biome b dist_min_blend = dist; biome_closest_blend = b; } } // Carefully tune pseudorandom seed variation to avoid single node dither // and create larger scale blending patterns similar to horizontal biome // blend. mysrand(pos.Y + (heat + humidity) * 0.9f); if (biome_closest_blend && dist_min_blend <= dist_min && myrand_range(0, biome_closest_blend->vertical_blend) >= pos.Y - biome_closest_blend->max_pos.Y) return biome_closest_blend; return (biome_closest) ? biome_closest : (Biome *)m_bmgr->getRaw(BIOME_NONE); } //////////////////////////////////////////////////////////////////////////////// void Biome::resolveNodeNames() { getIdFromNrBacklog(&c_top, "mapgen_stone", CONTENT_AIR, false); getIdFromNrBacklog(&c_filler, "mapgen_stone", CONTENT_AIR, false); getIdFromNrBacklog(&c_stone, "mapgen_stone", CONTENT_AIR, false); getIdFromNrBacklog(&c_water_top, "mapgen_water_source", CONTENT_AIR, false); getIdFromNrBacklog(&c_water, "mapgen_water_source", CONTENT_AIR, false); getIdFromNrBacklog(&c_river_water, "mapgen_river_water_source", CONTENT_AIR, false); getIdFromNrBacklog(&c_riverbed, "mapgen_stone", CONTENT_AIR, false); getIdFromNrBacklog(&c_dust, "ignore", CONTENT_IGNORE, false); getIdsFromNrBacklog(&c_cave_liquid); getIdFromNrBacklog(&c_dungeon, "ignore", CONTENT_IGNORE, false); getIdFromNrBacklog(&c_dungeon_alt, "ignore", CONTENT_IGNORE, false); getIdFromNrBacklog(&c_dungeon_stair, "ignore", CONTENT_IGNORE, false); }