1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#ifndef OPENMW_COMPONENTS_ESM_EXTERIORCELLLOCATION_H
#define OPENMW_COMPONENTS_ESM_EXTERIORCELLLOCATION_H
#include "refid.hpp"
#include <components/esm3/loadcell.hpp>
#include <ostream>
#include <tuple>
namespace ESM
{
struct ExteriorCellLocation
{
int mX = 0;
int mY = 0;
ESM::RefId mWorldspace = ESM::Cell::sDefaultWorldspaceId;
ExteriorCellLocation() = default;
ExteriorCellLocation(int x, int y, ESM::RefId worldspace)
: mX(x)
, mY(y)
, mWorldspace(worldspace)
{
}
friend bool operator==(const ExteriorCellLocation& lhs, const ExteriorCellLocation& rhs) = default;
friend inline bool operator<(const ExteriorCellLocation& lhs, const ExteriorCellLocation& rhs)
{
return std::make_tuple(lhs.mX, lhs.mY, lhs.mWorldspace) < std::make_tuple(rhs.mX, rhs.mY, rhs.mWorldspace);
}
friend inline std::ostream& operator<<(std::ostream& stream, const ExteriorCellLocation& value)
{
return stream << "{" << value.mX << ", " << value.mY << ", " << value.mWorldspace << "}";
}
};
}
namespace std
{
template <>
struct hash<ESM::ExteriorCellLocation>
{
std::size_t operator()(const ESM::ExteriorCellLocation& toHash) const
{
// Compute individual hash values for first,
// second and third and combine them using XOR
// and bit shifting:
return ((hash<int>()(toHash.mX) ^ (hash<int>()(toHash.mY) << 1)) >> 1)
^ (hash<ESM::RefId>()(toHash.mWorldspace) << 1);
}
};
}
#endif
|