summaryrefslogtreecommitdiffstats
path: root/game/server/overworld.hh
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-03-15 16:22:09 +0500
committeruntodesu <kirill@untode.su>2025-03-15 16:22:09 +0500
commit3bf42c6ff3805a0d42bbc661794a95ff31bedc26 (patch)
tree05049955847504808d6bed2bb7b155f8b03807bb /game/server/overworld.hh
parent02294547dcde0d4ad76e229106702261e9f10a51 (diff)
downloadvoxelius-3bf42c6ff3805a0d42bbc661794a95ff31bedc26.tar.bz2
voxelius-3bf42c6ff3805a0d42bbc661794a95ff31bedc26.zip
Add whatever I was working on for the last month
Diffstat (limited to 'game/server/overworld.hh')
-rw-r--r--game/server/overworld.hh51
1 files changed, 51 insertions, 0 deletions
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<std::uint64_t, CHUNK_AREA> entropy;
+ std::array<voxel_pos::value_type, CHUNK_AREA> 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<worldgen_chunk_pos, Metadata_2501> 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 */