Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple problems with the memory handler regarding unused entities #240

Open
SleepProgger opened this issue Jun 11, 2017 · 0 comments
Open

Comments

@SleepProgger
Copy link
Contributor

  1. The memory_handler.utils.memrange_iter doesn't properly handle freed entities.
    It is casting the void pointer to unsigned int and checks for -1 instead of using the value located at that pointer address. That one is simple to fix like:
        ...
        cdef unsigned int* pointer
        if current >= self.end:
            raise StopIteration
        else:
            pool_index = memory_zone.get_pool_index_from_index(current)
            used = memory_zone.get_pool_end_from_pool_index(pool_index)
            if current >= used:
                self.current = memory_zone.get_pool_range(pool_index)[1] + 1
                return next(self)
            else:
                pointer = <unsigned int*>memory_zone.get_pointer(current)
                self.current += 1
                if pointer[0] == <unsigned int>-1:
                    return next(self)
            ...
  1. The python side of things has a somewhat related problem as StaticMemGameSystem.components returns entities that a) have the entity_id set to -1 (were once used and are freed atm) and b) also returns never used entities (the entity_id and everything else being 0).
    IMHO in both cases the python side of things should get a None.
    I am not sure how to handle this one. One way would be to initially set every entity_id to -1, but it would propably be nicer to simple not return never used entites (which as far as i understand can only be entities on the tail anyway).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant