Fix LuaRED ToRED conversion for 64-bit integral types
@@ -31,9 +31,21 @@ struct LuaRED
result.value = apAllocator->New<T>();
}
else if (!CheckObjectType || aObject.is<T>())
+ {
+ if constexpr (std::is_integral_v<T> && (sizeof(T) == sizeof(uint64_t)))
+ {
+ sol::state_view v(aObject.lua_state());
+ std::string str = v["tostring"](aObject);
+ if constexpr (std::is_signed_v<T>)
+ result.value = apAllocator->New<T>(std::stoll(str));
+ else
+ result.value = apAllocator->New<T>(std::stoull(str));
+ }
+ else
{
result.value = apAllocator->New<T>(aObject.as<T>());
}
+ }
return result;
}
@@ -45,10 +57,22 @@ struct LuaRED
*reinterpret_cast<T*>(apType->value) = T{};
}
else if (!CheckObjectType || aObject.is<T>())
+ {
+ if constexpr (std::is_integral_v<T> && (sizeof(T) == sizeof(uint64_t)))
+ {
+ sol::state_view v(aObject.lua_state());
+ std::string str = v["tostring"](aObject);
+ if constexpr (std::is_signed_v<T>)
+ *reinterpret_cast<T*>(apType->value) = std::stoll(str);
+ else
+ *reinterpret_cast<T*>(apType->value) = std::stoull(str);
+ }
+ else
{
*reinterpret_cast<T*>(apType->value) = aObject.as<T>();
}
}
+ }
size_t Size() const noexcept
{
