fix: player name 3d text not updating by Decorator

This commit is contained in:
MihailRis 2026-04-03 19:49:19 +03:00
parent a9d185256a
commit 33db2633a2
5 changed files with 23 additions and 20 deletions

View file

@ -20,6 +20,7 @@
#include "world/generator/GeneratorDef.hpp"
#include "data/dv_util.hpp"
#include "debug/Logger.hpp"
#include "util/stringutil.hpp"
static debug::Logger logger("player");
@ -28,7 +29,7 @@ constexpr int SPAWN_ATTEMPTS_PER_UPDATE = 64;
Player::Player(
Level& level,
int64_t id,
const std::string& name,
const std::wstring& name,
glm::vec3 position,
float speed,
std::shared_ptr<Inventory> inv,
@ -230,11 +231,11 @@ entityid_t Player::getSelectedEntity() const {
return selectedEid;
}
void Player::setName(const std::string& name) {
void Player::setName(const std::wstring& name) {
this->name = name;
}
const std::string& Player::getName() const {
const std::wstring& Player::getName() const {
return name;
}
@ -266,7 +267,7 @@ dv::value Player::serialize() const {
auto root = dv::object();
root["id"] = id;
root["name"] = name;
root["name"] = util::wstr2str_utf8(name);
root["position"] = dv::to_value(position);
root["rotation"] = dv::to_value(rotation);
@ -293,7 +294,10 @@ dv::value Player::serialize() const {
void Player::deserialize(const dv::value& src) {
src.at("id").get(id);
src.at("name").get(name);
std::string utf8name;
src.at("name").get(utf8name);
name = util::str2wstr_utf8(utf8name);
const auto& posarr = src["position"];

View file

@ -45,7 +45,7 @@ struct CursorSelection {
class Player : public Serializable {
Level& level;
int64_t id;
std::string name;
std::wstring name;
float speed;
int chosenSlot;
@ -79,7 +79,7 @@ public:
Player(
Level& level,
int64_t id,
const std::string& name,
const std::wstring& name,
glm::vec3 position,
float speed,
std::shared_ptr<Inventory> inv,
@ -124,8 +124,8 @@ public:
entityid_t getSelectedEntity() const;
void setName(const std::string& name);
const std::string& getName() const;
void setName(const std::wstring& name);
const std::wstring& getName() const;
const std::shared_ptr<Inventory>& getInventory() const;

View file

@ -79,7 +79,7 @@ Player* Players::create(int64_t id) {
auto playerPtr = std::make_unique<Player>(
level,
id,
"",
L"",
glm::vec3(0, DEF_PLAYER_Y, 0),
DEF_PLAYER_SPEED,
level.inventories->create(DEF_PLAYER_INVENTORY_SIZE),
@ -134,7 +134,7 @@ void Players::deserialize(const dv::value& src) {
auto playerPtr = std::make_unique<Player>(
level,
0,
"",
L"",
glm::vec3(0, DEF_PLAYER_Y, 0),
DEF_PLAYER_SPEED,
level.inventories->create(DEF_PLAYER_INVENTORY_SIZE),