aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/luaentity_sao.cpp4
-rw-r--r--src/server/player_sao.cpp9
-rw-r--r--src/server/unit_sao.cpp17
-rw-r--r--src/server/unit_sao.h5
4 files changed, 20 insertions, 15 deletions
diff --git a/src/server/luaentity_sao.cpp b/src/server/luaentity_sao.cpp
index f20914f7f..b39797531 100644
--- a/src/server/luaentity_sao.cpp
+++ b/src/server/luaentity_sao.cpp
@@ -238,9 +238,9 @@ std::string LuaEntitySAO::getClientInitializationData(u16 protocol_version)
msg_os << serializeString32(generateUpdateAnimationCommand()); // 3
for (const auto &bone_pos : m_bone_position) {
msg_os << serializeString32(generateUpdateBonePositionCommand(
- bone_pos.first, bone_pos.second.X, bone_pos.second.Y)); // m_bone_position.size
+ bone_pos.first, bone_pos.second.X, bone_pos.second.Y)); // 3 + N
}
- msg_os << serializeString32(generateUpdateAttachmentCommand()); // 4
+ msg_os << serializeString32(generateUpdateAttachmentCommand()); // 4 + m_bone_position.size
int message_count = 4 + m_bone_position.size();
diff --git a/src/server/player_sao.cpp b/src/server/player_sao.cpp
index 8d4938c3c..344d18a20 100644
--- a/src/server/player_sao.cpp
+++ b/src/server/player_sao.cpp
@@ -122,10 +122,10 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version)
msg_os << serializeString32(generateUpdateAnimationCommand()); // 3
for (const auto &bone_pos : m_bone_position) {
msg_os << serializeString32(generateUpdateBonePositionCommand(
- bone_pos.first, bone_pos.second.X, bone_pos.second.Y)); // m_bone_position.size
+ bone_pos.first, bone_pos.second.X, bone_pos.second.Y)); // 3 + N
}
- msg_os << serializeString32(generateUpdateAttachmentCommand()); // 4
- msg_os << serializeString32(generateUpdatePhysicsOverrideCommand()); // 5
+ msg_os << serializeString32(generateUpdateAttachmentCommand()); // 4 + m_bone_position.size
+ msg_os << serializeString32(generateUpdatePhysicsOverrideCommand()); // 5 + m_bone_position.size
int message_count = 5 + m_bone_position.size();
@@ -569,7 +569,8 @@ bool PlayerSAO::checkMovementCheat()
int parent_id;
std::string bone;
v3f attachment_rot;
- getAttachment(&parent_id, &bone, &attachment_pos, &attachment_rot);
+ bool force_visible;
+ getAttachment(&parent_id, &bone, &attachment_pos, &attachment_rot, &force_visible);
}
v3f parent_pos = parent->getBasePosition();
diff --git a/src/server/unit_sao.cpp b/src/server/unit_sao.cpp
index d906e885e..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)
@@ -245,6 +247,7 @@ std::string UnitSAO::generateUpdateAttachmentCommand() const
os << serializeString16(m_attachment_bone);
writeV3F32(os, m_attachment_position);
writeV3F32(os, m_attachment_rotation);
+ writeU8(os, m_force_visible);
return os.str();
}
diff --git a/src/server/unit_sao.h b/src/server/unit_sao.h
index 3cb7f0ad5..a21e055c5 100644
--- a/src/server/unit_sao.h
+++ b/src/server/unit_sao.h
@@ -64,9 +64,9 @@ public:
ServerActiveObject *getParent() const;
inline bool isAttached() const { return getParent(); }
void setAttachment(int parent_id, const std::string &bone, v3f position,
- v3f rotation);
+ v3f rotation, bool force_visible);
void getAttachment(int *parent_id, std::string *bone, v3f *position,
- v3f *rotation) const;
+ v3f *rotation, bool *force_visible) const;
void clearChildAttachments();
void clearParentAttachment();
void addAttachmentChild(int child_id);
@@ -133,4 +133,5 @@ private:
v3f m_attachment_position;
v3f m_attachment_rotation;
bool m_attachment_sent = false;
+ bool m_force_visible = false;
};