Skip to content

Commit bc29e03

Browse files
authoredJan 21, 2017
Revert "Detach the player from entities on death." (#5087)
1 parent b9c1a75 commit bc29e03

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed
 

Diff for: ‎src/content_sao.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,6 @@ void UnitSAO::getAttachment(int *parent_id, std::string *bone, v3f *position,
203203
*rotation = m_attachment_rotation;
204204
}
205205

206-
void UnitSAO::detachFromParent()
207-
{
208-
ServerActiveObject *parent = NULL;
209-
if (m_attachment_parent_id)
210-
parent = m_env->getActiveObject(m_attachment_parent_id);
211-
setAttachment(NULL, "", v3f(0, 0, 0), v3f(0, 0, 0));
212-
if (parent != NULL)
213-
parent->removeAttachmentChild(m_id);
214-
}
215-
216206
void UnitSAO::addAttachmentChild(int child_id)
217207
{
218208
m_attachment_child_ids.insert(child_id);

Diff for: ‎src/content_sao.h

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class UnitSAO: public ServerActiveObject
4949
void setBonePosition(const std::string &bone, v3f position, v3f rotation);
5050
void getBonePosition(const std::string &bone, v3f *position, v3f *rotation);
5151
void setAttachment(int parent_id, const std::string &bone, v3f position, v3f rotation);
52-
void detachFromParent();
5352
void getAttachment(int *parent_id, std::string *bone, v3f *position, v3f *rotation);
5453
void addAttachmentChild(int child_id);
5554
void removeAttachmentChild(int child_id);

Diff for: ‎src/script/lua_api/l_object.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,20 @@ int ObjectRef::l_set_detach(lua_State *L)
710710
ServerActiveObject *co = getobject(ref);
711711
if (co == NULL)
712712
return 0;
713-
co->detachFromParent();
713+
714+
int parent_id = 0;
715+
std::string bone = "";
716+
v3f position;
717+
v3f rotation;
718+
co->getAttachment(&parent_id, &bone, &position, &rotation);
719+
ServerActiveObject *parent = NULL;
720+
if (parent_id)
721+
parent = env->getActiveObject(parent_id);
722+
723+
// Do it
724+
co->setAttachment(0, "", v3f(0,0,0), v3f(0,0,0));
725+
if (parent != NULL)
726+
parent->removeAttachmentChild(co->getId());
714727
return 0;
715728
}
716729

Diff for: ‎src/server.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -2560,8 +2560,6 @@ void Server::DiePlayer(u16 peer_id)
25602560
if (!playersao)
25612561
return;
25622562

2563-
playersao->detachFromParent();
2564-
25652563
infostream << "Server::DiePlayer(): Player "
25662564
<< playersao->getPlayer()->getName()
25672565
<< " dies" << std::endl;

Diff for: ‎src/serverobject.h

-2
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ class ServerActiveObject : public ActiveObject
166166
{}
167167
virtual void removeAttachmentChild(int child_id)
168168
{}
169-
virtual void detachFromParent()
170-
{}
171169
virtual const UNORDERED_SET<int> &getAttachmentChildIds()
172170
{ static const UNORDERED_SET<int> rv; return rv; }
173171
virtual ObjectProperties* accessObjectProperties()

0 commit comments

Comments
 (0)
Please sign in to comment.