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

@@ -20,10 +20,11 @@
namespace Cubed {
Renderer::Renderer(const Camera& camera, ClientWorld& world,
const TextureManager& texture_manager, DevPanel& dev_panel)
const TextureManager& texture_manager, DevPanel& dev_panel,
Config& config)
: m_camera(camera), m_dev_panel(dev_panel),
m_texture_manager(texture_manager), m_world(world),
m_world_renderer(*this) {}
m_world_renderer(*this), m_config(config) {}
Renderer::~Renderer() {
if (m_init) {
@@ -38,10 +39,7 @@ Renderer::~Renderer() {
}
}
void Renderer::hot_reload() {
auto& config = Config::get();
update_fov(config.get<double>("player.fov"));
}
void Renderer::hot_reload() { update_fov(m_config.get("player.fov", 70.0f)); }
void Renderer::init(bool debug_on) {
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {