Merge pull request #11899 from Jamiras/cheevos_runtime_iterate_modify

(cheevos) traverse list in reverse order in case items are removed by callback
This commit is contained in:
Autechre 2021-01-18 20:07:52 +01:00 committed by GitHub
commit 2aac83faf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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;