Skip to content

Commit

Permalink
#124 cleanup type matching code
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Aug 7, 2021
1 parent 918f117 commit 8b24d0d
Show file tree
Hide file tree
Showing 34 changed files with 477 additions and 907 deletions.
2 changes: 1 addition & 1 deletion docs/Manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,7 @@ while (ecs_filter_next(&it)) {
ecs_type_t table_type = ecs_iter_type(&it);

/* First Retrieve the column index for Position */
int32_t p_index = ecs_type_index_of(table_type, ecs_id(Position));
int32_t p_index = ecs_type_index_of(table_type, 0, ecs_id(Position));

/* Now use the column index to get the Position array from the table */
Position *p = ecs_table_column(&it, p_index);
Expand Down
2 changes: 1 addition & 1 deletion docs/Relations.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ ecs_id_t wildcard = ecs_pair(Eats, EcsWildcard);
ecs_id_t *ids = ecs_vector_first(bob_type);
int32_t cur = -1;

while (-1 != (cur = ecs_type_match(type, cur + 1, wildcard))) {
while (-1 != (cur = ecs_type_index_of(type, cur + 1, wildcard))) {
ecs_entity_t obj = ecs_pair_object(ids[cur]);
printf("Bob eats %s\n", ecs_get_name(world, obj));
}
Expand Down
4 changes: 2 additions & 2 deletions examples/c/27_filter_iter/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ int main(int argc, char *argv[]) {

/* Retrieve the column indices for both the Position and Velocity
* columns by finding their position in the table type */
int32_t p_index = ecs_type_index_of(table_type, ecs_id(Position));
int32_t v_index = ecs_type_index_of(table_type, ecs_id(Velocity));
int32_t p_index = ecs_type_index_of(table_type, 0, ecs_id(Position));
int32_t v_index = ecs_type_index_of(table_type, 0, ecs_id(Velocity));

/* Get pointers to the Position and Velocity columns with the obtained
* column indices */
Expand Down
6 changes: 3 additions & 3 deletions examples/c/28_snapshot_filter_iter/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ int main(int argc, char *argv[]) {

/* Retrieve the column indices for both the Position and Velocity
* columns by finding their position in the table type */
int32_t p_index = ecs_type_index_of(table_type, ecs_id(Position));
int32_t v_index = ecs_type_index_of(table_type, ecs_id(Velocity));
int32_t p_index = ecs_type_index_of(table_type, 0, ecs_id(Position));
int32_t v_index = ecs_type_index_of(table_type, 0, ecs_id(Velocity));

/* If we want to display the name of the entities we can't use the
* ecs_get_name function, since it tries to get the id from the world, and
* we just deleted the entities from the world. Therefore, we should get
* the name from the snapshot directly */
int32_t id_index = ecs_type_index_of(table_type,
int32_t id_index = ecs_type_index_of(table_type, 0,
ecs_pair(ecs_id(EcsIdentifier), EcsName));

/* Get pointers to the Position and Velocity columns with the obtained
Expand Down
Loading

0 comments on commit 8b24d0d

Please sign in to comment.