1
0

SetBedPos: make World parameter non-null

* Fixes 
This commit is contained in:
Tiger Wang 2021-06-06 17:20:21 +01:00
parent 2109057119
commit 93611b8437
2 changed files with 8 additions and 9 deletions
src/Entities

View File

@ -776,9 +776,9 @@ void cPlayer::SetCustomName(const AString & a_CustomName)
void cPlayer::SetBedPos(const Vector3i & a_Pos) void cPlayer::SetBedPos(const Vector3i a_Position)
{ {
m_LastBedPos = a_Pos; m_LastBedPos = a_Position;
m_SpawnWorldName = m_World->GetName(); m_SpawnWorldName = m_World->GetName();
} }
@ -786,11 +786,10 @@ void cPlayer::SetBedPos(const Vector3i & a_Pos)
void cPlayer::SetBedPos(const Vector3i & a_Pos, cWorld * a_World) void cPlayer::SetBedPos(const Vector3i a_Position, const cWorld & a_World)
{ {
m_LastBedPos = a_Pos; m_LastBedPos = a_Position;
ASSERT(a_World != nullptr); m_SpawnWorldName = a_World.GetName();
m_SpawnWorldName = a_World->GetName();
} }
@ -1752,7 +1751,7 @@ void cPlayer::LoadFromDisk()
const Vector3i WorldSpawn(static_cast<int>(m_World->GetSpawnX()), static_cast<int>(m_World->GetSpawnY()), static_cast<int>(m_World->GetSpawnZ())); const Vector3i WorldSpawn(static_cast<int>(m_World->GetSpawnX()), static_cast<int>(m_World->GetSpawnY()), static_cast<int>(m_World->GetSpawnZ()));
SetPosition(WorldSpawn); SetPosition(WorldSpawn);
SetBedPos(WorldSpawn, m_World); SetBedPos(WorldSpawn, *m_World);
m_Inventory.Clear(); m_Inventory.Clear();
m_EnchantmentSeed = GetRandomProvider().RandInt<unsigned int>(); // Use a random number to seed the enchantment generator m_EnchantmentSeed = GetRandomProvider().RandInt<unsigned int>(); // Use a random number to seed the enchantment generator

View File

@ -520,10 +520,10 @@ public:
/** Sets the player's bed (home / respawn) position to the specified position. /** Sets the player's bed (home / respawn) position to the specified position.
Sets the respawn world to the player's world. */ Sets the respawn world to the player's world. */
void SetBedPos(const Vector3i & a_Pos); void SetBedPos(const Vector3i a_Position);
/** Sets the player's bed (home / respawn) position and respawn world to the specified parameters. */ /** Sets the player's bed (home / respawn) position and respawn world to the specified parameters. */
void SetBedPos(const Vector3i & a_Pos, cWorld * a_World); void SetBedPos(const Vector3i a_Position, const cWorld & a_World);
// tolua_end // tolua_end