refactor: config (#30)

* refactor(config): replace singleton with dependency injection

* refactor(client_player): return ChunkPosSet by value in non-const getter

Copy the internal set under the mutex lock to avoid exposing a mutable reference that could be used unsafely after the lock is released. This fixes a potential data race when the caller holds the returned reference beyond the critical section. Also update the caller in `client_world` to remove the now-unnecessary `std::move`.

* fix(gameplay): prevent use-after-free in pending delete queues during destruction

* refactor(config): separate game and server configuration with explicit paths
This commit is contained in:
zhenyan121
2026-07-11 09:22:40 +08:00
committed by GitHub
parent 913809a5f0
commit 03259f323c
27 changed files with 285 additions and 368 deletions

View File

@@ -2,7 +2,6 @@
#include "Cubed/config.hpp"
#include "Cubed/constants.hpp"
#include "Cubed/map_table.hpp"
#include "Cubed/tools/cubed_assert.hpp"
#include "Cubed/tools/log.hpp"
#include "Cubed/tools/shader_tools.hpp"
@@ -32,7 +31,7 @@ unsigned char* generate_flat_normal_map(int width = BLOCK_NORMAL_SIZE,
namespace Cubed {
TextureManager::TextureManager() {}
TextureManager::TextureManager(Config& config) : m_config(config) {}
TextureManager::~TextureManager() { delete_texture(); }
@@ -286,10 +285,9 @@ void TextureManager::init_texture() {
Logger::info("Support anisotropic filtering max_aniso is {}",
m_max_aniso);
}
m_aniso = Config::get().get<int>("texture.aniso");
m_aniso = m_config.get("texture.aniso", 1);
m_aniso = std::min(static_cast<int>(m_max_aniso), m_aniso);
Logger::info("Setting Texture Aniso is {}", m_aniso);
MapTable::init_map();
Logger::info("Map Init Success");
init_block();