Fixed a bug with the ObjectStore which would have caused some objects to
be ignored when running the game-loop functions.
This commit is contained in:
1 parent
be547b00ed
commit
149a1180d1
1 file changed
+6
@@ -93,8 +93,14 @@ void remove_object_from_store(ObjectStore *os, ObjectID *id_ptr) {
|
|||||||
|
|
||||||
os->reusable_ids[(os->deleted_count)++] = id;
|
os->reusable_ids[(os->deleted_count)++] = id;
|
||||||
|
|
||||||
|
if (id == (os->count - 1)) {
|
||||||
|
// Only decrement the count if the last object is deleted. Otherwise, the
|
||||||
|
// count shouldn't be decremented since the deleted object would be in the
|
||||||
|
// middle, which means that the functions that loop over all objects in the
|
||||||
|
// store will not actually loop over everything
|
||||||
os->count -= 1;
|
os->count -= 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void handle_all_objects_events(ObjectStore *os, const SDL_Event *event) {
|
void handle_all_objects_events(ObjectStore *os, const SDL_Event *event) {
|
||||||
if (!os || os->count == 0) {
|
if (!os || os->count == 0) {
|
||||||
|
|||||||
Reference in new issue
Block a user