diff options
| author | untodesu <kirill@untode.su> | 2025-12-11 15:14:26 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-12-11 15:14:26 +0500 |
| commit | f40d09cb8f712e87691af4912f3630d92d692779 (patch) | |
| tree | 7ac3a4168ff722689372fd489c6f94d0a2546e8f /game/server/world/unloader.cc | |
| parent | 8bcbd2729388edc63c82d77d314b583af1447c49 (diff) | |
| download | voxelius-f40d09cb8f712e87691af4912f3630d92d692779.tar.bz2 voxelius-f40d09cb8f712e87691af4912f3630d92d692779.zip | |
Shuffle stuff around
- Use the new and improved hierarchy I figured out when making Prospero chat
- Re-add NSIS scripts, again from Prospero
- Update most build and utility scripts with their most recent versions
Diffstat (limited to 'game/server/world/unloader.cc')
| -rw-r--r-- | game/server/world/unloader.cc | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/game/server/world/unloader.cc b/game/server/world/unloader.cc deleted file mode 100644 index 371a96f..0000000 --- a/game/server/world/unloader.cc +++ /dev/null @@ -1,78 +0,0 @@ -#include "server/pch.hh"
-
-#include "server/world/unloader.hh"
-
-#include "core/config/number.hh"
-
-#include "shared/entity/player.hh"
-#include "shared/entity/transform.hh"
-
-#include "shared/world/chunk.hh"
-#include "shared/world/chunk_aabb.hh"
-#include "shared/world/dimension.hh"
-
-#include "server/world/inhabited.hh"
-#include "server/world/universe.hh"
-
-#include "server/game.hh"
-#include "server/globals.hh"
-
-static void on_chunk_update(const world::ChunkUpdateEvent& event)
-{
- event.dimension->chunks.emplace_or_replace<world::Inhabited>(event.chunk->get_entity());
-}
-
-static void on_voxel_set(const world::VoxelSetEvent& event)
-{
- event.dimension->chunks.emplace_or_replace<world::Inhabited>(event.chunk->get_entity());
-}
-
-void world::unloader::init(void)
-{
- globals::dispatcher.sink<world::ChunkUpdateEvent>().connect<&on_chunk_update>();
- globals::dispatcher.sink<world::VoxelSetEvent>().connect<&on_voxel_set>();
-}
-
-void world::unloader::init_late(void)
-{
-}
-
-void world::unloader::fixed_update_late(Dimension* dimension)
-{
- auto group = dimension->entities.group(entt::get<entity::Player, entity::Transform>);
- auto boxes = std::vector<ChunkAABB>();
-
- for(const auto [entity, transform] : group.each()) {
- ChunkAABB aabb;
- aabb.min = transform.chunk - static_cast<chunk_pos::value_type>(server_game::view_distance.get_value());
- aabb.max = transform.chunk + static_cast<chunk_pos::value_type>(server_game::view_distance.get_value());
- boxes.push_back(aabb);
- }
-
- auto view = dimension->chunks.view<ChunkComponent>();
- auto chunk_in_view = false;
-
- for(const auto [entity, chunk] : view.each()) {
- chunk_in_view = false;
-
- for(const auto& aabb : boxes) {
- if(aabb.contains(chunk.cpos)) {
- chunk_in_view = true;
- break;
- }
- }
-
- if(chunk_in_view) {
- // The chunk is within view box of at least
- // a single player; we shouldn't unload it now
- continue;
- }
-
- if(dimension->chunks.any_of<Inhabited>(entity)) {
- // Only store inhabited chunks on disk
- world::universe::save_chunk(dimension, chunk.cpos);
- }
-
- dimension->remove_chunk(entity);
- }
-}
|
