Skip to content

Commit

Permalink
Add note to FAQ about recycled entity ids
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Aug 4, 2023
1 parent b1a37c6 commit e996463
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,23 @@ This is likely because you're creating a query in a loop. Queries should be crea
## Can Flecs be compiled to web assembly?
Yes it can! See the [quickstart manual](Quickstart.md) for more information.

## Why am I getting an “use of undeclared identifier 'FLECS__E …’” compiler error?
## Why am I getting an “use of undeclared identifier 'FLECS_ID …’” compiler error?
This happens in C if the variable that holds the component id can't be found. This example shows how to fix it: https://github.com/SanderMertens/flecs/tree/master/examples/c/entities/fwd_declare_component

## Why are my entity ids so large?
When you inspect the integer value of an entity you may see that this value is very large, usually around 4 billion. This is not a bug, and instead means that the entity id has been recycled. This example shows when recycling happens:

```cpp
flecs::entity e1 = world.entity(); // small id
e1.destruct(); // id is made available for recycling

flecs::entity e2 = world.entity(); // recycles e1
e1.is_alive(); // false
e2.is_alive(); // true

std::cout << e2.id(); // large id, upper 32 bits contains liveliness count
```

## What is the difference between add & set? Why do both exist?
An `add` just adds a component without assigning a value to it. A `set` assigns a value to the component. Both operations ensure that the entity will have the component afterwards.

Expand Down

0 comments on commit e996463

Please sign in to comment.