summaryrefslogtreecommitdiffstats
path: root/source/cPlayer.cpp
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-12-26 22:54:08 +0100
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-12-26 22:54:08 +0100
commiteb942797b8a1321f7460cea7763bb6891affd475 (patch)
tree89d2c6c4724bda06f0d8779a6ab3e02636c968ce /source/cPlayer.cpp
parent- improved Simulator system (diff)
downloadcuberite-eb942797b8a1321f7460cea7763bb6891affd475.tar
cuberite-eb942797b8a1321f7460cea7763bb6891affd475.tar.gz
cuberite-eb942797b8a1321f7460cea7763bb6891affd475.tar.bz2
cuberite-eb942797b8a1321f7460cea7763bb6891affd475.tar.lz
cuberite-eb942797b8a1321f7460cea7763bb6891affd475.tar.xz
cuberite-eb942797b8a1321f7460cea7763bb6891affd475.tar.zst
cuberite-eb942797b8a1321f7460cea7763bb6891affd475.zip
Diffstat (limited to '')
-rw-r--r--source/cPlayer.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/source/cPlayer.cpp b/source/cPlayer.cpp
index 5fe31c8c9..dcc9de177 100644
--- a/source/cPlayer.cpp
+++ b/source/cPlayer.cpp
@@ -701,6 +701,33 @@ void cPlayer::TossItem( bool a_bDraggingItem, int a_Amount /* = 1 */ )
}
}
+bool cPlayer::MoveToWorld( const char* a_WorldName )
+{
+ cWorld* World = cRoot::Get()->GetWorld( a_WorldName );
+ if( World )
+ {
+ /* Remove all links to the old world */
+ GetWorld()->RemovePlayer( this );
+ GetClientHandle()->RemoveFromAllChunks();
+ cChunk* Chunk = GetWorld()->GetChunkUnreliable( m_ChunkX, m_ChunkY, m_ChunkZ );
+ if( Chunk )
+ {
+ Chunk->RemoveEntity( *this );
+ Chunk->Broadcast( cPacket_DestroyEntity( this ) ); // Remove player entity from all clients in old world
+ }
+
+ /* Add player to all the necessary parts of the new world */
+ SetWorld( World );
+ GetWorld()->AddPlayer( this );
+ MoveToCorrectChunk(true);
+ GetClientHandle()->StreamChunks();
+
+ return true;
+ }
+
+ return false;
+}
+
bool cPlayer::LoadFromDisk() // TODO - This should also get/set/whatever the correct world for this player
{
cIniFile IniFile("users.ini");