diff --git a/distr/flecs.c b/distr/flecs.c index 1a408490c..2d2dabb8f 100644 --- a/distr/flecs.c +++ b/distr/flecs.c @@ -15786,7 +15786,7 @@ ecs_entity_t ecs_observer_init( const ecs_observer_desc_t *desc) { ecs_entity_t entity = 0; - ecs_check(world != NULL, ECS_INVALID_PARAMETER, NULL); + flecs_poly_assert(world, ecs_world_t); ecs_check(desc != NULL, ECS_INVALID_PARAMETER, NULL); ecs_check(desc->_canary == 0, ECS_INVALID_PARAMETER, "ecs_observer_desc_t was not initialized to zero"); @@ -17205,7 +17205,7 @@ void flecs_stage_merge( bool is_stage = flecs_poly_is(world, ecs_stage_t); ecs_stage_t *stage = flecs_stage_from_world(&world); - bool measure_frame_time = ECS_BIT_IS_SET(world->flags, + bool measure_frame_time = ECS_BIT_IS_SET(ecs_world_get_flags(world), EcsWorldMeasureFrameTime); ecs_time_t t_start = {0}; @@ -20208,6 +20208,8 @@ void flecs_type_info_free( ecs_world_t *world, ecs_entity_t component) { + flecs_poly_assert(world, ecs_world_t); + if (world->flags & EcsWorldQuit) { /* If world is in the final teardown stages, cleanup policies are no * longer applied and it can't be guaranteed that a component is not @@ -25867,6 +25869,7 @@ ecs_entity_t ecs_import( ecs_module_action_t module, const char *module_name) { + flecs_poly_assert(world, ecs_world_t); ecs_check(!(world->flags & EcsWorldReadonly), ECS_INVALID_WHILE_READONLY, NULL); @@ -33230,7 +33233,7 @@ void flecs_query_fini( ecs_id_record_t *idr = flecs_id_record_get(q->real_world, term->id); if (idr) { - if (!(q->world->flags & EcsWorldQuit)) { + if (!(ecs_world_get_flags(q->world) & EcsWorldQuit)) { if (ecs_os_has_threading()) { int32_t idr_keep_alive = ecs_os_adec(&idr->keep_alive); ecs_assert(idr_keep_alive >= 0, ECS_INTERNAL_ERROR, NULL); @@ -38177,6 +38180,8 @@ void flecs_table_fini( ecs_world_t *world, ecs_table_t *table) { + flecs_poly_assert(world, ecs_world_t); + bool is_root = table == &world->store.root; ecs_assert(!table->_->lock, ECS_LOCKED_STORAGE, FLECS_LOCKED_STORAGE_MSG); ecs_assert(is_root || table->id != 0, ECS_INTERNAL_ERROR, NULL); @@ -38499,6 +38504,8 @@ int32_t flecs_table_grow_data( int32_t size, const ecs_entity_t *ids) { + flecs_poly_assert(world, ecs_world_t); + ecs_assert(table != NULL, ECS_INTERNAL_ERROR, NULL); int32_t count = ecs_table_count(table); @@ -39361,6 +39368,8 @@ void flecs_table_notify( ecs_id_t id, ecs_table_event_t *event) { + flecs_poly_assert(world, ecs_world_t); + if (world->flags & EcsWorldFini) { return; } @@ -63694,6 +63703,7 @@ ecs_entity_t flecs_run_intern( ecs_ftime_t delta_time, void *param) { + flecs_poly_assert(world, ecs_world_t); ecs_ftime_t time_elapsed = delta_time; ecs_entity_t tick_source = system_data->tick_source; @@ -63743,6 +63753,8 @@ ecs_entity_t flecs_run_intern( stage = world->stages[0]; } + flecs_poly_assert(stage, ecs_stage_t); + /* Prepare the query iterator */ ecs_iter_t wit, qit = ecs_query_iter(thread_ctx, system_data->query); ecs_iter_t *it = &qit; @@ -67534,6 +67546,8 @@ void flecs_query_cache_rematch_tables( ecs_world_t *world, ecs_query_impl_t *impl) { + flecs_poly_assert(world, ecs_world_t); + ecs_iter_t it; ecs_table_t *table = NULL; ecs_query_cache_table_t *qt = NULL; @@ -67893,7 +67907,11 @@ ecs_query_cache_t* flecs_query_cache_init( const ecs_query_desc_t *const_desc) { ecs_world_t *world = impl->pub.real_world; + flecs_poly_assert(world, ecs_world_t); + ecs_stage_t *stage = impl->stage; + flecs_poly_assert(stage, ecs_stage_t); + ecs_check(world != NULL, ECS_INTERNAL_ERROR, NULL); ecs_check(const_desc != NULL, ECS_INVALID_PARAMETER, NULL); ecs_check(const_desc->_canary == 0, ECS_INVALID_PARAMETER, @@ -68393,6 +68411,7 @@ void flecs_query_cache_build_sorted_table_range( ecs_query_cache_table_list_t *list) { ecs_world_t *world = cache->query->world; + flecs_poly_assert(world, ecs_world_t); ecs_assert(!(world->flags & EcsWorldMultiThreaded), ECS_UNSUPPORTED, "cannot sort query in multithreaded mode"); diff --git a/src/addons/module.c b/src/addons/module.c index 6c1bc4965..f1b0cf6be 100644 --- a/src/addons/module.c +++ b/src/addons/module.c @@ -36,6 +36,7 @@ ecs_entity_t ecs_import( ecs_module_action_t module, const char *module_name) { + flecs_poly_assert(world, ecs_world_t); ecs_check(!(world->flags & EcsWorldReadonly), ECS_INVALID_WHILE_READONLY, NULL); diff --git a/src/addons/system/system.c b/src/addons/system/system.c index 55216554d..7f08e6f79 100644 --- a/src/addons/system/system.c +++ b/src/addons/system/system.c @@ -31,6 +31,7 @@ ecs_entity_t flecs_run_intern( ecs_ftime_t delta_time, void *param) { + flecs_poly_assert(world, ecs_world_t); ecs_ftime_t time_elapsed = delta_time; ecs_entity_t tick_source = system_data->tick_source; @@ -80,6 +81,8 @@ ecs_entity_t flecs_run_intern( stage = world->stages[0]; } + flecs_poly_assert(stage, ecs_stage_t); + /* Prepare the query iterator */ ecs_iter_t wit, qit = ecs_query_iter(thread_ctx, system_data->query); ecs_iter_t *it = &qit; diff --git a/src/observer.c b/src/observer.c index 4eb7433e7..8d57d0e00 100644 --- a/src/observer.c +++ b/src/observer.c @@ -1084,7 +1084,7 @@ ecs_entity_t ecs_observer_init( const ecs_observer_desc_t *desc) { ecs_entity_t entity = 0; - ecs_check(world != NULL, ECS_INVALID_PARAMETER, NULL); + flecs_poly_assert(world, ecs_world_t); ecs_check(desc != NULL, ECS_INVALID_PARAMETER, NULL); ecs_check(desc->_canary == 0, ECS_INVALID_PARAMETER, "ecs_observer_desc_t was not initialized to zero"); diff --git a/src/query/api.c b/src/query/api.c index 6924e959d..3af9ff1cc 100644 --- a/src/query/api.c +++ b/src/query/api.c @@ -277,7 +277,7 @@ void flecs_query_fini( ecs_id_record_t *idr = flecs_id_record_get(q->real_world, term->id); if (idr) { - if (!(q->world->flags & EcsWorldQuit)) { + if (!(ecs_world_get_flags(q->world) & EcsWorldQuit)) { if (ecs_os_has_threading()) { int32_t idr_keep_alive = ecs_os_adec(&idr->keep_alive); ecs_assert(idr_keep_alive >= 0, ECS_INTERNAL_ERROR, NULL); diff --git a/src/query/engine/cache.c b/src/query/engine/cache.c index 1c00b515d..4d1b34edc 100644 --- a/src/query/engine/cache.c +++ b/src/query/engine/cache.c @@ -844,6 +844,8 @@ void flecs_query_cache_rematch_tables( ecs_world_t *world, ecs_query_impl_t *impl) { + flecs_poly_assert(world, ecs_world_t); + ecs_iter_t it; ecs_table_t *table = NULL; ecs_query_cache_table_t *qt = NULL; @@ -1203,7 +1205,11 @@ ecs_query_cache_t* flecs_query_cache_init( const ecs_query_desc_t *const_desc) { ecs_world_t *world = impl->pub.real_world; + flecs_poly_assert(world, ecs_world_t); + ecs_stage_t *stage = impl->stage; + flecs_poly_assert(stage, ecs_stage_t); + ecs_check(world != NULL, ECS_INTERNAL_ERROR, NULL); ecs_check(const_desc != NULL, ECS_INVALID_PARAMETER, NULL); ecs_check(const_desc->_canary == 0, ECS_INVALID_PARAMETER, diff --git a/src/query/engine/cache_order_by.c b/src/query/engine/cache_order_by.c index fd5979840..67e929edb 100644 --- a/src/query/engine/cache_order_by.c +++ b/src/query/engine/cache_order_by.c @@ -85,6 +85,7 @@ void flecs_query_cache_build_sorted_table_range( ecs_query_cache_table_list_t *list) { ecs_world_t *world = cache->query->world; + flecs_poly_assert(world, ecs_world_t); ecs_assert(!(world->flags & EcsWorldMultiThreaded), ECS_UNSUPPORTED, "cannot sort query in multithreaded mode"); diff --git a/src/stage.c b/src/stage.c index d4421c300..f27f554a2 100644 --- a/src/stage.c +++ b/src/stage.c @@ -76,7 +76,7 @@ void flecs_stage_merge( bool is_stage = flecs_poly_is(world, ecs_stage_t); ecs_stage_t *stage = flecs_stage_from_world(&world); - bool measure_frame_time = ECS_BIT_IS_SET(world->flags, + bool measure_frame_time = ECS_BIT_IS_SET(ecs_world_get_flags(world), EcsWorldMeasureFrameTime); ecs_time_t t_start = {0}; diff --git a/src/storage/table.c b/src/storage/table.c index c6e88734f..46af419c9 100644 --- a/src/storage/table.c +++ b/src/storage/table.c @@ -1008,6 +1008,8 @@ void flecs_table_fini( ecs_world_t *world, ecs_table_t *table) { + flecs_poly_assert(world, ecs_world_t); + bool is_root = table == &world->store.root; ecs_assert(!table->_->lock, ECS_LOCKED_STORAGE, FLECS_LOCKED_STORAGE_MSG); ecs_assert(is_root || table->id != 0, ECS_INTERNAL_ERROR, NULL); @@ -1330,6 +1332,8 @@ int32_t flecs_table_grow_data( int32_t size, const ecs_entity_t *ids) { + flecs_poly_assert(world, ecs_world_t); + ecs_assert(table != NULL, ECS_INTERNAL_ERROR, NULL); int32_t count = ecs_table_count(table); @@ -2192,6 +2196,8 @@ void flecs_table_notify( ecs_id_t id, ecs_table_event_t *event) { + flecs_poly_assert(world, ecs_world_t); + if (world->flags & EcsWorldFini) { return; } diff --git a/src/world.c b/src/world.c index ab2008ea5..11ee0ea69 100644 --- a/src/world.c +++ b/src/world.c @@ -1946,6 +1946,8 @@ void flecs_type_info_free( ecs_world_t *world, ecs_entity_t component) { + flecs_poly_assert(world, ecs_world_t); + if (world->flags & EcsWorldQuit) { /* If world is in the final teardown stages, cleanup policies are no * longer applied and it can't be guaranteed that a component is not