From 6cd00aacfa22fed6a54a9b812f6b069ad16feec0 Mon Sep 17 00:00:00 2001 From: untodesu Date: Sun, 29 Jun 2025 22:24:42 +0500 Subject: Move game sources into src subdirectory --- src/game/server/overworld.hh | 63 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/game/server/overworld.hh (limited to 'src/game/server/overworld.hh') diff --git a/src/game/server/overworld.hh b/src/game/server/overworld.hh new file mode 100644 index 0000000..972a91d --- /dev/null +++ b/src/game/server/overworld.hh @@ -0,0 +1,63 @@ +#ifndef SERVER_OVERWORLD_HH +#define SERVER_OVERWORLD_HH 1 +#pragma once + +#include "core/config.hh" + +#include "shared/const.hh" +#include "shared/dimension.hh" +#include "shared/feature.hh" + +constexpr static unsigned int OW_NUM_TREES = 4U; + +struct Overworld_Metadata final { + dimension_entropy_map entropy; + dimension_height_map heightmap; + std::vector trees; +}; + +class Overworld final : public Dimension { +public: + explicit Overworld(const char* name); + virtual ~Overworld(void) = default; + +public: + virtual void init(Config& config) override; + virtual void init_late(std::uint64_t global_seed) override; + virtual bool generate(const chunk_pos& cpos, VoxelStorage& voxels) override; + +private: + bool is_inside_cave(const voxel_pos& vpos); + bool is_inside_terrain(const voxel_pos& vpos); + +private: + const Overworld_Metadata& get_or_create_metadata(const chunk_pos_xz& cpos); + +private: + void generate_terrain(const chunk_pos& cpos, VoxelStorage& voxels); + void generate_surface(const chunk_pos& cpos, VoxelStorage& voxels); + void generate_caves(const chunk_pos& cpos, VoxelStorage& voxels); + void generate_features(const chunk_pos& cpos, VoxelStorage& voxels); + +private: + ConfigInt m_terrain_variation; + ConfigInt m_bottommost_chunk; + +private: + emhash8::HashMap m_metamap; + +private: + fnl_state m_fnl_variation; + fnl_state m_fnl_terrain; + fnl_state m_fnl_caves_a; + fnl_state m_fnl_caves_b; + fnl_state m_fnl_nvdi; + +private: + Feature m_feat_tree[OW_NUM_TREES]; + +private: + std::mutex m_mutex; +}; + +#endif /* SERVER_OVERWORLD_HH */ -- cgit