refactor(server): enhance thread safety and session management

This commit is contained in:
2026-06-24 17:56:11 +08:00
parent 85341651b3
commit af8812916d
7 changed files with 137 additions and 70 deletions

View File

@@ -3,10 +3,12 @@
#include "Cubed/gameplay/server_world.hpp"
namespace Cubed {
ServerPlayer::ServerPlayer(std::string_view name, std::string_view uuid,
ServerWorld& world)
: m_name(name), m_uuid(uuid), m_world(world) {}
ServerWorld& world, std::shared_ptr<Session> session)
: m_name(name), m_uuid(uuid), m_world(world), m_session(session) {}
const glm::vec3& ServerPlayer::get_pos() const { return m_pos; }
const std::string& ServerPlayer::get_name() const { return m_name; }
const std::string& ServerPlayer::get_uuid() const { return m_uuid; }
std::shared_ptr<Session> ServerPlayer::get_session() const { return m_session; }
void ServerPlayer::update_pos(float x, float y, float z) {
m_pos = glm::vec3{x, y, z};
ChunkPos chunk_pos = get_chunk_pos(x, z);