traverse list in reverse order in case items are removed by callback

This commit is contained in:
Jamiras 2021-01-17 22:33:48 -07:00
parent 41981f62e1
commit ca2c57a5a1

View File

@ -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;