From ca2c57a5a1a5fdea49ee323b79ca271224166647 Mon Sep 17 00:00:00 2001 From: Jamiras Date: Sun, 17 Jan 2021 22:33:48 -0700 Subject: [PATCH] traverse list in reverse order in case items are removed by callback --- deps/rcheevos/src/rcheevos/runtime.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deps/rcheevos/src/rcheevos/runtime.c b/deps/rcheevos/src/rcheevos/runtime.c index b9e9df4e76..51094bb43f 100644 --- a/deps/rcheevos/src/rcheevos/runtime.c +++ b/deps/rcheevos/src/rcheevos/runtime.c @@ -442,13 +442,13 @@ const char* rc_runtime_get_richpresence(const rc_runtime_t* self) void rc_runtime_do_frame(rc_runtime_t* self, rc_runtime_event_handler_t event_handler, rc_peek_t peek, void* ud, lua_State* L) { rc_runtime_event_t runtime_event; - unsigned i; + int i; runtime_event.value = 0; rc_update_memref_values(self->memrefs, peek, ud); - for (i = 0; i < self->trigger_count; ++i) { + for (i = self->trigger_count - 1; i >= 0; --i) { rc_trigger_t* trigger = self->triggers[i].trigger; int trigger_state; @@ -497,7 +497,7 @@ void rc_runtime_do_frame(rc_runtime_t* self, rc_runtime_event_handler_t event_ha } } - for (i = 0; i < self->lboard_count; ++i) { + for (i = self->lboard_count - 1; i >= 0; --i) { rc_lboard_t* lboard = self->lboards[i].lboard; int lboard_state;