From f56ec88cda3fe2347d6a4e534d97d7e3c4698fa9 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sun, 26 Jun 2022 08:41:12 +0900 Subject: [PATCH] Make sure nact->is_quit breaks event loops --- modules/NIGHTDLL/nt_scenario.c | 2 +- src/input.c | 13 +++++++------ src/selection.c | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/NIGHTDLL/nt_scenario.c b/modules/NIGHTDLL/nt_scenario.c index e3f53e8..eaf2e09 100644 --- a/modules/NIGHTDLL/nt_scenario.c +++ b/modules/NIGHTDLL/nt_scenario.c @@ -52,7 +52,7 @@ static void ntmain(struct _scoadr inadr) { struct _scoadr curadr; while (!nact->is_quit) { - for (int cnt = 0; !nact->wait_vsync && cnt < 10000; cnt++) { + for (int cnt = 0; !nact->is_quit && !nact->wait_vsync && cnt < 10000; cnt++) { //SACT_DEBUG("%d:%x\n", sl_getPage(), sl_getIndex()); if (!nact->popupmenu_opened) { exec_command(); diff --git a/src/input.c b/src/input.c index 5be5db8..5d6796b 100644 --- a/src/input.c +++ b/src/input.c @@ -92,7 +92,8 @@ int sys_keywait(int msec, unsigned flags) { int key=0, n; int end = msec == INT_MAX ? INT_MAX : sdl_getTicks() + msec; - while (!((flags & KEYWAIT_SKIPPABLE) && msgskip_isSkipping()) && + while (!nact->is_quit && + !((flags & KEYWAIT_SKIPPABLE) && msgskip_isSkipping()) && (n = end - sdl_getTicks()) > 0) { if (n <= 16) sdl_sleep(n); @@ -122,19 +123,19 @@ void sys_hit_any_key() { if (nact->messagewait_cancelled) { nact->messagewait_cancelled = FALSE; /* consume the input that cancelled message wait */ - while(0 == (key & hak_ignore_mask)) { + while (!nact->is_quit && !(key & hak_ignore_mask)) { key = sys_keywait(INT_MAX, KEYWAIT_CANCELABLE); } - while(key & hak_releasewait_mask) { + while (!nact->is_quit && key & hak_releasewait_mask) { key = sys_keywait(100, KEYWAIT_CANCELABLE); } } - while (!msgskip_isSkipping() && 0 == (key & hak_ignore_mask)) { + while (!nact->is_quit && !msgskip_isSkipping() && 0 == (key & hak_ignore_mask)) { key = sys_keywait(100, KEYWAIT_CANCELABLE | KEYWAIT_SKIPPABLE); } - while (!msgskip_isSkipping() && (key & hak_releasewait_mask)) { + while (!nact->is_quit && !msgskip_isSkipping() && (key & hak_releasewait_mask)) { key = sys_keywait(100, KEYWAIT_CANCELABLE | KEYWAIT_SKIPPABLE); } } @@ -148,7 +149,7 @@ void sys_key_releasewait(int key, boolean zi_mask_enabled) { mask = 0xffffffff; } - while(key & mask) { + while (!nact->is_quit && key & mask) { key = sys_keywait(50, KEYWAIT_NONCANCELABLE); } } diff --git a/src/selection.c b/src/selection.c index 1b5b587..4fd8b3f 100644 --- a/src/selection.c +++ b/src/selection.c @@ -457,7 +457,7 @@ void sel_select() { } sys_key_releasewait(SYS35KEY_RET, FALSE); - while (1) { + while (!nact->is_quit) { key = sys_keywait(25, KEYWAIT_CANCELABLE); if (!key && prevkey == SYS35KEY_SPC) break;