aboutsummaryrefslogtreecommitdiff
path: root/src/mapgen_valleys.h
blob: 6dd7ebc47e01ba45b4371d4e51ef23b6633f5be3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
Minetest Valleys C
Copyright (C) 2010-2015 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
Copyright (C) 2010-2015 paramat, Matt Gregory
Copyright (C) 2016 Duane Robertson <duane@duanerobertson.com>

Based on Valleys Mapgen by Gael de Sailly
 (https://forum.minetest.net/viewtopic.php?f=9&t=11430)
and mapgen_v7 by kwolekr and paramat.

Licensing changed by permission of Gael de Sailly.

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.
*/

#ifndef MAPGEN_VALLEYS_HEADER
#define MAPGEN_VALLEYS_HEADER

#include "mapgen.h"

////////////// Mapgen Valleys flags
#define MGVALLEYS_ALT_CHILL    0x01
#define MGVALLEYS_HUMID_RIVERS 0x02

// Feed only one variable into these.
#define MYSQUARE(x) (x) * (x)
#define MYCUBE(x) (x) * (x) * (x)

class BiomeManager;
class BiomeGenOriginal;

// Global profiler
//class Profiler;
//extern Profiler *mapgen_profiler;


struct MapgenValleysParams : public MapgenParams {
	u32 spflags;
	s16 large_cave_depth;
	s16 massive_cave_depth;
	u16 altitude_chill;
	u16 lava_features;
	u16 river_depth;
	u16 river_size;
	u16 water_features;
	float cave_width;
	NoiseParams np_cave1;
	NoiseParams np_cave2;
	NoiseParams np_filler_depth;
	NoiseParams np_inter_valley_fill;
	NoiseParams np_inter_valley_slope;
	NoiseParams np_rivers;
	NoiseParams np_massive_caves;
	NoiseParams np_terrain_height;
	NoiseParams np_valley_depth;
	NoiseParams np_valley_profile;

	MapgenValleysParams();
	~MapgenValleysParams() {}

	void readParams(const Settings *settings);
	void writeParams(Settings *settings) const;
};

struct TerrainNoise {
	s16 x;
	s16 z;
	float terrain_height;
	float *rivers;
	float *valley;
	float valley_profile;
	float *slope;
	float inter_valley_fill;
};

class MapgenValleys : public MapgenBasic {
public:

	MapgenValleys(int mapgenid, MapgenValleysParams *params, EmergeManager *emerge);
	~MapgenValleys();

	virtual MapgenType getType() const { return MAPGEN_VALLEYS; }

	virtual void makeChunk(BlockMakeData *data);
	int getSpawnLevelAtPoint(v2s16 p);

	s16 large_cave_depth;

private:
	BiomeGenOriginal *m_bgen;

	float map_gen_limit;

	bool humid_rivers;
	bool use_altitude_chill;
	float humidity_adjust;
	s16 cave_water_max_height;
	s16 lava_max_height;

	float altitude_chill;
	s16 lava_features_lim;
	s16 massive_cave_depth;
	float river_depth_bed;
	float river_size_factor;
	float *tcave_cache;
	s16 water_features_lim;
	Noise *noise_inter_valley_fill;
	Noise *noise_inter_valley_slope;
	Noise *noise_rivers;
	Noise *noise_cave1;
	Noise *noise_cave2;
	Noise *noise_massive_caves;
	Noise *noise_terrain_height;
	Noise *noise_valley_depth;
	Noise *noise_valley_profile;

	content_t c_lava_source;

	float terrainLevelAtPoint(s16 x, s16 z);

	void calculateNoise();

	virtual int generateTerrain();
	float terrainLevelFromNoise(TerrainNoise *tn);
	float adjustedTerrainLevelFromNoise(TerrainNoise *tn);

	virtual void generateCaves(s16 max_stone_y, s16 large_cave_depth);
};

#endif
kwb">void draw(); //! Sets the new caption of this element. virtual void setText(const wchar_t* text); //! Sets the maximum amount of characters which may be entered in the box. //! \param max: Maximum amount of characters. If 0, the character amount is //! infinity. virtual void setMax(u32 max); //! Returns maximum amount of characters, previously set by setMax(); virtual u32 getMax() const; //! Sets whether the edit box is a password box. Setting this to true will /** disable MultiLine, WordWrap and the ability to copy with ctrl+c or ctrl+x \param passwordBox: true to enable password, false to disable \param passwordChar: the character that is displayed instead of letters */ virtual void setPasswordBox(bool passwordBox, wchar_t passwordChar = L'*'); //! Returns true if the edit box is currently a password box. virtual bool isPasswordBox() const; //! Updates the absolute position, splits text if required virtual void updateAbsolutePosition(); //! Writes attributes of the element. virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; //! Reads attributes of the element virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); protected: //! Breaks the single text line. void breakText(); //! sets the area of the given line void setTextRect(s32 line); //! returns the line number that the cursor is on s32 getLineFromPos(s32 pos); //! adds a letter to the edit box void inputChar(wchar_t c); //! calculates the current scroll position void calculateScrollPos(); //! send some gui event to parent void sendGuiEvent(EGUI_EVENT_TYPE type); //! set text markers void setTextMarkers(s32 begin, s32 end); bool processKey(const SEvent& event); bool processMouse(const SEvent& event); s32 getCursorPos(s32 x, s32 y); bool MouseMarking; bool Border; bool OverrideColorEnabled; s32 MarkBegin; s32 MarkEnd; video::SColor OverrideColor; gui::IGUIFont *OverrideFont, *LastBreakFont; IOSOperator* Operator; u32 BlinkStartTime; s32 CursorPos; s32 HScrollPos, VScrollPos; // scroll position in characters u32 Max; bool WordWrap, MultiLine, AutoScroll, PasswordBox; wchar_t PasswordChar; EGUI_ALIGNMENT HAlign, VAlign; core::array< core::stringw > BrokenText; core::array< s32 > BrokenTextPositions; core::rect<s32> CurrentTextRect, FrameRect; // temporary values }; } // end namespace gui } // end namespace irr //#endif // _IRR_COMPILE_WITH_GUI_ #endif // __C_GUI_EDIT_BOX_H_INCLUDED__