Skip to content

Commit

Permalink
Revert "Detach the player from entities on death." (#5087)
Browse files Browse the repository at this point in the history
  • Loading branch information
nerzhul committed Jan 21, 2017
1 parent b9c1a75 commit bc29e03
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
10 changes: 0 additions & 10 deletions src/content_sao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,6 @@ void UnitSAO::getAttachment(int *parent_id, std::string *bone, v3f *position,
*rotation = m_attachment_rotation;
}

void UnitSAO::detachFromParent()
{
ServerActiveObject *parent = NULL;
if (m_attachment_parent_id)
parent = m_env->getActiveObject(m_attachment_parent_id);
setAttachment(NULL, "", v3f(0, 0, 0), v3f(0, 0, 0));
if (parent != NULL)
parent->removeAttachmentChild(m_id);
}

void UnitSAO::addAttachmentChild(int child_id)
{
m_attachment_child_ids.insert(child_id);
Expand Down
1 change: 0 additions & 1 deletion src/content_sao.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class UnitSAO: public ServerActiveObject
void setBonePosition(const std::string &bone, v3f position, v3f rotation);
void getBonePosition(const std::string &bone, v3f *position, v3f *rotation);
void setAttachment(int parent_id, const std::string &bone, v3f position, v3f rotation);
void detachFromParent();
void getAttachment(int *parent_id, std::string *bone, v3f *position, v3f *rotation);
void addAttachmentChild(int child_id);
void removeAttachmentChild(int child_id);
Expand Down
15 changes: 14 additions & 1 deletion src/script/lua_api/l_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,20 @@ int ObjectRef::l_set_detach(lua_State *L)
ServerActiveObject *co = getobject(ref);
if (co == NULL)
return 0;
co->detachFromParent();

int parent_id = 0;
std::string bone = "";
v3f position;
v3f rotation;
co->getAttachment(&parent_id, &bone, &position, &rotation);
ServerActiveObject *parent = NULL;
if (parent_id)
parent = env->getActiveObject(parent_id);

// Do it
co->setAttachment(0, "", v3f(0,0,0), v3f(0,0,0));
if (parent != NULL)
parent->removeAttachmentChild(co->getId());
return 0;
}

Expand Down
2 changes: 0 additions & 2 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2560,8 +2560,6 @@ void Server::DiePlayer(u16 peer_id)
if (!playersao)
return;

playersao->detachFromParent();

infostream << "Server::DiePlayer(): Player "
<< playersao->getPlayer()->getName()
<< " dies" << std::endl;
Expand Down
2 changes: 0 additions & 2 deletions src/serverobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ class ServerActiveObject : public ActiveObject
{}
virtual void removeAttachmentChild(int child_id)
{}
virtual void detachFromParent()
{}
virtual const UNORDERED_SET<int> &getAttachmentChildIds()
{ static const UNORDERED_SET<int> rv; return rv; }
virtual ObjectProperties* accessObjectProperties()
Expand Down

0 comments on commit bc29e03

Please sign in to comment.