mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
[scene] Return existing component instead of null
While checking on how Ent_AddComponent behaved (I don't remember what I was looking for, though), I realized that instead of treating adding the same component to an entity as an error, Ent_AddComponent should just return the existing component.
This commit is contained in:
parent
f37c31a2dc
commit
9e83ded0ac
1 changed files with 4 additions and 5 deletions
|
@ -68,15 +68,14 @@ ECS_RegisterComponents (ecs_registry_t *registry,
|
|||
}
|
||||
}
|
||||
|
||||
VISIBLE void*
|
||||
VISIBLE void *
|
||||
Ent_AddComponent (uint32_t ent, uint32_t comp, ecs_registry_t *registry)
|
||||
{
|
||||
uint32_t id = Ent_Index (ent);
|
||||
ecs_pool_t *pool = ®istry->comp_pools[comp];
|
||||
if (pool->sparse[id] < pool->count) {
|
||||
//Sys_Error ("Ent_AddComponent: component %s already on entity %x\n",
|
||||
// registry->components[i].name, ent);
|
||||
return 0;
|
||||
if (pool->sparse[id] < pool->count
|
||||
&& pool->dense[pool->sparse[id]] == ent) {
|
||||
return Ent_GetComponent (ent, comp, registry);
|
||||
}
|
||||
if (pool->count == pool->max_count) {
|
||||
pool->max_count += COMP_GROW;
|
||||
|
|
Loading…
Reference in a new issue