1
0

Implemented end and nether portals

This commit is contained in:
Tiger Wang
2014-05-31 22:28:51 +01:00
parent 60a37c1370
commit 8bff3e5af2
23 changed files with 254 additions and 92 deletions

View File

@@ -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;
}