summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
authorx12xx12x <44411062+12xx12@users.noreply.github.com>2022-04-20 00:10:35 +0200
committerAlexander Harkness <me@bearbin.net>2022-04-20 09:41:02 +0200
commitfe983a1a45b23c67cf6c758a4f0ffe6a8ba764d6 (patch)
treea5c9f00728af0f2ca841bb5d881b8d0d785b24ae /src/World.cpp
parentUpdated protocol functions to Vector3x (diff)
downloadcuberite-fe983a1a45b23c67cf6c758a4f0ffe6a8ba764d6.tar
cuberite-fe983a1a45b23c67cf6c758a4f0ffe6a8ba764d6.tar.gz
cuberite-fe983a1a45b23c67cf6c758a4f0ffe6a8ba764d6.tar.bz2
cuberite-fe983a1a45b23c67cf6c758a4f0ffe6a8ba764d6.tar.lz
cuberite-fe983a1a45b23c67cf6c758a4f0ffe6a8ba764d6.tar.xz
cuberite-fe983a1a45b23c67cf6c758a4f0ffe6a8ba764d6.tar.zst
cuberite-fe983a1a45b23c67cf6c758a4f0ffe6a8ba764d6.zip
Diffstat (limited to 'src/World.cpp')
-rw-r--r--src/World.cpp43
1 files changed, 19 insertions, 24 deletions
diff --git a/src/World.cpp b/src/World.cpp
index d0cca09db..77230e5b8 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -850,42 +850,37 @@ bool cWorld::CanSpawnAt(int a_X, int & a_Y, int a_Z)
-bool cWorld::CheckPlayerSpawnPoint(int a_PosX, int a_PosY, int a_PosZ)
+bool cWorld::CheckPlayerSpawnPoint(Vector3i a_Pos)
{
// Check height bounds
- if (!cChunkDef::IsValidHeight(a_PosY))
+ if (!cChunkDef::IsValidHeight(a_Pos))
{
return false;
}
// Check that surrounding blocks are neither solid or liquid
- static const Vector3i SurroundingCoords[] =
- {
- Vector3i(0, 0, 1),
- Vector3i(1, 0, 1),
- Vector3i(1, 0, 0),
- Vector3i(1, 0, -1),
- Vector3i(0, 0, -1),
- Vector3i(-1, 0, -1),
- Vector3i(-1, 0, 0),
- Vector3i(-1, 0, 1),
- };
-
- static const int SurroundingCoordsCount = ARRAYCOUNT(SurroundingCoords);
-
- for (int CoordIndex = 0; CoordIndex < SurroundingCoordsCount; ++CoordIndex)
- {
- const int XPos = a_PosX + SurroundingCoords[CoordIndex].x;
- const int ZPos = a_PosZ + SurroundingCoords[CoordIndex].z;
-
- const BLOCKTYPE BlockType = GetBlock({ XPos, a_PosY, ZPos });
+ constexpr std::array<Vector3i, 8> SurroundingCoords =
+ {{
+ {0, 0, 1},
+ {1, 0, 1},
+ {1, 0, 0},
+ {1, 0, -1},
+ {0, 0, -1},
+ {-1, 0, -1},
+ {-1, 0, 0},
+ {-1, 0, 1},
+ }};
+
+ for (const auto & Offset : SurroundingCoords)
+ {
+ const BLOCKTYPE BlockType = GetBlock(a_Pos + Offset);
if (cBlockInfo::IsSolid(BlockType) || IsBlockLiquid(BlockType))
{
- return false;
+ return true;
}
}
- return true;
+ return false;
}