diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-01-15 19:27:53 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-01-15 19:27:53 +0100 |
commit | 785293f4bf1beec65d23be0612e545e4c26ec366 (patch) | |
tree | f250c34d82977116498b8049c8055fc3981478ab /loader | |
parent | a5acc700d6a3a9b050864cf78a0f9f2305babdff (diff) |
b
Diffstat (limited to 'loader')
-rw-r--r-- | loader/impl.hpp | 2 | ||||
-rw-r--r-- | loader/loader.cpp | 33 | ||||
-rw-r--r-- | loader/loader.hpp | 8 |
3 files changed, 32 insertions, 11 deletions
diff --git a/loader/impl.hpp b/loader/impl.hpp index 5f1a8ff0..a4a33747 100644 --- a/loader/impl.hpp +++ b/loader/impl.hpp @@ -22,13 +22,13 @@ struct loader_impl final : loader_ { explicit loader_impl(); ~loader_impl() override; - // >-----> system >-----> String original_working_directory; void set_application_working_directory(); StringView startup_directory() noexcept override; static void system_init(); + void destroy() override; static bool chdir(StringView pathname); // >-----> plugins >-----> diff --git a/loader/loader.cpp b/loader/loader.cpp index df712f39..af7b053f 100644 --- a/loader/loader.cpp +++ b/loader/loader.cpp @@ -1,15 +1,36 @@ #include "impl.hpp" +#include "ground-info.hpp" +#include "wall-info.hpp" +#include "scenery.hpp" -namespace floormat { - -using loader_detail::loader_impl; +namespace floormat::loader_detail { -void loader_::destroy() +void loader_impl::destroy() { - loader.~loader_(); - new (&loader) loader_impl(); + wall_atlas_map.clear(); + wall_atlas_array.clear(); + invalid_wall_atlas = nullptr; + missing_wall_atlases.clear(); + + ground_atlas_map.clear(); + ground_atlas_array.clear(); + invalid_ground_atlas = nullptr; + missing_ground_atlases.clear(); + + anim_atlas_map.clear(); + anim_atlases.clear(); + sceneries_map.clear(); + sceneries_array.clear(); + vobj_atlas_map.clear(); + vobjs.clear(); } +} // namespace floormat::loader_detail + +namespace floormat { + +using loader_detail::loader_impl; + loader_& loader_::default_loader() noexcept { static loader_impl loader_singleton{}; diff --git a/loader/loader.hpp b/loader/loader.hpp index 477a5dd0..51a15b14 100644 --- a/loader/loader.hpp +++ b/loader/loader.hpp @@ -1,4 +1,5 @@ #pragma once +#include "compat/defs.hpp" #include "src/pass-mode.hpp" #include <stdio.h> #include <memory> @@ -37,7 +38,7 @@ struct loader_ virtual std::shared_ptr<class anim_atlas> anim_atlas(StringView name, StringView dir = ANIM_PATH) noexcept(false) = 0; virtual std::shared_ptr<class wall_atlas> wall_atlas(StringView name, bool fail_ok = false) noexcept(false) = 0; virtual ArrayView<const wall_info> wall_atlas_list() = 0; - static void destroy(); + virtual void destroy() = 0; static loader_& default_loader() noexcept; virtual ArrayView<const ground_info> ground_atlas_list() noexcept(false) = 0; virtual ArrayView<const serialized_scenery> sceneries() = 0; @@ -49,10 +50,9 @@ struct loader_ static StringView make_atlas_path(char(&buf)[FILENAME_MAX], StringView dir, StringView name); [[nodiscard]] static bool check_atlas_name(StringView name) noexcept; - loader_(const loader_&) = delete; - loader_& operator=(const loader_&) = delete; - virtual ~loader_() noexcept; + fm_DECLARE_DELETED_COPY_ASSIGNMENT(loader_); + fm_DECLARE_DELETED_MOVE_ASSIGNMENT(loader_); static const StringView INVALID; static const StringView IMAGE_PATH_; |