mirror of https://github.com/OpenTTD/OpenTTD
Codechange: make strongtype constructor explicit
parent
98e980c478
commit
a22e357911
|
@ -127,8 +127,8 @@ namespace StrongType {
|
||||||
friend constexpr bool operator >=(const TType &lhs, TCompatibleType rhs) { return lhs.value >= static_cast<TBaseType>(rhs); }
|
friend constexpr bool operator >=(const TType &lhs, TCompatibleType rhs) { return lhs.value >= static_cast<TBaseType>(rhs); }
|
||||||
friend constexpr bool operator >(const TType &lhs, TCompatibleType rhs) { return lhs.value > static_cast<TBaseType>(rhs); }
|
friend constexpr bool operator >(const TType &lhs, TCompatibleType rhs) { return lhs.value > static_cast<TBaseType>(rhs); }
|
||||||
|
|
||||||
friend constexpr TType operator +(const TType &lhs, TCompatibleType rhs) { return { static_cast<TBaseType>(lhs.value + rhs) }; }
|
friend constexpr TType operator +(const TType &lhs, TCompatibleType rhs) { return TType{ static_cast<TBaseType>(lhs.value + rhs) }; }
|
||||||
friend constexpr TType operator -(const TType &lhs, TCompatibleType rhs) { return { static_cast<TBaseType>(lhs.value - rhs) }; }
|
friend constexpr TType operator -(const TType &lhs, TCompatibleType rhs) { return TType{ static_cast<TBaseType>(lhs.value - rhs) }; }
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ namespace StrongType {
|
||||||
constexpr Typedef(const Typedef &) = default;
|
constexpr Typedef(const Typedef &) = default;
|
||||||
constexpr Typedef(Typedef &&) = default;
|
constexpr Typedef(Typedef &&) = default;
|
||||||
|
|
||||||
constexpr Typedef(const TBaseType &value) : value(value) {}
|
explicit constexpr Typedef(const TBaseType &value) : value(value) {}
|
||||||
|
|
||||||
constexpr Typedef &operator =(const Typedef &rhs) { this->value = rhs.value; return *this; }
|
constexpr Typedef &operator =(const Typedef &rhs) { this->value = rhs.value; return *this; }
|
||||||
constexpr Typedef &operator =(Typedef &&rhs) { this->value = std::move(rhs.value); return *this; }
|
constexpr Typedef &operator =(Typedef &&rhs) { this->value = std::move(rhs.value); return *this; }
|
||||||
|
|
|
@ -442,6 +442,9 @@ inline TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
|
||||||
return TileDiffXY(tidc.x, tidc.y);
|
return TileDiffXY(tidc.x, tidc.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Helper functions to provide explicit +=/-= operators for TileIndex and TileIndexDiff. */
|
||||||
|
constexpr TileIndex &operator+=(TileIndex &tile, TileIndexDiff offset) { tile = tile + TileIndex(offset); return tile; }
|
||||||
|
constexpr TileIndex &operator-=(TileIndex &tile, TileIndexDiff offset) { tile = tile - TileIndex(offset); return tile; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a given offset to a tile.
|
* Adds a given offset to a tile.
|
||||||
|
|
|
@ -76,7 +76,7 @@ void UpdateHousesAndTowns()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for cases when a NewGRF has set a wrong house substitute type. */
|
/* Check for cases when a NewGRF has set a wrong house substitute type. */
|
||||||
for (const auto t : Map::Iterate()) {
|
for (const TileIndex &t : Map::Iterate()) {
|
||||||
if (!IsTileType(t, MP_HOUSE)) continue;
|
if (!IsTileType(t, MP_HOUSE)) continue;
|
||||||
|
|
||||||
HouseID house_type = GetCleanHouseType(t);
|
HouseID house_type = GetCleanHouseType(t);
|
||||||
|
|
Loading…
Reference in New Issue