@@ -475,7 +475,7 @@ struct ecs_table_t {
475
475
476
476
ecs_graph_node_t node; /* Graph node */
477
477
ecs_data_t storage; /* Component storage */
478
- ecs_type_info_t **c_info ; /* Cached pointers to component info */
478
+ ecs_type_info_t **type_info ; /* Cached pointers to type info */
479
479
480
480
int32_t *dirty_state; /* Keep track of changes in columns */
481
481
int32_t alloc_count; /* Increases when columns are reallocd */
@@ -2159,8 +2159,8 @@ void check_table_sanity(ecs_table_t *table) {
2159
2159
for (i = 0; i < storage_count; i ++) {
2160
2160
ecs_type_info_t *ti = NULL;
2161
2161
ecs_column_t *column = &table->storage.columns[i];
2162
- if (table->c_info ) {
2163
- ti = table->c_info [i];
2162
+ if (table->type_info ) {
2163
+ ti = table->type_info [i];
2164
2164
}
2165
2165
if (ti) {
2166
2166
ecs_assert(ti->size == column->size, ECS_INTERNAL_ERROR, NULL);
@@ -2389,7 +2389,7 @@ void init_type_info(
2389
2389
ecs_id_t *ids = ecs_vector_first(type, ecs_id_t);
2390
2390
int32_t i, count = ecs_vector_count(type);
2391
2391
2392
- table->c_info = ecs_os_calloc_n(ecs_type_info_t*, count);
2392
+ table->type_info = ecs_os_calloc_n(ecs_type_info_t*, count);
2393
2393
2394
2394
for (i = 0; i < count; i ++) {
2395
2395
ecs_id_t id = ids[i];
@@ -2400,7 +2400,7 @@ void init_type_info(
2400
2400
table->flags |= get_component_action_flags(ti);
2401
2401
}
2402
2402
2403
- table->c_info [i] = (ecs_type_info_t*)ti;
2403
+ table->type_info [i] = (ecs_type_info_t*)ti;
2404
2404
}
2405
2405
}
2406
2406
@@ -2659,7 +2659,7 @@ void dtor_all_components(
2659
2659
/* Run on_remove callbacks in bulk for improved performance */
2660
2660
for (c = 0; c < column_count; c++) {
2661
2661
ecs_column_t *column = &data->columns[c];
2662
- ecs_type_info_t *cdata = table->c_info [c];
2662
+ ecs_type_info_t *cdata = table->type_info [c];
2663
2663
if (!cdata) {
2664
2664
continue;
2665
2665
}
@@ -2680,7 +2680,7 @@ void dtor_all_components(
2680
2680
for (i = row; i < end; i ++) {
2681
2681
for (c = 0; c < column_count; c++) {
2682
2682
ecs_column_t *column = &data->columns[c];
2683
- dtor_component(world, table, table->c_info [c], column,
2683
+ dtor_component(world, table, table->type_info [c], column,
2684
2684
entities, ids[c], i, 1, false);
2685
2685
}
2686
2686
@@ -2911,8 +2911,8 @@ void flecs_table_free(
2911
2911
ecs_os_free(table->dirty_state);
2912
2912
ecs_os_free(table->storage_map);
2913
2913
2914
- if (table->c_info ) {
2915
- ecs_os_free(table->c_info );
2914
+ if (table->type_info ) {
2915
+ ecs_os_free(table->type_info );
2916
2916
}
2917
2917
2918
2918
flecs_table_records_unregister(world, table);
@@ -3254,7 +3254,7 @@ int32_t grow_data(
3254
3254
ecs_os_memset(r, 0, ECS_SIZEOF(ecs_record_t*) * to_add);
3255
3255
3256
3256
/* Add elements to each column array */
3257
- ecs_type_info_t **c_info_array = table->c_info ;
3257
+ ecs_type_info_t **c_info_array = table->type_info ;
3258
3258
ecs_entity_t *entities = ecs_vector_first(data->entities, ecs_entity_t);
3259
3259
for (i = 0; i < column_count; i ++) {
3260
3260
ecs_column_t *column = &columns[i];
@@ -3365,7 +3365,7 @@ int32_t flecs_table_append(
3365
3365
ecs_sw_column_t *sw_columns = table->storage.sw_columns;
3366
3366
ecs_bs_column_t *bs_columns = table->storage.bs_columns;
3367
3367
3368
- ecs_type_info_t **c_info_array = table->c_info ;
3368
+ ecs_type_info_t **c_info_array = table->type_info ;
3369
3369
ecs_entity_t *entities = ecs_vector_first(
3370
3370
data->entities, ecs_entity_t);
3371
3371
@@ -3506,7 +3506,7 @@ void flecs_table_delete(
3506
3506
}
3507
3507
3508
3508
/* Destruct component data */
3509
- ecs_type_info_t **c_info_array = table->c_info ;
3509
+ ecs_type_info_t **c_info_array = table->type_info ;
3510
3510
ecs_column_t *columns = data->columns;
3511
3511
int32_t column_count = ecs_vector_count(table->storage_type);
3512
3512
int32_t i;
@@ -3720,7 +3720,7 @@ void flecs_table_move(
3720
3720
ecs_assert(dst != NULL, ECS_INTERNAL_ERROR, NULL);
3721
3721
ecs_assert(src != NULL, ECS_INTERNAL_ERROR, NULL);
3722
3722
3723
- ecs_type_info_t *ti = new_table->c_info [i_new];
3723
+ ecs_type_info_t *ti = new_table->type_info [i_new];
3724
3724
if (same_entity) {
3725
3725
ecs_move_t callback;
3726
3726
if (ti && (callback = ti->lifecycle.ctor_move_dtor)) {
@@ -3740,11 +3740,11 @@ void flecs_table_move(
3740
3740
} else {
3741
3741
if (new_component < old_component) {
3742
3742
if (construct) {
3743
- ctor_component(world, new_table->c_info [i_new],
3743
+ ctor_component(world, new_table->type_info [i_new],
3744
3744
&new_columns[i_new], &dst_entity, new_index, 1);
3745
3745
}
3746
3746
} else {
3747
- dtor_component(world, old_table, old_table->c_info [i_old],
3747
+ dtor_component(world, old_table, old_table->type_info [i_old],
3748
3748
&old_columns[i_old], &src_entity, old_component,
3749
3749
old_index, 1, true);
3750
3750
}
@@ -3756,13 +3756,13 @@ void flecs_table_move(
3756
3756
3757
3757
if (construct) {
3758
3758
for (; (i_new < new_column_count); i_new ++) {
3759
- ctor_component(world, new_table->c_info [i_new],
3759
+ ctor_component(world, new_table->type_info [i_new],
3760
3760
&new_columns[i_new], &dst_entity, new_index, 1);
3761
3761
}
3762
3762
}
3763
3763
3764
3764
for (; (i_old < old_column_count); i_old ++) {
3765
- dtor_component(world, old_table, old_table->c_info [i_old],
3765
+ dtor_component(world, old_table, old_table->type_info [i_old],
3766
3766
&old_columns[i_old], &src_entity, old_components[i_old],
3767
3767
old_index, 1, true);
3768
3768
}
@@ -3975,7 +3975,7 @@ void merge_column(
3975
3975
ecs_vector_t *src)
3976
3976
{
3977
3977
ecs_entity_t *entities = ecs_vector_first(data->entities, ecs_entity_t);
3978
- ecs_type_info_t *ti = table->c_info [column_id];
3978
+ ecs_type_info_t *ti = table->type_info [column_id];
3979
3979
ecs_column_t *column = &data->columns[column_id];
3980
3980
ecs_vector_t *dst = column->data;
3981
3981
int16_t size = column->size;
@@ -4087,7 +4087,7 @@ void merge_table_data(
4087
4087
old_count + new_count);
4088
4088
4089
4089
/* Construct new values */
4090
- ecs_type_info_t *c_info = new_table->c_info [i_new];
4090
+ ecs_type_info_t *c_info = new_table->type_info [i_new];
4091
4091
if (c_info) {
4092
4092
ctor_component(world, c_info, column,
4093
4093
entities, 0, old_count + new_count);
@@ -4098,7 +4098,7 @@ void merge_table_data(
4098
4098
ecs_column_t *column = &old_columns[i_old];
4099
4099
4100
4100
/* Destruct old values */
4101
- ecs_type_info_t *c_info = old_table->c_info [i_old];
4101
+ ecs_type_info_t *c_info = old_table->type_info [i_old];
4102
4102
if (c_info) {
4103
4103
dtor_component(world, old_table, c_info, column,
4104
4104
entities, 0, 0, old_count, false);
@@ -4128,7 +4128,7 @@ void merge_table_data(
4128
4128
old_count + new_count);
4129
4129
4130
4130
/* Construct new values */
4131
- ecs_type_info_t *c_info = new_table->c_info [i_new];
4131
+ ecs_type_info_t *c_info = new_table->type_info [i_new];
4132
4132
if (c_info) {
4133
4133
ctor_component(world, c_info, column,
4134
4134
entities, 0, old_count + new_count);
@@ -4140,7 +4140,7 @@ void merge_table_data(
4140
4140
ecs_column_t *column = &old_columns[i_old];
4141
4141
4142
4142
/* Destruct old values */
4143
- ecs_type_info_t *c_info = old_table->c_info [i_old];
4143
+ ecs_type_info_t *c_info = old_table->type_info [i_old];
4144
4144
if (c_info) {
4145
4145
dtor_component(world, old_table, c_info, column, entities, 0,
4146
4146
0, old_count, false);
@@ -23065,6 +23065,13 @@ int init_type(
23065
23065
EcsMetaType *meta_type = ecs_get_mut(world, type, EcsMetaType, &is_added);
23066
23066
if (is_added) {
23067
23067
meta_type->existing = ecs_has(world, type, EcsComponent);
23068
+
23069
+ /* Ensure that component has a default constructor, to prevent crashing
23070
+ * serializers on uninitialized values. */
23071
+ ecs_type_info_t *ti = flecs_ensure_type_info(world, type);
23072
+ if (!ti->lifecycle.ctor) {
23073
+ ti->lifecycle.ctor = ecs_default_ctor;
23074
+ }
23068
23075
} else {
23069
23076
if (meta_type->kind != kind) {
23070
23077
ecs_err("type '%s' reregistered with different kind",
@@ -35610,12 +35617,6 @@ ecs_type_info_t* flecs_ensure_type_info(
35610
35617
ti_mut = flecs_sparse_ensure(
35611
35618
world->type_info, ecs_type_info_t, component);
35612
35619
ecs_assert(ti_mut != NULL, ECS_INTERNAL_ERROR, NULL);
35613
-
35614
- /* Assign default ctor but don't set lifecycle_set to true. This will
35615
- * cause components to be initialized to 0 by default unless overridden
35616
- * by the application, while still allowing the application to override
35617
- * the ctor callback */
35618
- ti_mut->lifecycle.ctor = ecs_default_ctor;
35619
35620
} else {
35620
35621
ti_mut = (ecs_type_info_t*)ti;
35621
35622
}
@@ -43603,7 +43604,7 @@ void init_table(
43603
43604
ecs_world_t *world,
43604
43605
ecs_table_t *table)
43605
43606
{
43606
- table->c_info = NULL;
43607
+ table->type_info = NULL;
43607
43608
table->flags = 0;
43608
43609
table->dirty_state = NULL;
43609
43610
table->alloc_count = 0;
0 commit comments