diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-01-24 05:08:14 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-01-24 05:08:14 +0100 |
commit | 94f414e570fa4f95a863d476ae9f034f3d60e379 (patch) | |
tree | 6f50d6e65edfce00b862e2812f071a64f3498b63 /serialize | |
parent | 8ad20c5e659dea5d2b23bb060f81359be887820d (diff) |
b
Diffstat (limited to 'serialize')
-rw-r--r-- | serialize/savegame.cpp | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/serialize/savegame.cpp b/serialize/savegame.cpp index 965f4fca..af151684 100644 --- a/serialize/savegame.cpp +++ b/serialize/savegame.cpp @@ -698,22 +698,10 @@ void world::serialize(StringView filename) namespace { template<atlas_type Type> struct atlas_from_type; -template<> struct atlas_from_type<atlas_type::ground> { - using Type = ground_atlas; - static StringView name(void* ptr) { return reinterpret_cast<Type*>(ptr)->name(); } -}; -template<> struct atlas_from_type<atlas_type::wall> { - using Type = wall_atlas; - static StringView name(void* ptr) { return reinterpret_cast<Type*>(ptr)->name(); } -}; -template<> struct atlas_from_type<atlas_type::anim> { - using Type = anim_atlas; - static StringView name(void* ptr) { return reinterpret_cast<Type*>(ptr)->name(); } -}; -template<> struct atlas_from_type<atlas_type::vobj> { - using Type = anim_atlas; - static StringView name(void* ptr) { return reinterpret_cast<Type*>(ptr)->name(); } -}; +template<> struct atlas_from_type<atlas_type::ground> { using Type = ground_atlas; }; +template<> struct atlas_from_type<atlas_type::wall> { using Type = wall_atlas; }; +template<> struct atlas_from_type<atlas_type::anim> { using Type = anim_atlas; }; +template<> struct atlas_from_type<atlas_type::vobj> { using Type = anim_atlas; }; struct reader final : visitor_<reader> { @@ -837,7 +825,9 @@ ok: fm_soft_assert(id < atlases.size()); auto a = atlases[id]; fm_soft_assert(a.type == Type); - return atlas_from_type<Type>::name(a.atlas); + using atlas_type = typename atlas_from_type<Type>::Type; + const auto* atlas = reinterpret_cast<const atlas_type*>(a.atlas); + return atlas->name(); } void deserialize_strings_(binary_reader<const char*>& s) |