From 94f414e570fa4f95a863d476ae9f034f3d60e379 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 24 Jan 2024 05:08:14 +0100 Subject: b --- serialize/savegame.cpp | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'serialize') 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 struct atlas_from_type; -template<> struct atlas_from_type { - using Type = ground_atlas; - static StringView name(void* ptr) { return reinterpret_cast(ptr)->name(); } -}; -template<> struct atlas_from_type { - using Type = wall_atlas; - static StringView name(void* ptr) { return reinterpret_cast(ptr)->name(); } -}; -template<> struct atlas_from_type { - using Type = anim_atlas; - static StringView name(void* ptr) { return reinterpret_cast(ptr)->name(); } -}; -template<> struct atlas_from_type { - using Type = anim_atlas; - static StringView name(void* ptr) { return reinterpret_cast(ptr)->name(); } -}; +template<> struct atlas_from_type { using Type = ground_atlas; }; +template<> struct atlas_from_type { using Type = wall_atlas; }; +template<> struct atlas_from_type { using Type = anim_atlas; }; +template<> struct atlas_from_type { using Type = anim_atlas; }; struct reader final : visitor_ { @@ -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::name(a.atlas); + using atlas_type = typename atlas_from_type::Type; + const auto* atlas = reinterpret_cast(a.atlas); + return atlas->name(); } void deserialize_strings_(binary_reader& s) -- cgit v1.2.3