1
0
Fork 0

Replaced a std::hash specialization with explicit type.

std::hash is problematic in gcc / clang, one has a class, the other a struct.
This commit is contained in:
Mattes D 2014-12-24 08:38:37 +01:00
parent 9c5463be1e
commit 63de5f8a55
2 changed files with 4 additions and 8 deletions

View File

@ -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

View File

@ -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);