summaryrefslogtreecommitdiffstats
path: root/src/ChunkDef.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/ChunkDef.h')
-rw-r--r--src/ChunkDef.h55
1 files changed, 33 insertions, 22 deletions
diff --git a/src/ChunkDef.h b/src/ChunkDef.h
index b3cf9049f..f99cc761b 100644
--- a/src/ChunkDef.h
+++ b/src/ChunkDef.h
@@ -31,7 +31,7 @@ class cEntity;
class cClientHandle;
class cBlockEntity;
-typedef std::list<cEntity *> cEntityList;
+typedef std::vector<std::unique_ptr<cEntity>> cEntityList;
typedef std::list<cBlockEntity *> cBlockEntityList;
@@ -53,6 +53,32 @@ typedef unsigned char HEIGHTTYPE;
+
+class cChunkCoords
+{
+public:
+ int m_ChunkX;
+ int m_ChunkZ;
+
+ cChunkCoords(int a_ChunkX, int a_ChunkZ) : m_ChunkX(a_ChunkX), m_ChunkZ(a_ChunkZ) {}
+
+ bool operator == (const cChunkCoords & a_Other) const
+ {
+ return ((m_ChunkX == a_Other.m_ChunkX) && (m_ChunkZ == a_Other.m_ChunkZ));
+ }
+
+ bool operator != (const cChunkCoords & a_Other) const
+ {
+ return !operator == (a_Other);
+ }
+};
+
+typedef std::vector<cChunkCoords> cChunkCoordsVector;
+
+
+
+
+
/** Constants used throughout the code, useful typedefs and utility functions */
class cChunkDef
{
@@ -142,6 +168,12 @@ public:
}
}
+ /** Converts absolute block coords to chunk coords. */
+ inline static cChunkCoords BlockToChunk(const Vector3i & a_Position)
+ {
+ return { FloorC(a_Position.x / cChunkDef::Width), FloorC(a_Position.x / cChunkDef::Width) };
+ }
+
inline static int MakeIndex(int x, int y, int z)
{
@@ -411,27 +443,6 @@ typedef std::vector<sSetBlock> sSetBlockVector;
-class cChunkCoords
-{
-public:
- int m_ChunkX;
- int m_ChunkZ;
-
- cChunkCoords(int a_ChunkX, int a_ChunkZ) : m_ChunkX(a_ChunkX), m_ChunkZ(a_ChunkZ) {}
-
- bool operator == (const cChunkCoords & a_Other) const
- {
- return ((m_ChunkX == a_Other.m_ChunkX) && (m_ChunkZ == a_Other.m_ChunkZ));
- }
-} ;
-
-typedef std::list<cChunkCoords> cChunkCoordsList;
-typedef std::vector<cChunkCoords> cChunkCoordsVector;
-
-
-
-
-
/** A simple hash function for chunk coords, we assume that chunk coords won't use more than 16 bits, so the hash is almost an identity.
Used for std::unordered_map<cChunkCoords, ...> */
class cChunkCoordsHash