summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-05-03 18:39:46 +0200
committerStanislaw Halik <sthalik@misaki.pl>2024-05-05 03:16:22 +0200
commitba91cb1393274072721e1c31db0c7f73dc9c9db7 (patch)
treee457bb2ddbd16187c6e2fc34988d09b5afabb659
parenta549fdf835a8548e09084156137cb26e869e8901 (diff)
expose script init status
-rw-r--r--editor/update.cpp7
-rw-r--r--src/world.cpp5
-rw-r--r--src/world.hpp3
3 files changed, 14 insertions, 1 deletions
diff --git a/editor/update.cpp b/editor/update.cpp
index e461c9b4..7fdcd77e 100644
--- a/editor/update.cpp
+++ b/editor/update.cpp
@@ -310,10 +310,15 @@ auto app::get_z_bounds() -> z_bounds
void app::update(Ns dt)
{
- M->world().collect(true);
+ auto& w = M->world();
+ w.collect(true);
update_cursor_tile(cursor.pixel);
tests_pre_update(dt);
apply_commands(*keys_);
+ { auto status = w.script_status();
+ fm_assert(status.initialized);
+ fm_assert(!status.finalized);
+ }
update_character(dt);
update_world(dt);
do_camera(dt, *keys_, get_key_modifiers());
diff --git a/src/world.cpp b/src/world.cpp
index bdc74218..c0a6cc39 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -262,6 +262,11 @@ void world::finish_scripts()
obj->destroy_script_post();
}
+struct world::script_status world::script_status() const
+{
+ return { _script_initialized, _script_finalized };
+}
+
shared_ptr_wrapper<critter> world::ensure_player_character(object_id& id)
{
return ensure_player_character(id, make_player_proto());
diff --git a/src/world.hpp b/src/world.hpp
index 2a3a26f1..fe434e17 100644
--- a/src/world.hpp
+++ b/src/world.hpp
@@ -103,8 +103,11 @@ public:
shared_ptr_wrapper<critter> ensure_player_character(object_id& id);
static critter_proto make_player_proto();
+ struct script_status { bool initialized, finalized; };
void init_scripts();
void finish_scripts();
+ struct script_status script_status() const;
+
bool is_teardown() const;
object_id object_counter() const { return _object_counter; }
[[nodiscard]] object_id make_id() { return ++_object_counter; }