diff --git a/distr/flecs.c b/distr/flecs.c index 83d13d254..c69928476 100644 --- a/distr/flecs.c +++ b/distr/flecs.c @@ -19765,6 +19765,13 @@ ecs_entities_t ecs_get_entities( return result; } +ecs_flags32_t ecs_world_get_flags( + const ecs_world_t *world) +{ + flecs_poly_assert(world, ecs_world_t); + return world->flags; +} + /** * @file addons/alerts.c * @brief Alerts addon. diff --git a/distr/flecs.h b/distr/flecs.h index 7df5091fe..964c88708 100644 --- a/distr/flecs.h +++ b/distr/flecs.h @@ -5167,6 +5167,17 @@ FLECS_API ecs_entities_t ecs_get_entities( const ecs_world_t *world); +/** Get flags set on the world. + * This operation returns the internal flags (see api_flags.h) that are + * set on the world. + * + * @param world The world. + * @return Flags set on the world. + */ +FLECS_API +ecs_flags32_t ecs_world_get_flags( + const ecs_world_t *world); + /** @} */ /** diff --git a/include/flecs.h b/include/flecs.h index 94e87221b..a5a7e8f65 100644 --- a/include/flecs.h +++ b/include/flecs.h @@ -1953,6 +1953,17 @@ FLECS_API ecs_entities_t ecs_get_entities( const ecs_world_t *world); +/** Get flags set on the world. + * This operation returns the internal flags (see api_flags.h) that are + * set on the world. + * + * @param world The world. + * @return Flags set on the world. + */ +FLECS_API +ecs_flags32_t ecs_world_get_flags( + const ecs_world_t *world); + /** @} */ /** diff --git a/src/world.c b/src/world.c index b5fb1a7c3..ce0792e34 100644 --- a/src/world.c +++ b/src/world.c @@ -2220,3 +2220,10 @@ ecs_entities_t ecs_get_entities( result.alive_count = flecs_entities_count(world); return result; } + +ecs_flags32_t ecs_world_get_flags( + const ecs_world_t *world) +{ + flecs_poly_assert(world, ecs_world_t); + return world->flags; +} diff --git a/test/core/project.json b/test/core/project.json index ea2866f71..bceedca94 100644 --- a/test/core/project.json +++ b/test/core/project.json @@ -1993,7 +1993,8 @@ "set_get_binding_context_w_free", "get_entities", "run_post_frame", - "run_post_frame_outside_of_frame" + "run_post_frame_outside_of_frame", + "get_flags" ] }, { "id": "WorldInfo", diff --git a/test/core/src/World.c b/test/core/src/World.c index 0595490ef..6b768b6fd 100644 --- a/test/core/src/World.c +++ b/test/core/src/World.c @@ -1738,3 +1738,19 @@ void World_run_post_frame_outside_of_frame(void) { int ctx = 10; ecs_run_post_frame(world, post_frame_action, &ctx); } + +void World_get_flags(void) { + ecs_world_t *world = ecs_mini(); + + test_assert(!(ecs_world_get_flags(world) & EcsWorldFrameInProgress)); + + ecs_frame_begin(world, 0); + + test_assert((ecs_world_get_flags(world) & EcsWorldFrameInProgress)); + + ecs_frame_end(world); + + test_assert(!(ecs_world_get_flags(world) & EcsWorldFrameInProgress)); + + ecs_fini(world); +} diff --git a/test/core/src/main.c b/test/core/src/main.c index 531c22347..117b49528 100644 --- a/test/core/src/main.c +++ b/test/core/src/main.c @@ -1919,6 +1919,7 @@ void World_set_get_binding_context_w_free(void); void World_get_entities(void); void World_run_post_frame(void); void World_run_post_frame_outside_of_frame(void); +void World_get_flags(void); // Testsuite 'WorldInfo' void WorldInfo_get_tick(void); @@ -9681,6 +9682,10 @@ bake_test_case World_testcases[] = { { "run_post_frame_outside_of_frame", World_run_post_frame_outside_of_frame + }, + { + "get_flags", + World_get_flags } }; @@ -11209,7 +11214,7 @@ static bake_test_suite suites[] = { "World", World_setup, NULL, - 65, + 66, World_testcases }, {