aboutsummaryrefslogtreecommitdiff
path: root/src/server/unit_sao.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/unit_sao.cpp')
-rw-r--r--src/server/unit_sao.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/server/unit_sao.cpp b/src/server/unit_sao.cpp
index ef0e87f2c..2371640ca 100644
--- a/src/server/unit_sao.cpp
+++ b/src/server/unit_sao.cpp
@@ -121,8 +121,8 @@ void UnitSAO::sendOutdatedData()
}
// clang-format on
-void UnitSAO::setAttachment(
- int parent_id, const std::string &bone, v3f position, v3f rotation)
+void UnitSAO::setAttachment(int parent_id, const std::string &bone, v3f position,
+ v3f rotation, bool force_visible)
{
// Attachments need to be handled on both the server and client.
// If we just attach on the server, we can only copy the position of the parent.
@@ -137,6 +137,7 @@ void UnitSAO::setAttachment(
m_attachment_bone = bone;
m_attachment_position = position;
m_attachment_rotation = rotation;
+ m_force_visible = force_visible;
m_attachment_sent = false;
if (parent_id != old_parent) {
@@ -145,13 +146,14 @@ void UnitSAO::setAttachment(
}
}
-void UnitSAO::getAttachment(
- int *parent_id, std::string *bone, v3f *position, v3f *rotation) const
+void UnitSAO::getAttachment(int *parent_id, std::string *bone, v3f *position,
+ v3f *rotation, bool *force_visible) const
{
*parent_id = m_attachment_parent_id;
*bone = m_attachment_bone;
*position = m_attachment_position;
*rotation = m_attachment_rotation;
+ *force_visible = m_force_visible;
}
void UnitSAO::clearChildAttachments()
@@ -159,7 +161,7 @@ void UnitSAO::clearChildAttachments()
for (int child_id : m_attachment_child_ids) {
// Child can be NULL if it was deleted earlier
if (ServerActiveObject *child = m_env->getActiveObject(child_id))
- child->setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0));
+ child->setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0), false);
}
m_attachment_child_ids.clear();
}
@@ -169,9 +171,9 @@ void UnitSAO::clearParentAttachment()
ServerActiveObject *parent = nullptr;
if (m_attachment_parent_id) {
parent = m_env->getActiveObject(m_attachment_parent_id);
- setAttachment(0, "", m_attachment_position, m_attachment_rotation);
+ setAttachment(0, "", m_attachment_position, m_attachment_rotation, false);
} else {
- setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0));
+ setAttachment(0, "", v3f(0, 0, 0), v3f(0, 0, 0), false);
}
// Do it
if (parent)
@@ -242,9 +244,10 @@ std::string UnitSAO::generateUpdateAttachmentCommand() const
writeU8(os, AO_CMD_ATTACH_TO);
// parameters
writeS16(os, m_attachment_parent_id);
- os << serializeString(m_attachment_bone);
+ os << serializeString16(m_attachment_bone);
writeV3F32(os, m_attachment_position);
writeV3F32(os, m_attachment_rotation);
+ writeU8(os, m_force_visible);
return os.str();
}
@@ -255,7 +258,7 @@ std::string UnitSAO::generateUpdateBonePositionCommand(
// command
writeU8(os, AO_CMD_SET_BONE_POSITION);
// parameters
- os << serializeString(bone);
+ os << serializeString16(bone);
writeV3F32(os, position);
writeV3F32(os, rotation);
return os.str();
@@ -291,7 +294,7 @@ std::string UnitSAO::generateUpdateArmorGroupsCommand() const
writeU8(os, AO_CMD_UPDATE_ARMOR_GROUPS);
writeU16(os, m_armor_groups.size());
for (const auto &armor_group : m_armor_groups) {
- os << serializeString(armor_group.first);
+ os << serializeString16(armor_group.first);
writeS16(os, armor_group.second);
}
return os.str();