summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-05-31 23:28:51 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-05-31 23:28:51 +0200
commit8bff3e5af220070ecc789ef551c0b8428b8953ef (patch)
tree4e0b04d1595f8441a9ca5f319ea94244143294db /src/Entities/Player.cpp
parentVery minor code changes (diff)
downloadcuberite-8bff3e5af220070ecc789ef551c0b8428b8953ef.tar
cuberite-8bff3e5af220070ecc789ef551c0b8428b8953ef.tar.gz
cuberite-8bff3e5af220070ecc789ef551c0b8428b8953ef.tar.bz2
cuberite-8bff3e5af220070ecc789ef551c0b8428b8953ef.tar.lz
cuberite-8bff3e5af220070ecc789ef551c0b8428b8953ef.tar.xz
cuberite-8bff3e5af220070ecc789ef551c0b8428b8953ef.tar.zst
cuberite-8bff3e5af220070ecc789ef551c0b8428b8953ef.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Player.cpp36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 0dfdcfd8b..140b98d5d 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -134,7 +134,7 @@ cPlayer::~cPlayer(void)
SaveToDisk();
- m_World->RemovePlayer( this );
+ m_World->RemovePlayer(this);
m_ClientHandle = NULL;
@@ -150,8 +150,6 @@ cPlayer::~cPlayer(void)
void cPlayer::Destroyed()
{
CloseWindow(false);
-
- m_ClientHandle = NULL;
}
@@ -952,7 +950,7 @@ void cPlayer::Respawn(void)
m_LifetimeTotalXp = 0;
// ToDo: send score to client? How?
- m_ClientHandle->SendRespawn();
+ m_ClientHandle->SendRespawn(*GetWorld());
// Extinguish the fire:
StopBurning();
@@ -1574,12 +1572,25 @@ void cPlayer::TossItems(const cItems & a_Items)
-bool cPlayer::MoveToWorld(const char * a_WorldName)
+bool cPlayer::MoveToWorld(const AString & a_WorldName, cWorld * a_World)
{
- cWorld * World = cRoot::Get()->GetWorld(a_WorldName);
- if (World == NULL)
+ cWorld * World;
+ if (a_World == NULL)
+ {
+ World = cRoot::Get()->GetWorld(a_WorldName);
+ if (World == NULL)
+ {
+ LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName);
+ return false;
+ }
+ }
+ else
+ {
+ World = a_World;
+ }
+
+ if (GetWorld() == World)
{
- LOG("%s: Couldn't find world \"%s\".", __FUNCTION__, a_WorldName);
return false;
}
@@ -1588,11 +1599,11 @@ bool cPlayer::MoveToWorld(const char * a_WorldName)
// Remove all links to the old world
m_World->RemovePlayer(this);
m_ClientHandle->RemoveFromAllChunks();
- m_World->RemoveEntity(this);
// If the dimension is different, we can send the respawn packet
// http://wiki.vg/Protocol#0x09 says "don't send if dimension is the same" as of 2013_07_02
- m_ClientHandle->MoveToWorld(*World, (OldDimension != World->GetDimension()));
+ bool SendRespawn = OldDimension != World->GetDimension();
+ m_ClientHandle->MoveToWorld(*World, SendRespawn);
// Add player to all the necessary parts of the new world
SetWorld(World);
@@ -1600,6 +1611,11 @@ bool cPlayer::MoveToWorld(const char * a_WorldName)
World->AddEntity(this);
World->AddPlayer(this);
+ if (SendRespawn)
+ {
+ GetClientHandle()->SendPlayerMoveLook();
+ }
+
return true;
}