Prevent implicit conversions from Pos2 and xy32 (#1051)

This commit is contained in:
Duncan 2021-08-05 22:17:54 +01:00 committed by GitHub
parent 3616ec0f7d
commit 4c54152737
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -6,7 +6,7 @@
namespace OpenLoco
{
using xy32 = Math::Vector::TVector2<int32_t, 1>;
using xy32 = Math::Vector::TVector2<int32_t, 1, false>;
namespace Location
{

View File

@ -7,10 +7,11 @@
namespace OpenLoco::Math::Vector
{
#pragma pack(push, 1)
template<typename T, T TResolution>
template<typename T, T TResolution, bool TIsGameSpace = true>
struct TVector2
{
static constexpr auto Resolution = TResolution;
static constexpr auto IsGameSpace = TIsGameSpace;
T x = 0;
T y = 0;
@ -236,8 +237,8 @@ namespace OpenLoco::Math::Vector
return res;
}
template<typename T, T TResolution>
static constexpr auto manhattanDistance(const TVector2<T, TResolution>& lhs, const TVector2<T, TResolution>& rhs)
template<typename T, T TResolution, bool TIsGameSpace>
static constexpr auto manhattanDistance(const TVector2<T, TResolution, TIsGameSpace>& lhs, const TVector2<T, TResolution, TIsGameSpace>& rhs)
{
return std::abs(lhs.x - rhs.x) + std::abs(lhs.y - rhs.y);
}