From 3bf42c6ff3805a0d42bbc661794a95ff31bedc26 Mon Sep 17 00:00:00 2001 From: untodesu Date: Sat, 15 Mar 2025 16:22:09 +0500 Subject: Add whatever I was working on for the last month --- game/server/overworld.hh | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 game/server/overworld.hh (limited to 'game/server/overworld.hh') diff --git a/game/server/overworld.hh b/game/server/overworld.hh new file mode 100644 index 0000000..dbe66d0 --- /dev/null +++ b/game/server/overworld.hh @@ -0,0 +1,51 @@ +#ifndef SERVER_OVERWORLD_HH +#define SERVER_OVERWORLD_HH 1 +#pragma once + +#include "core/config.hh" + +#include "shared/const.hh" +#include "shared/dimension.hh" + +struct Metadata_2501 final { + std::array entropy; + std::array heightmap; +}; + +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: + float get_noise(const voxel_pos &vpos, std::int64_t variation); + Metadata_2501 &get_metadata(const worldgen_chunk_pos &cpos); + void generate_terrain(const chunk_pos &cpos, VoxelStorage &voxels); + void generate_surface(const chunk_pos &cpos, VoxelStorage &voxels); + void generate_carvers(const chunk_pos &cpos, VoxelStorage &voxels); + void generate_features(const chunk_pos &cpos, VoxelStorage &voxels); + +private: + ConfigInt m_terrain_variation; + ConfigInt m_bottommost_chunk; + ConfigBoolean m_enable_surface; + ConfigBoolean m_enable_carvers; + ConfigBoolean m_enable_features; + +private: + emhash8::HashMap m_metadata; + std::mt19937_64 m_twister; + fnl_state m_fnl_terrain; + fnl_state m_fnl_caves_a; + fnl_state m_fnl_caves_b; + +private: + std::mutex m_mutex; +}; + +#endif /* SERVER_OVERWORLD_HH */ -- cgit