@@ -417,35 +417,35 @@ debug_inline static TileIndex TileVirtXY
{
return (y >> 4 << Map::LogX()) + (x >> 4);
}
/**
* Get the X component of a tile
* @param tile the tile to get the X component of
* @return the X component
*/
debug_inline static uint TileX(TileIndex tile)
return tile.value & Map::MaxX();
return static_cast<uint32_t>(tile) & Map::MaxX();
* Get the Y component of a tile
* @param tile the tile to get the Y component of
* @return the Y component
debug_inline static uint TileY(TileIndex tile)
return tile.value >> Map::LogX();
return static_cast<uint32_t>(tile) >> Map::LogX();
* Return the offset between two tiles from a TileIndexDiffC struct.
*
* This function works like #TileDiffXY(int, int) and returns the
* difference between two tiles.
* @param tidc The coordinate of the offset as TileIndexDiffC
* @return The difference between two tiles.
* @see TileDiffXY(int, int)
@@ -44,25 +44,25 @@ public:
EndianBufferWriter &operator <<(const std::tuple<Targs...> &data)
this->WriteTuple(data, std::index_sequence_for<Targs...>{});
return *this;
template <class T, std::enable_if_t<std::disjunction_v<std::negation<std::is_class<T>>, std::is_base_of<StrongTypedefBase, T>>, int> = 0>
EndianBufferWriter &operator <<(const T data)
if constexpr (std::is_enum_v<T>) {
this->Write(static_cast<std::underlying_type_t<const T>>(data));
} else if constexpr (std::is_base_of_v<StrongTypedefBase, T>) {
this->Write(data.value);
this->Write(static_cast<typename T::Type>(data));
} else {
this->Write(data);
template <typename Tvalue, typename Tbuf = std::vector<byte>>
static Tbuf FromValue(const Tvalue &data)
Tbuf buffer;
EndianBufferWriter writer{ buffer };
writer << data;
@@ -137,25 +137,25 @@ public:
EndianBufferReader &operator >>(std::tuple<Targs...> &data)
this->ReadTuple(data, std::index_sequence_for<Targs...>{});
EndianBufferReader &operator >>(T &data)
data = static_cast<T>(this->Read<std::underlying_type_t<T>>());
data.value = this->Read<decltype(data.value)>();
data = this->Read<typename T::Type>();
data = this->Read<T>();
template <typename Tvalue>
static Tvalue ToValue(span<const byte> buffer)
Tvalue result{};
EndianBufferReader reader{ buffer };
reader >> result;
@@ -28,25 +28,25 @@ namespace SQConvert {
* We use a class instead of a plain function to allow us to use partial template specializations.
template <typename T> struct Return;
template <> struct Return<uint8_t> { static inline int Set(HSQUIRRELVM vm, uint8_t res) { sq_pushinteger(vm, (int32_t)res); return 1; } };
template <> struct Return<uint16_t> { static inline int Set(HSQUIRRELVM vm, uint16_t res) { sq_pushinteger(vm, (int32_t)res); return 1; } };
template <> struct Return<uint32_t> { static inline int Set(HSQUIRRELVM vm, uint32_t res) { sq_pushinteger(vm, (int32_t)res); return 1; } };
template <> struct Return<int8_t> { static inline int Set(HSQUIRRELVM vm, int8_t res) { sq_pushinteger(vm, res); return 1; } };
template <> struct Return<int16_t> { static inline int Set(HSQUIRRELVM vm, int16_t res) { sq_pushinteger(vm, res); return 1; } };
template <> struct Return<int32_t> { static inline int Set(HSQUIRRELVM vm, int32_t res) { sq_pushinteger(vm, res); return 1; } };
template <> struct Return<int64_t> { static inline int Set(HSQUIRRELVM vm, int64_t res) { sq_pushinteger(vm, res); return 1; } };
template <> struct Return<Money> { static inline int Set(HSQUIRRELVM vm, Money res) { sq_pushinteger(vm, res); return 1; } };
template <> struct Return<TileIndex> { static inline int Set(HSQUIRRELVM vm, TileIndex res) { sq_pushinteger(vm, (int32_t)res.value); return 1; } };
template <> struct Return<TileIndex> { static inline int Set(HSQUIRRELVM vm, TileIndex res) { sq_pushinteger(vm, (int32_t)static_cast<uint32_t>(res)); return 1; } };
template <> struct Return<bool> { static inline int Set(HSQUIRRELVM vm, bool res) { sq_pushbool (vm, res); return 1; } };
template <> struct Return<char *> { /* Do not use char *, use std::optional<std::string> instead. */ };
template <> struct Return<const char *> { /* Do not use const char *, use std::optional<std::string> instead. */ };
template <> struct Return<void *> { static inline int Set(HSQUIRRELVM vm, void *res) { sq_pushuserpointer(vm, res); return 1; } };
template <> struct Return<HSQOBJECT> { static inline int Set(HSQUIRRELVM vm, HSQOBJECT res) { sq_pushobject(vm, res); return 1; } };
template <> struct Return<std::optional<std::string>> {
static inline int Set(HSQUIRRELVM vm, std::optional<std::string> res) {
if (res.has_value()) {
sq_pushstring(vm, res.value(), -1);
sq_pushnull(vm);
Status change: