diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ChunkDef.h | 10 | ||||
-rw-r--r-- | src/Entities/Player.cpp | 2 |
2 files changed, 4 insertions, 8 deletions
diff --git a/src/ChunkDef.h b/src/ChunkDef.h index 959841ecc..2bfa2949c 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -399,21 +399,17 @@ public: typedef std::list<cChunkCoords> cChunkCoordsList; typedef std::vector<cChunkCoords> cChunkCoordsVector; -namespace std -{ - /** 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, ...> */ -template<> struct hash<cChunkCoords> +class cChunkCoordsHash { - size_t operator ()(const cChunkCoords & a_Coords) +public: + size_t operator () (const cChunkCoords & a_Coords) const { return (static_cast<size_t>(a_Coords.m_ChunkX) << 16) ^ static_cast<size_t>(a_Coords.m_ChunkZ); } }; -} // namespace std - diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 7bdd1c6f7..1d5cc6554 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -2206,7 +2206,7 @@ void cPlayer::SendBlocksAround(int a_BlockX, int a_BlockY, int a_BlockZ, int a_R } // Divide the block changes by their respective chunks: - std::unordered_map<cChunkCoords, sSetBlockVector> Changes; + std::unordered_map<cChunkCoords, sSetBlockVector, cChunkCoordsHash> Changes; for (const auto & blk: blks) { Changes[cChunkCoords(blk.m_ChunkX, blk.m_ChunkZ)].push_back(blk); |