diff options
author | sfan5 <sfan5@live.de> | 2020-05-26 16:05:06 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2020-05-29 22:54:50 +0200 |
commit | 4c8e1c320054ee0dc5d8ec821a6b4cd69002aa09 (patch) | |
tree | 9095c1f66b051d84e6001c71bb1978a5fb83a3d1 /src/client | |
parent | db7c262ee85c5bcae68354280848218dbf14bf55 (diff) | |
download | minetest-4c8e1c320054ee0dc5d8ec821a6b4cd69002aa09.tar.gz minetest-4c8e1c320054ee0dc5d8ec821a6b4cd69002aa09.tar.bz2 minetest-4c8e1c320054ee0dc5d8ec821a6b4cd69002aa09.zip |
Clean up CAO nametag handling and remove deprecated AO_CMD
AO_CMD_UPDATE_NAMETAG_ATTRIBUTES was deprecated in
9eee3c3f465c071bb9908749cf48be3c131a1bdf (0.4.14)
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/content_cao.cpp | 57 | ||||
-rw-r--r-- | src/client/content_cao.h | 2 |
2 files changed, 38 insertions, 21 deletions
diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp index 947c1a279..dde31899b 100644 --- a/src/client/content_cao.cpp +++ b/src/client/content_cao.cpp @@ -776,15 +776,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc) if (node && m_matrixnode) node->setParent(m_matrixnode); - if (node && !m_prop.nametag.empty() && !m_is_local_player) { - // Add nametag - v3f pos; - pos.Y = m_prop.selectionbox.MaxEdge.Y + 0.3f; - m_nametag = m_client->getCamera()->addNametag(node, - m_prop.nametag, m_prop.nametag_color, - pos); - } - + updateNametag(); updateNodePos(); updateAnimation(); updateBonePosition(); @@ -872,6 +864,38 @@ v3s16 GenericCAO::getLightPosition() return floatToInt(m_position, BS); } +void GenericCAO::updateNametag() +{ + if (m_is_local_player) // No nametag for local player + return; + + if (m_prop.nametag.empty()) { + // Delete nametag + if (m_nametag) { + m_client->getCamera()->removeNametag(m_nametag); + m_nametag = nullptr; + } + return; + } + + scene::ISceneNode *node = getSceneNode(); + if (!node) + return; + + v3f pos; + pos.Y = m_prop.selectionbox.MaxEdge.Y + 0.3f; + if (!m_nametag) { + // Add nametag + m_nametag = m_client->getCamera()->addNametag(node, + m_prop.nametag, m_prop.nametag_color, pos); + } else { + // Update nametag + m_nametag->nametag_text = m_prop.nametag; + m_nametag->nametag_color = m_prop.nametag_color; + m_nametag->nametag_pos = pos; + } +} + void GenericCAO::updateNodePos() { if (getParent() != NULL) @@ -1465,8 +1489,6 @@ bool GenericCAO::visualExpiryRequired(const ObjectProperties &new_) const old.initial_sprite_basepos != new_.initial_sprite_basepos || old.is_visible != new_.is_visible || old.mesh != new_.mesh || - old.nametag != new_.nametag || - old.nametag_color != new_.nametag_color || old.spritediv != new_.spritediv || old.use_texture_alpha != new_.use_texture_alpha || old.visual != new_.visual || @@ -1516,6 +1538,7 @@ void GenericCAO::processMessage(const std::string &data) if ((m_is_player && !m_is_local_player) && m_prop.nametag.empty()) m_prop.nametag = m_name; + updateNametag(); if (expire_visuals) { expireVisuals(); @@ -1694,22 +1717,14 @@ void GenericCAO::processMessage(const std::string &data) int rating = readS16(is); m_armor_groups[name] = rating; } - } else if (cmd == AO_CMD_UPDATE_NAMETAG_ATTRIBUTES) { - // Deprecated, for backwards compatibility only. - readU8(is); // version - m_prop.nametag_color = readARGB8(is); - if (m_nametag != NULL) { - m_nametag->nametag_color = m_prop.nametag_color; - v3f pos; - pos.Y = m_prop.collisionbox.MaxEdge.Y + 0.3f; - m_nametag->nametag_pos = pos; - } } else if (cmd == AO_CMD_SPAWN_INFANT) { u16 child_id = readU16(is); u8 type = readU8(is); // maybe this will be useful later (void)type; addAttachmentChild(child_id); + } else if (cmd == AO_CMD_OBSOLETE1) { + // Don't do anything and also don't log a warning } else { warningstream << FUNCTION_NAME << ": unknown command or outdated client \"" diff --git a/src/client/content_cao.h b/src/client/content_cao.h index 03a355204..8e2a13ea8 100644 --- a/src/client/content_cao.h +++ b/src/client/content_cao.h @@ -244,6 +244,8 @@ public: v3s16 getLightPosition(); + void updateNametag(); + void updateNodePos(); void step(float dtime, ClientEnvironment *env); |