2024-10-28 15:57:39 +01:00
|
|
|
// Luanti
|
|
|
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
// Copyright (C) 2010-2018 celeron55, Perttu Ahola <celeron55@gmail.com>
|
|
|
|
// Copyright (C) 2015-2018 paramat
|
2013-03-09 21:28:19 -05:00
|
|
|
|
2017-08-17 22:19:39 +02:00
|
|
|
#pragma once
|
2013-03-09 21:28:19 -05:00
|
|
|
|
|
|
|
#include "voxel.h"
|
|
|
|
#include "noise.h"
|
2014-12-06 04:18:04 -05:00
|
|
|
#include "mapgen.h"
|
2013-03-09 21:28:19 -05: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 02:42:27 -05:00
|
|
|
class MMVManip;
|
2018-02-10 22:04:16 +02:00
|
|
|
class NodeDefManager;
|
2013-12-07 22:45:21 -05:00
|
|
|
|
|
|
|
v3s16 rand_ortho_dir(PseudoRandom &random, bool diagonal_dirs);
|
2013-03-09 21:28:19 -05:00
|
|
|
v3s16 turn_xz(v3s16 olddir, int t);
|
2019-04-07 12:08:27 -05:00
|
|
|
void random_turn(PseudoRandom &random, v3s16 &dir);
|
2013-03-09 21:28:19 -05:00
|
|
|
int dir_to_facedir(v3s16 d);
|
|
|
|
|
2013-12-07 22:45:21 -05:00
|
|
|
|
|
|
|
struct DungeonParams {
|
2016-06-04 01:35:37 -04:00
|
|
|
s32 seed;
|
2016-05-22 16:50:43 -04:00
|
|
|
|
2016-06-12 03:11:26 +01:00
|
|
|
content_t c_wall;
|
2019-06-30 22:55:20 +01:00
|
|
|
// Randomly scattered alternative wall nodes
|
2016-06-12 03:11:26 +01:00
|
|
|
content_t c_alt_wall;
|
2013-12-07 22:45:21 -05:00
|
|
|
content_t c_stair;
|
|
|
|
|
2019-07-09 20:38:51 +01:00
|
|
|
// 3D noise that determines which c_wall nodes are converted to c_alt_wall
|
|
|
|
NoiseParams np_alt_wall;
|
|
|
|
|
2019-09-14 23:02:07 +01:00
|
|
|
// Number of dungeons generated in mapchunk. All will use the same set of
|
|
|
|
// dungeonparams.
|
2019-07-09 20:38:51 +01:00
|
|
|
u16 num_dungeons;
|
|
|
|
// Dungeons only generate in ground
|
2017-02-21 01:56:34 +00:00
|
|
|
bool only_in_ground;
|
2019-07-09 20:38:51 +01:00
|
|
|
// Number of rooms
|
|
|
|
u16 num_rooms;
|
|
|
|
// Room size random range. Includes walls / floor / ceilng
|
|
|
|
v3s16 room_size_min;
|
|
|
|
v3s16 room_size_max;
|
2019-07-16 20:39:58 +01:00
|
|
|
// Large room size random range. Includes walls / floor / ceilng
|
|
|
|
v3s16 room_size_large_min;
|
|
|
|
v3s16 room_size_large_max;
|
|
|
|
// Value 0 disables large rooms.
|
|
|
|
// Value 1 results in 1 large room, the first generated room.
|
|
|
|
// Value > 1 makes the first generated room large, all other rooms have a
|
|
|
|
// '1 in value' chance of being large.
|
|
|
|
u16 large_room_chance;
|
2019-06-30 22:55:20 +01:00
|
|
|
// Dimensions of 3D 'brush' that creates corridors.
|
|
|
|
// Dimensions are of the empty space, not including walls / floor / ceilng.
|
2019-09-14 23:02:07 +01:00
|
|
|
// Diagonal corridors must have hole width >=2 to be passable.
|
|
|
|
// Currently, hole width >= 3 causes stair corridor bugs.
|
2013-12-07 22:45:21 -05:00
|
|
|
v3s16 holesize;
|
2019-07-09 20:38:51 +01:00
|
|
|
// Corridor length random range
|
2017-02-21 01:56:34 +00:00
|
|
|
u16 corridor_len_min;
|
|
|
|
u16 corridor_len_max;
|
2019-09-14 23:02:07 +01:00
|
|
|
// Diagonal corridors are possible, 1 in 4 corridors will be diagonal
|
2019-07-09 20:38:51 +01:00
|
|
|
bool diagonal_dirs;
|
2019-06-30 22:55:20 +01:00
|
|
|
// Usually 'GENNOTIFY_DUNGEON', but mapgen v6 uses 'GENNOTIFY_TEMPLE' for
|
|
|
|
// desert dungeons.
|
2016-06-12 03:11:26 +01:00
|
|
|
GenNotifyType notifytype;
|
2013-12-07 22:45:21 -05:00
|
|
|
};
|
|
|
|
|
2013-03-09 21:28:19 -05:00
|
|
|
class DungeonGen {
|
|
|
|
public:
|
2018-09-23 20:12:39 +01:00
|
|
|
MMVManip *vm = nullptr;
|
2018-02-10 22:04:16 +02:00
|
|
|
const NodeDefManager *ndef;
|
2016-05-22 16:50:43 -04:00
|
|
|
GenerateNotifier *gennotify;
|
|
|
|
|
2013-03-09 21:28:19 -05:00
|
|
|
u32 blockseed;
|
|
|
|
PseudoRandom random;
|
|
|
|
v3s16 csize;
|
2013-12-07 22:45:21 -05:00
|
|
|
|
|
|
|
content_t c_torch;
|
|
|
|
DungeonParams dp;
|
2014-12-06 04:18:04 -05:00
|
|
|
|
2016-05-22 16:50:43 -04:00
|
|
|
// RoomWalker
|
2013-03-09 21:28:19 -05:00
|
|
|
v3s16 m_pos;
|
|
|
|
v3s16 m_dir;
|
|
|
|
|
2018-02-10 22:04:16 +02:00
|
|
|
DungeonGen(const NodeDefManager *ndef,
|
2016-05-22 16:50:43 -04:00
|
|
|
GenerateNotifier *gennotify, DungeonParams *dparams);
|
|
|
|
|
2019-07-09 20:38:51 +01:00
|
|
|
void generate(MMVManip *vm, u32 bseed, v3s16 full_node_min, v3s16 full_node_max);
|
2014-12-06 04:18:04 -05:00
|
|
|
|
2013-03-09 21:28:19 -05:00
|
|
|
void makeDungeon(v3s16 start_padding);
|
|
|
|
void makeRoom(v3s16 roomsize, v3s16 roomplace);
|
|
|
|
void makeCorridor(v3s16 doorplace, v3s16 doordir,
|
2016-05-22 16:50:43 -04:00
|
|
|
v3s16 &result_place, v3s16 &result_dir);
|
2013-03-09 21:28:19 -05: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 04:18:04 -05:00
|
|
|
|
2016-05-22 16:50:43 -04:00
|
|
|
inline void randomizeDir()
|
2013-03-09 21:28:19 -05:00
|
|
|
{
|
2013-12-07 22:45:21 -05:00
|
|
|
m_dir = rand_ortho_dir(random, dp.diagonal_dirs);
|
2013-03-09 21:28:19 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-12-07 22:45:21 -05:00
|
|
|
extern NoiseParams nparams_dungeon_density;
|
2016-06-12 03:11:26 +01:00
|
|
|
extern NoiseParams nparams_dungeon_alt_wall;
|