2013-03-10 03:28:19 +01:00
|
|
|
/*
|
|
|
|
Minetest
|
2018-01-15 03:26:15 +01:00
|
|
|
Copyright (C) 2010-2018 celeron55, Perttu Ahola <celeron55@gmail.com>
|
|
|
|
Copyright (C) 2015-2018 paramat
|
2013-03-10 03:28:19 +01:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2017-08-17 22:19:39 +02:00
|
|
|
#pragma once
|
2013-03-10 03:28:19 +01:00
|
|
|
|
|
|
|
#include "voxel.h"
|
|
|
|
#include "noise.h"
|
2014-12-06 10:18:04 +01:00
|
|
|
#include "mapgen.h"
|
2013-03-10 03:28:19 +01:00
|
|
|
|
|
|
|
#define VMANIP_FLAG_DUNGEON_INSIDE VOXELFLAG_CHECKED1
|
|
|
|
#define VMANIP_FLAG_DUNGEON_PRESERVE VOXELFLAG_CHECKED2
|
|
|
|
#define VMANIP_FLAG_DUNGEON_UNTOUCHABLE (\
|
|
|
|
VMANIP_FLAG_DUNGEON_INSIDE|VMANIP_FLAG_DUNGEON_PRESERVE)
|
|
|
|
|
2015-01-05 08:42:27 +01:00
|
|
|
class MMVManip;
|
2018-02-10 21:04:16 +01:00
|
|
|
class NodeDefManager;
|
2013-12-08 04:45:21 +01:00
|
|
|
|
|
|
|
v3s16 rand_ortho_dir(PseudoRandom &random, bool diagonal_dirs);
|
2013-03-10 03:28:19 +01:00
|
|
|
v3s16 turn_xz(v3s16 olddir, int t);
|
|
|
|
v3s16 random_turn(PseudoRandom &random, v3s16 olddir);
|
|
|
|
int dir_to_facedir(v3s16 d);
|
|
|
|
|
2013-12-08 04:45:21 +01:00
|
|
|
|
|
|
|
struct DungeonParams {
|
2016-06-04 07:35:37 +02:00
|
|
|
s32 seed;
|
2016-05-22 22:50:43 +02:00
|
|
|
|
2016-06-12 04:11:26 +02:00
|
|
|
content_t c_wall;
|
|
|
|
content_t c_alt_wall;
|
2013-12-08 04:45:21 +01:00
|
|
|
content_t c_stair;
|
|
|
|
|
|
|
|
bool diagonal_dirs;
|
2017-02-21 02:56:34 +01:00
|
|
|
bool only_in_ground;
|
2013-12-08 04:45:21 +01:00
|
|
|
v3s16 holesize;
|
2017-02-21 02:56:34 +01:00
|
|
|
u16 corridor_len_min;
|
|
|
|
u16 corridor_len_max;
|
|
|
|
v3s16 room_size_min;
|
|
|
|
v3s16 room_size_max;
|
|
|
|
v3s16 room_size_large_min;
|
|
|
|
v3s16 room_size_large_max;
|
2016-06-12 04:11:26 +02:00
|
|
|
u16 rooms_min;
|
|
|
|
u16 rooms_max;
|
|
|
|
GenNotifyType notifytype;
|
2013-12-08 04:45:21 +01:00
|
|
|
|
|
|
|
NoiseParams np_density;
|
2016-06-12 04:11:26 +02:00
|
|
|
NoiseParams np_alt_wall;
|
2013-12-08 04:45:21 +01:00
|
|
|
};
|
|
|
|
|
2013-03-10 03:28:19 +01:00
|
|
|
class DungeonGen {
|
|
|
|
public:
|
2015-01-05 08:42:27 +01:00
|
|
|
MMVManip *vm;
|
2018-02-10 21:04:16 +01:00
|
|
|
const NodeDefManager *ndef;
|
2016-05-22 22:50:43 +02:00
|
|
|
GenerateNotifier *gennotify;
|
|
|
|
|
2013-03-10 03:28:19 +01:00
|
|
|
u32 blockseed;
|
|
|
|
PseudoRandom random;
|
|
|
|
v3s16 csize;
|
2013-12-08 04:45:21 +01:00
|
|
|
|
|
|
|
content_t c_torch;
|
|
|
|
DungeonParams dp;
|
2014-12-06 10:18:04 +01:00
|
|
|
|
2016-05-22 22:50:43 +02:00
|
|
|
// RoomWalker
|
2013-03-10 03:28:19 +01:00
|
|
|
v3s16 m_pos;
|
|
|
|
v3s16 m_dir;
|
|
|
|
|
2018-02-10 21:04:16 +01:00
|
|
|
DungeonGen(const NodeDefManager *ndef,
|
2016-05-22 22:50:43 +02:00
|
|
|
GenerateNotifier *gennotify, DungeonParams *dparams);
|
|
|
|
|
|
|
|
void generate(MMVManip *vm, u32 bseed,
|
|
|
|
v3s16 full_node_min, v3s16 full_node_max);
|
2014-12-06 10:18:04 +01:00
|
|
|
|
2013-03-10 03:28:19 +01:00
|
|
|
void makeDungeon(v3s16 start_padding);
|
|
|
|
void makeRoom(v3s16 roomsize, v3s16 roomplace);
|
|
|
|
void makeCorridor(v3s16 doorplace, v3s16 doordir,
|
2016-05-22 22:50:43 +02:00
|
|
|
v3s16 &result_place, v3s16 &result_dir);
|
2013-03-10 03:28:19 +01:00
|
|
|
void makeDoor(v3s16 doorplace, v3s16 doordir);
|
|
|
|
void makeFill(v3s16 place, v3s16 size, u8 avoid_flags, MapNode n, u8 or_flags);
|
|
|
|
void makeHole(v3s16 place);
|
|
|
|
|
|
|
|
bool findPlaceForDoor(v3s16 &result_place, v3s16 &result_dir);
|
|
|
|
bool findPlaceForRoomDoor(v3s16 roomsize, v3s16 &result_doorplace,
|
|
|
|
v3s16 &result_doordir, v3s16 &result_roomplace);
|
2014-12-06 10:18:04 +01:00
|
|
|
|
2016-05-22 22:50:43 +02:00
|
|
|
inline void randomizeDir()
|
2013-03-10 03:28:19 +01:00
|
|
|
{
|
2013-12-08 04:45:21 +01:00
|
|
|
m_dir = rand_ortho_dir(random, dp.diagonal_dirs);
|
2013-03-10 03:28:19 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-12-08 04:45:21 +01:00
|
|
|
extern NoiseParams nparams_dungeon_density;
|
2016-06-12 04:11:26 +02:00
|
|
|
extern NoiseParams nparams_dungeon_alt_wall;
|