From dada2bea27bbc0b5dec68e8089ce5b8c296baabd Mon Sep 17 00:00:00 2001 From: faketruth Date: Wed, 2 Nov 2011 20:19:57 +0000 Subject: Fixed some "Entity was not found in any chunk!" warnings Player's current world is saved in the player file. When a player joins the server, the player joins the last world he was in. It seems MCServer can finally run multiple worlds! It just needs functionality to switch between them git-svn-id: http://mc-server.googlecode.com/svn/trunk@46 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cClientHandle.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source/cClientHandle.cpp') diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index a694ea97e..621e8a19e 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -432,7 +432,9 @@ void cClientHandle::HandlePacket( cPacket* a_Packet ) } // Now initialize player (adds to entity list etc.) - m_Player->Initialize( cRoot::Get()->GetDefaultWorld() ); // TODO - Get correct world for player + cWorld* PlayerWorld = cRoot::Get()->GetWorld( m_Player->GetLoadedWorldName() ); + if( !PlayerWorld ) PlayerWorld = cRoot::Get()->GetDefaultWorld(); + m_Player->Initialize( PlayerWorld ); // TODO - Get correct world for player // Broadcasts to all but this ( this is actually handled in cChunk.cpp, after entity is added to the chunk ) //m_Player->SpawnOn( 0 ); @@ -937,13 +939,15 @@ void cClientHandle::Tick(float a_Dt) { m_bSendLoginResponse = false; - cWorld* World = cRoot::Get()->GetDefaultWorld(); // TODO - Get the correct world or better yet, move this to the main thread so we don't have to lock anything - World->LockEntities(); // Spawn player (only serversided, so data is loaded) m_Player = new cPlayer( this, GetUsername() ); // !!DO NOT INITIALIZE!! <- is done after receiving MoveLook Packet + + cWorld* World = cRoot::Get()->GetWorld( m_Player->GetLoadedWorldName() ); // TODO - Get the correct world or better yet, move this to the main thread so we don't have to lock anything + if( !World ) World = cRoot::Get()->GetDefaultWorld(); + World->LockEntities(); m_Player->SetGameMode ( World->GetGameMode() ); //set player's gamemode to server's gamemode at login. - cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_PLAYER_SPAWN, 1, m_Player ); // TODO - this function is called from a seperate thread, which might be dangerous + cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_PLAYER_SPAWN, 1, m_Player ); // Return a server login packet cPacket_Login LoginResponse; -- cgit v1.2.3