diff options
author | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-03-30 08:32:43 +0200 |
---|---|---|
committer | LogicParrot <LogicParrot@users.noreply.github.com> | 2016-03-30 08:32:43 +0200 |
commit | b0273c6438652956b0c0188083a7422b7c328d65 (patch) | |
tree | df536e502f68bcee9b31ed8fe760143e26075efe /src/Entities/Player.cpp | |
parent | Merge pull request #3096 from mathias-github/icons (diff) | |
parent | Bed's world is now saved (diff) | |
download | cuberite-b0273c6438652956b0c0188083a7422b7c328d65.tar cuberite-b0273c6438652956b0c0188083a7422b7c328d65.tar.gz cuberite-b0273c6438652956b0c0188083a7422b7c328d65.tar.bz2 cuberite-b0273c6438652956b0c0188083a7422b7c328d65.tar.lz cuberite-b0273c6438652956b0c0188083a7422b7c328d65.tar.xz cuberite-b0273c6438652956b0c0188083a7422b7c328d65.tar.zst cuberite-b0273c6438652956b0c0188083a7422b7c328d65.zip |
Diffstat (limited to 'src/Entities/Player.cpp')
-rw-r--r-- | src/Entities/Player.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 9d18cedc4..c94cec3c9 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -828,6 +828,27 @@ void cPlayer::SetCustomName(const AString & a_CustomName) +void cPlayer::SetBedPos(const Vector3i & a_Pos) +{ + m_LastBedPos = a_Pos; + m_SpawnWorld = m_World; +} + + + + + +void cPlayer::SetBedPos(const Vector3i & a_Pos, cWorld * a_World) +{ + m_LastBedPos = a_Pos; + ASSERT(a_World != nullptr); + m_SpawnWorld = a_World; +} + + + + + void cPlayer::SetFlying(bool a_IsFlying) { if (a_IsFlying == m_IsFlying) @@ -1078,12 +1099,19 @@ void cPlayer::Respawn(void) m_LifetimeTotalXp = 0; // ToDo: send score to client? How? - m_ClientHandle->SendRespawn(GetWorld()->GetDimension(), true); + m_ClientHandle->SendRespawn(m_SpawnWorld->GetDimension(), true); // Extinguish the fire: StopBurning(); - TeleportToCoords(GetLastBedPos().x, GetLastBedPos().y, GetLastBedPos().z); + if (GetWorld() != m_SpawnWorld) + { + MoveToWorld(m_SpawnWorld, false, GetLastBedPos()); + } + else + { + TeleportToCoords(GetLastBedPos().x, GetLastBedPos().y, GetLastBedPos().z); + } SetVisible(true); } @@ -1895,9 +1923,16 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World) a_World = cRoot::Get()->GetDefaultWorld(); } + m_LastBedPos.x = root.get("SpawnX", a_World->GetSpawnX()).asInt(); m_LastBedPos.y = root.get("SpawnY", a_World->GetSpawnY()).asInt(); m_LastBedPos.z = root.get("SpawnZ", a_World->GetSpawnZ()).asInt(); + AString SpawnWorldName = root.get("SpawnWorld", cRoot::Get()->GetDefaultWorld()->GetName()).asString(); + m_SpawnWorld = cRoot::Get()->GetWorld(SpawnWorldName); + if (m_SpawnWorld == nullptr) + { + m_SpawnWorld = cRoot::Get()->GetDefaultWorld(); + } // Load the player stats. // We use the default world name (like bukkit) because stats are shared between dimensions / worlds. @@ -1955,6 +1990,7 @@ bool cPlayer::SaveToDisk() root["SpawnX"] = GetLastBedPos().x; root["SpawnY"] = GetLastBedPos().y; root["SpawnZ"] = GetLastBedPos().z; + root["SpawnWorld"] = m_SpawnWorld->GetName(); if (m_World != nullptr) { |