mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add player:get_meta(), deprecate player attributes (#7202)
* Add player:get_meta(), deprecate player attributes
This commit is contained in:
parent
7e3f88f539
commit
91615f9588
22 changed files with 314 additions and 70 deletions
|
@ -72,14 +72,15 @@ void RemotePlayer::serializeExtraAttributes(std::string &output)
|
|||
{
|
||||
assert(m_sao);
|
||||
Json::Value json_root;
|
||||
const PlayerAttributes &attrs = m_sao->getExtendedAttributes();
|
||||
|
||||
const StringMap &attrs = m_sao->getMeta().getStrings();
|
||||
for (const auto &attr : attrs) {
|
||||
json_root[attr.first] = attr.second;
|
||||
}
|
||||
|
||||
output = fastWriteJson(json_root);
|
||||
|
||||
m_sao->setExtendedAttributeModified(false);
|
||||
m_sao->getMeta().setModified(false);
|
||||
}
|
||||
|
||||
|
||||
|
@ -132,8 +133,9 @@ void RemotePlayer::deSerialize(std::istream &is, const std::string &playername,
|
|||
const Json::Value::Members attr_list = attr_root.getMemberNames();
|
||||
for (const auto &it : attr_list) {
|
||||
Json::Value attr_value = attr_root[it];
|
||||
sao->setExtendedAttribute(it, attr_value.asString());
|
||||
sao->getMeta().setString(it, attr_value.asString());
|
||||
}
|
||||
sao->getMeta().setModified(false);
|
||||
} catch (SettingNotFoundException &e) {}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue