From 9d35200ea54a0729d489dc2c76823a2a13cdcac4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 14 Apr 2024 08:53:35 +0200 Subject: add find_object specialization for scenery subtypes --- test/save.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/save.cpp b/test/save.cpp index 8edb5b4d..675041c7 100644 --- a/test/save.cpp +++ b/test/save.cpp @@ -1,6 +1,7 @@ #include "app.hpp" #include "src/world.hpp" #include "loader/loader.hpp" +#include "loader/scenery-cell.hpp" #include "src/scenery.hpp" #include "src/scenery-proto.hpp" #include "src/critter.hpp" @@ -264,18 +265,30 @@ void test_save_objs() fm_assert(p.falloff == obj2.falloff); fm_assert(p.enabled == obj2.enabled); assert_chunks_equal(w.at(ch), w2.at(ch)); + //const auto obj3 = w.find_object(id); // must fail + } + + { + // --- scenery --- + auto w = world(); + scenery_proto p; + p.atlas = loader.invalid_scenery_atlas().proto->atlas; + p.subtype = generic_scenery_proto{}; + constexpr auto ch = chunk_coords_{-3, 4, 0}; + constexpr auto coord = global_coords{ch, { 3, 4}}; + const auto id = w.make_id(); + const auto objʹ = w.make_scenery(id, coord, move(p)); + const auto obj = std::static_pointer_cast(objʹ); + const auto obj2 = w.find_object(id); + //const auto obj3 = w.find_object(id); // must fail + fm_assert(obj == obj2); } #if 0 - constexpr auto coord = global_coords{{-3, 4, 0}, { 3, 4}}; constexpr auto coord = global_coords{{ 5, -6, 0}, { 4, 7}}; constexpr auto coord = global_coords{{-7, 8, 0}, { 9, 1}}; constexpr auto coord = global_coords{{ 9, 0, 0}, {15, 0}}; #endif - - { - - } } } // namespace -- cgit v1.2.3