aboutsummaryrefslogtreecommitdiff
path: root/advtrains
Commit message (Collapse)AuthorAge
* Add speed as number in km/h to train hudlemon-melon2017-07-15
|
* Add m/s to km/h helper functionlemon-melon2017-07-15
|
* Add command to throw all players out of trains, fixes #78orwell962017-06-12
|
* Fix broken door animations caused by continuous set_object_properties() ↵orwell962017-06-08
| | | | | | messages sent to client ... which each time caused the animation to be reset
* lower capacity of freight carsorwell962017-06-08
|
* Change log level of save_all message to atprint()orwell962017-06-08
|
* Do not clear the F table when running the init code failsorwell962017-06-08
|
* Merge pull request #67 from AntumDeluge/settingsorwell962017-06-08
|\ | | | | Replace deprecated methods
| * Replace deprecated methods:AntumDeluge2017-06-07
| | | | | | | | - 'setting_get' with 'settings:get' - 'setting_getbool' with 'settings:get_bool'
* | Check if 'digtron' global exists before calling in condition:AntumDeluge2017-06-07
|/ | | Fixes 'Undeclared global variable "digtron"'.
* Add loading/unloading rails (#63)gpcf2017-05-31
| | | | Pull request by gpcf Will update zip file with next release
* Fix still broken ndb restoring, and make sid() honor nil valuesorwell962017-05-31
|
* Fix detector rails changing to default orientationorwell962017-05-30
| | | | Release 1.8.1
* Re-add option for debugging features and add option to disable collisionsorwell962017-05-30
|
* Fix collision bug (trains driving through each other)orwell962017-05-30
|
* Re-add debug ring buffer and print its contents on a lua crashorwell962017-05-30
| | | | | When the crash on linuxworks has been fixed, the ringbuffer will go into master and behind an option also fix last commit
* Fix command + Update zip file - Version 1.8orwell962017-05-22
|
* Add Digtron compatibilityorwell962017-05-22
| | | | Override digtron's item-place function to be able to place tracks with digtrons.
* Fix some 'undeclared assignment' warningsorwell962017-05-22
|
* Fix Syntax Errororwell962017-05-22
|
* Fix issue #40orwell962017-05-22
| | | | Was caused by arrowconn not being set. Instructs user to revisit.
* Remove the debug settingorwell962017-05-22
|
* Fix a series of bugsorwell962017-05-22
| | | | | | | | - Prevent min_iot from becoming a comma value, which caused a major problem on the linuxworks server - Fix previous commit - also restore the nodedb file after a crash Other changes: - add chatcommand to update the nodedb after using WorldEdit
* Don't invoke conway on a path item that has been over-generatedorwell962017-05-15
| | | | This breaks ATC systems that are based on wronly switched switches, but fixes a series of bugs (esp. setting train recovery positions at a place where no tracks are)
* write the saved nodedb state back to the map when restoring after a crashorwell962017-05-12
| | | | | also, print a complete stack trace when an error happens also, don't replace nodes in the nodedb when worldedit has been used
* Remove pos_to_string whereever possible to prevent crashesorwell962017-05-12
|
* Relicensing media under CC-BY-SAorwell962017-05-04
|
* Performance improvements: Don't clear paths unless absolutely necessaryorwell962017-05-03
| | | | | instead delete path elements that are too far from the train one-by-one Also when switching a switch or changing rails, only clear train paths of trains that are nearby.
* Merge nocrash branch into master and merging it with the unified functions ↵orwell962017-04-29
|\ | | | | | | | | | | so that restoring works how it should Also fix minor bugs and an occasional crash with couples
| * Add pcall wrapper to prevent server crashes when advtrains throws an errororwell962017-04-29
| | | | | | | | | | Instead, read save files again and restore state before the crash Rebased to latest commit
* | Unify globalstep, load and save of all components into single functionsorwell962017-04-29
|/
* Add Andrew's Crossorwell962017-04-27
|
* Fix bug introduced by last commit (revert change)orwell962017-04-12
|
* Add privilege for basic train operation.orwell962017-04-09
| | | | This privilege is granted to singleplayer by default, but is not granted on servers. This prevents unexperienced or evil players from breaking automatic train operation on servers.
* record_protection_violation: fix player name not being passedorwell962017-04-07
|
* Fix #59orwell962017-04-05
|
* Actually check for protection when placing trains and use the train_place ↵orwell962017-04-02
| | | | privilege
* Assert some variable types obtained from lua automationorwell962017-03-30
|
* Add support to display text to passengers and on the outside of the trainorwell962017-03-30
| | | | | Outside is currently displayed as infotext. TODO: signs-like draw it on the wagon FIXME: When object properties are set, for some reason the animation restarts
* Respect protection_bypass privilege, fix crash with areas and properly ↵orwell962017-03-30
| | | | record protection violations
* Fix privilege enforcement being uselessorwell962017-03-16
| | | | Privilege violations caused an error message but didn't abort the operation
* Fix Atc arrows pointing into wrong directionorwell962017-03-12
|
* Screw buttonlike rules for wall signals and use regular rules.orwell962017-03-12
|
* Redo rail modelsorwell962017-03-12
| | | | Use multiple textures for slope objects, include mbb's rail textures and make curves and switches look better. Also add cable template.
* Don't drop items in creative mode when player gets overrun by trainorwell962017-03-11
|
* "Sneak" instead of "Shift" for the sneak keyorwell962017-03-09
|
* Update manual and include everything in repoorwell962017-03-09
|
* Improve debug outputs of couples and increase maximum distanceorwell962017-03-03
|
* Only get on by walking in when there's a platform, improve get off handlingorwell962017-02-28
|
* Add passive component namingorwell962017-02-28
|
n868' href='#n868'>868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914
/*
Minetest
Copyright (C) 2010-2018 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2010-2018 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
Copyright (C) 2015-2018 paramat

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "util/numeric.h"
#include <cmath>
#include "map.h"
#include "mapgen.h"
#include "mapgen_v5.h"
#include "mapgen_v6.h"
#include "mapgen_v7.h"
#include "mg_biome.h"
#include "cavegen.h"

// TODO Remove this. Cave liquids are now defined and located using biome definitions
static NoiseParams nparams_caveliquids(0, 1, v3f(150.0, 150.0, 150.0), 776, 3, 0.6, 2.0);


////
//// CavesNoiseIntersection
////

CavesNoiseIntersection::CavesNoiseIntersection(
	const NodeDefManager *nodedef, BiomeManager *biomemgr, v3s16 chunksize,
	NoiseParams *np_cave1, NoiseParams *np_cave2, s32 seed, float cave_width)
{
	assert(nodedef);
	assert(biomemgr);

	m_ndef = nodedef;
	m_bmgr = biomemgr;

	m_csize = chunksize;
	m_cave_width = cave_width;

	m_ystride    = m_csize.X;
	m_zstride_1d = m_csize.X * (m_csize.Y + 1);

	// Noises are created using 1-down overgeneration
	// A Nx-by-1-by-Nz-sized plane is at the bottom of the desired for
	// re-carving the solid overtop placed for blocking sunlight
	noise_cave1 = new Noise(np_cave1, seed, m_csize.X, m_csize.Y + 1, m_csize.Z);
	noise_cave2 = new Noise(np_cave2, seed, m_csize.X, m_csize.Y + 1, m_csize.Z);
}


CavesNoiseIntersection::~CavesNoiseIntersection()
{
	delete noise_cave1;
	delete noise_cave2;
}


void CavesNoiseIntersection::generateCaves(MMVManip *vm,
	v3s16 nmin, v3s16 nmax, u8 *biomemap)
{
	assert(vm);
	assert(biomemap);

	noise_cave1->perlinMap3D(nmin.X, nmin.Y - 1, nmin.Z);
	noise_cave2->perlinMap3D(nmin.X, nmin.Y - 1, nmin.Z);

	const v3s16 &em = vm->m_area.getExtent();
	u32 index2d = 0;  // Biomemap index

	for (s16 z = nmin.Z; z <= nmax.Z; z++)
	for (s16 x = nmin.X; x <= nmax.X; x++, index2d++) {
		bool column_is_open = false;  // Is column open to overground
		bool is_under_river = false;  // Is column under river water
		bool is_under_tunnel = false;  // Is tunnel or is under tunnel
		bool is_top_filler_above = false;  // Is top or filler above node
		// Indexes at column top
		u32 vi = vm->m_area.index(x, nmax.Y, z);
		u32 index3d = (z - nmin.Z) * m_zstride_1d + m_csize.Y * m_ystride +
			(x - nmin.X);  // 3D noise index
		// Biome of column
		Biome *biome = (Biome *)m_bmgr->getRaw(biomemap[index2d]);
		u16 depth_top = biome->depth_top;
		u16 base_filler = depth_top + biome->depth_filler;
		u16 depth_riverbed = biome->depth_riverbed;
		u16 nplaced = 0;
		// Don't excavate the overgenerated stone at nmax.Y + 1,
		// this creates a 'roof' over the tunnel, preventing light in
		// tunnels at mapchunk borders when generating mapchunks upwards.
		// This 'roof' is removed when the mapchunk above is generated.
		for (s16 y = nmax.Y; y >= nmin.Y - 1; y--,
				index3d -= m_ystride,
				VoxelArea::add_y(em, vi, -1)) {
			content_t c = vm->m_data[vi].getContent();

			if (c == CONTENT_AIR || c == biome->c_water_top ||
					c == biome->c_water) {
				column_is_open = true;
				is_top_filler_above = false;
				continue;
			}

			if (c == biome->c_river_water) {
				column_is_open = true;
				is_under_river = true;
				is_top_filler_above = false;
				continue;
			}

			// Ground
			float d1 = contour(noise_cave1->result[index3d]);
			float d2 = contour(noise_cave2->result[index3d]);

			if (d1 * d2 > m_cave_width && m_ndef->get(c).is_ground_content) {
				// In tunnel and ground content, excavate
				vm->m_data[vi] = MapNode(CONTENT_AIR);
				is_under_tunnel = true;
				// If tunnel roof is top or filler, replace with stone
				if (is_top_filler_above)
					vm->m_data[vi + em.X] = MapNode(biome->c_stone);
				is_top_filler_above = false;
			} else if (column_is_open && is_under_tunnel &&
					(c == biome->c_stone || c == biome->c_filler)) {
				// Tunnel entrance floor, place biome surface nodes
				if (is_under_river) {
					if (nplaced < depth_riverbed) {
						vm->m_data[vi] = MapNode(biome->c_riverbed);
						is_top_filler_above = true;
						nplaced++;
					} else {
						// Disable top/filler placement
						column_is_open = false;
						is_under_river = false;
						is_under_tunnel = false;
					}
				} else if (nplaced < depth_top) {
					vm->m_data[vi] = MapNode(biome->c_top);
					is_top_filler_above = true;
					nplaced++;
				} else if (nplaced < base_filler) {
					vm->m_data[vi] = MapNode(biome->c_filler);
					is_top_filler_above = true;
					nplaced++;
				} else {
					// Disable top/filler placement
					column_is_open = false;
					is_under_tunnel = false;
				}
			} else {
				// Not tunnel or tunnel entrance floor
				// Check node for possible replacing with stone for tunnel roof
				if (c == biome->c_top || c == biome->c_filler)
					is_top_filler_above = true;