summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-04-07 10:03:14 +0200
committerStanislaw Halik <sthalik@misaki.pl>2024-04-07 10:03:14 +0200
commit8382bc2dcfe613652f59c3118fa21d47b874f647 (patch)
treed0a9b5d4053637a6e3f9acf866077cee50a10a9e
parentc3fec2466ed44e3d65b8dceb5a80bc621176d45d (diff)
use static_cast on void* instead of reinterpret_cast
-rw-r--r--editor/inspect.cpp2
-rw-r--r--entity/metadata.hpp20
-rw-r--r--serialize/savegame.cpp8
3 files changed, 15 insertions, 15 deletions
diff --git a/editor/inspect.cpp b/editor/inspect.cpp
index 788ef27a..c4345bcf 100644
--- a/editor/inspect.cpp
+++ b/editor/inspect.cpp
@@ -49,7 +49,7 @@ int corrade_string_resize_callback(ImGuiInputTextCallbackData* data)
{
if (data->EventFlag == ImGuiInputTextFlags_CallbackResize)
{
- auto& str = *reinterpret_cast<String*>(data->UserData);
+ auto& str = *static_cast<String*>(data->UserData);
fm_assert(str.data() == data->Buf);
if ((size_t)data->BufSize > str.size()+1)
{
diff --git a/entity/metadata.hpp b/entity/metadata.hpp
index 3da3dcb0..101af0df 100644
--- a/entity/metadata.hpp
+++ b/entity/metadata.hpp
@@ -158,20 +158,20 @@ constexpr erased_accessor entity_field<Obj, Type, R, W, Ts...>::erased() const
constexpr auto obj_name = name_of<Obj>, field_name = name_of<Type>;
constexpr auto reader_fn = [](const void* obj, const reader_t* reader, void* value) {
- const auto& obj_ = *reinterpret_cast<const Obj*>(obj);
- const auto& reader_ = *reinterpret_cast<const R*>(reader);
- auto& value_ = *reinterpret_cast<Type*>(value);
+ const auto& obj_ = *static_cast<const Obj*>(obj);
+ const auto& reader_ = *static_cast<const R*>(reader);
+ auto& value_ = *static_cast<Type*>(value);
value_ = read(reader_, obj_);
};
constexpr auto writer_fn = [](void* obj, const writer_t* writer, void* value) {
- auto& obj_ = *reinterpret_cast<Obj*>(obj);
- const auto& writer_ = *reinterpret_cast<const W*>(writer);
- Type value_ = move(*reinterpret_cast<Type*>(value));
+ auto& obj_ = *static_cast<Obj*>(obj);
+ const auto& writer_ = *static_cast<const W*>(writer);
+ Type value_ = move(*static_cast<Type*>(value));
write(writer_, obj_, move(value_));
};
constexpr auto predicate_fn = [](const void* obj, const predicate_t* predicate) {
- const auto& obj_ = *reinterpret_cast<const Obj*>(obj);
- const auto& predicate_ = *reinterpret_cast<const Predicate*>(predicate);
+ const auto& obj_ = *static_cast<const Obj*>(obj);
+ const auto& predicate_ = *static_cast<const Predicate*>(predicate);
return is_enabled(predicate_, obj_);
};
constexpr auto writer_stub_fn = [](void*, const writer_t*, void*) {
@@ -180,10 +180,10 @@ constexpr erased_accessor entity_field<Obj, Type, R, W, Ts...>::erased() const
constexpr bool has_writer = !std::is_same_v<std::decay_t<decltype(writer)>, std::nullptr_t>;
constexpr auto c_range_fn = [](const void* obj, const c_range_t* reader) -> erased_constraints::range {
- return get_range(*reinterpret_cast<const Range*>(reader), *reinterpret_cast<const Obj*>(obj));
+ return get_range(*static_cast<const Range*>(reader), *reinterpret_cast<const Obj*>(obj));
};
constexpr auto c_length_fn = [](const void* obj, const c_length_t* reader) -> erased_constraints::max_length {
- return get_max_length(*reinterpret_cast<const Length*>(reader), *reinterpret_cast<const Obj*>(obj));
+ return get_max_length(*static_cast<const Length*>(reader), *reinterpret_cast<const Obj*>(obj));
};
return erased_accessor {
(void*)&reader, has_writer ? (void*)&writer : nullptr,
diff --git a/serialize/savegame.cpp b/serialize/savegame.cpp
index 8e7039e5..34e90993 100644
--- a/serialize/savegame.cpp
+++ b/serialize/savegame.cpp
@@ -460,11 +460,11 @@ struct writer final : visitor_<writer>
switch (type)
{
- case atlas_type::ground: name = reinterpret_cast<const ground_atlas*>(atlas)->name(); break;
- case atlas_type::wall: name = reinterpret_cast<const wall_atlas*>(atlas)->name(); break;
+ case atlas_type::ground: name = static_cast<const ground_atlas*>(atlas)->name(); break;
+ case atlas_type::wall: name = static_cast<const wall_atlas*>(atlas)->name(); break;
case atlas_type::vobj:
case atlas_type::anim:
- name = reinterpret_cast<const anim_atlas*>(atlas)->name();
+ name = static_cast<const anim_atlas*>(atlas)->name();
break;
default:
fm_abort("invalid atlas type '%d'", (int)type);
@@ -896,7 +896,7 @@ struct reader final : visitor_<reader>
auto a = atlases[id];
fm_soft_assert(a.type == Type);
using atlas_type = typename atlas_from_type<Type>::Type;
- const auto* atlas = reinterpret_cast<const atlas_type*>(a.atlas);
+ const auto* atlas = static_cast<const atlas_type*>(a.atlas);
return atlas->name();
}