mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 04:21:51 +00:00
[ecs] Move correct number of subpool ranges
Fixes yet another segfault when deleting the last range in the subpool. Also, initialize the subpool's next index.
This commit is contained in:
parent
5ad6ec2757
commit
698ce157b3
2 changed files with 4 additions and 3 deletions
|
@ -88,12 +88,13 @@ ECS_CreateComponentPools (ecs_registry_t *registry)
|
|||
{
|
||||
uint32_t count = registry->components.size;
|
||||
registry->comp_pools = calloc (count, sizeof (ecs_pool_t));
|
||||
registry->subpools = calloc (count, sizeof (ecs_subpool_t));
|
||||
size_t size = registry->max_entities * sizeof (uint32_t);
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
registry->comp_pools[i].sparse = malloc (size);
|
||||
memset (registry->comp_pools[i].sparse, nullent, size);
|
||||
registry->subpools[i].next = nullent;
|
||||
}
|
||||
registry->subpools = calloc (count, sizeof (ecs_subpool_t));
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -81,8 +81,8 @@ ECS_DelSubpoolRange (ecs_registry_t *registry, uint32_t component, uint32_t id)
|
|||
subpool->rangeids[ind] = next;
|
||||
subpool->next = ind;
|
||||
subpool->available++;
|
||||
memmove (subpool->ranges + ind, subpool->ranges + ind + 1,
|
||||
(count - 1 - range) * sizeof (ecs_range_t));
|
||||
memmove (subpool->ranges + range, subpool->ranges + range + 1,
|
||||
(subpool->num_ranges - 1 - range) * sizeof (ecs_range_t));
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
if (subpool->sorted[i] > range) {
|
||||
subpool->sorted[i]--;
|
||||
|
|
Loading…
Reference in a new issue