diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-07-03 09:47:35 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2013-07-03 09:47:35 +0200 |
commit | f7b8a301f8a705cec6df17c7051164169cf619a6 (patch) | |
tree | 18e0c07ecb0b0750868a37f1f62512f84f769c93 /source/Player.cpp | |
parent | dtOnFire damage wasn't dealt properly (diff) | |
download | cuberite-f7b8a301f8a705cec6df17c7051164169cf619a6.tar cuberite-f7b8a301f8a705cec6df17c7051164169cf619a6.tar.gz cuberite-f7b8a301f8a705cec6df17c7051164169cf619a6.tar.bz2 cuberite-f7b8a301f8a705cec6df17c7051164169cf619a6.tar.lz cuberite-f7b8a301f8a705cec6df17c7051164169cf619a6.tar.xz cuberite-f7b8a301f8a705cec6df17c7051164169cf619a6.tar.zst cuberite-f7b8a301f8a705cec6df17c7051164169cf619a6.zip |
Diffstat (limited to 'source/Player.cpp')
-rw-r--r-- | source/Player.cpp | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/source/Player.cpp b/source/Player.cpp index 84d38f13b..865ff24d6 100644 --- a/source/Player.cpp +++ b/source/Player.cpp @@ -117,9 +117,9 @@ cPlayer::~cPlayer(void) -void cPlayer::Initialize( cWorld* a_World ) +void cPlayer::Initialize(cWorld * a_World) { - cPawn::Initialize( a_World ); + super::Initialize(a_World); GetWorld()->AddPlayer(this); } @@ -891,26 +891,37 @@ void cPlayer::TossItem( -bool cPlayer::MoveToWorld( const char* a_WorldName ) +bool cPlayer::MoveToWorld(const char * a_WorldName) { - cWorld * World = cRoot::Get()->GetWorld( a_WorldName ); - if ( World ) + cWorld * World = cRoot::Get()->GetWorld(a_WorldName); + if (World == NULL) { - /* Remove all links to the old world */ - m_World->RemovePlayer( this ); - m_ClientHandle->RemoveFromAllChunks(); - m_World->RemoveEntity(this); - - /* Add player to all the necessary parts of the new world */ - SetWorld( World ); - GetWorld()->AddPlayer(this); - - m_ClientHandle->HandleRespawn(); - m_ClientHandle->StreamChunks(); - return true; + LOG("%s: Couldn't find world \"%s\".", a_WorldName); + return false; } - - return false; + + eDimension OldDimension = m_World->GetDimension(); + + // Remove all links to the old world + m_World->RemovePlayer(this); + m_ClientHandle->RemoveFromAllChunks(); + m_World->RemoveEntity(this); + + // Add player to all the necessary parts of the new world + SetWorld(World); + World->AddEntity(this); + World->AddPlayer(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 + if (OldDimension != World->GetDimension()) + { + m_ClientHandle->SendRespawn(); + } + + // Stream the new chunks: + m_ClientHandle->StreamChunks(); + return true; } |