mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 07:11:41 +00:00
[ecs] Avoid shuffling components in empty ranges
When bubbling a component past an empty range, there's no need for any actual movement other than adjusting the range itself, and doing so corrupts the sparse/dense array relationship. Fixes a segfault when hiding the deathmatch overlay (that resulted from the change to using canvases).
This commit is contained in:
parent
03e867f0f8
commit
3d52caadec
1 changed files with 6 additions and 4 deletions
|
@ -123,10 +123,12 @@ Ent_RemoveComponent (uint32_t ent, uint32_t comp, ecs_registry_t *registry)
|
|||
while (range - subpool->ranges < range_count) {
|
||||
uint32_t end = --*range;
|
||||
range++;
|
||||
pool->sparse[Ent_Index (pool->dense[end])] = ind;
|
||||
pool->dense[ind] = pool->dense[end];
|
||||
Component_MoveElements (c, pool->data, ind, end, 1);
|
||||
ind = end;
|
||||
if (ind < end) {
|
||||
pool->sparse[Ent_Index (pool->dense[end])] = ind;
|
||||
pool->dense[ind] = pool->dense[end];
|
||||
Component_MoveElements (c, pool->data, ind, end, 1);
|
||||
ind = end;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (last > ind) {
|
||||
|
|
Loading…
Reference in a new issue