From 29988d0d6c2d8dc7efca8da413d9c5db967d5143 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sun, 2 Feb 2025 09:36:20 +0900 Subject: [PATCH] Simplify boolean expressions --- modules/NIGHTDLL/NIGHTDLL.c | 4 ++-- modules/SACT/sprite.c | 2 +- modules/SACT/sprite_keywait.c | 2 +- modules/SACT/sprite_sel.c | 4 ++-- modules/lib/graph_expandcolor_blend.c | 2 +- modules/lib/graph_rect.c | 2 +- modules/lib/graph_saturadd_amap.c | 2 +- src/cmd2F.c | 2 +- src/cmdb.c | 2 +- src/cmdi.c | 2 +- src/cmdm.c | 4 ++-- src/cmdp.c | 4 ++-- src/cmds.c | 8 ++++---- src/cmdv.c | 14 +++++++------- src/cmdw.c | 4 ++-- src/cmdz.c | 10 +++++----- src/cursor.c | 4 ++-- src/gameresource.c | 2 +- src/menu_emscripten.c | 2 +- src/message.c | 2 +- 20 files changed, 39 insertions(+), 39 deletions(-) diff --git a/modules/NIGHTDLL/NIGHTDLL.c b/modules/NIGHTDLL/NIGHTDLL.c index 00830a1..1aad29e 100644 --- a/modules/NIGHTDLL/NIGHTDLL.c +++ b/modules/NIGHTDLL/NIGHTDLL.c @@ -400,7 +400,7 @@ static void CDStop(void) { /* 39 */ static void CDMute(void) { /* 40 */ int p1 = getCaliValue(); // 0: mute off, 1: mute on - nt_cd_mute(p1 == 0 ? FALSE : TRUE); + nt_cd_mute(p1 != 0); TRACE_UNIMPLEMENTED("NIGHTDLL.CDMute %d:", p1); } @@ -440,7 +440,7 @@ static void SoundEffectSetSyncFlag(void) { /* 44 */ int p1 = getCaliValue(); // ch int p2 = getCaliValue(); // 0: 終るまで待たない, 1: 待つ - nt_snd_waitend(p1, p2 == 0 ? FALSE : TRUE); + nt_snd_waitend(p1, p2 != 0); TRACE_UNIMPLEMENTED("NIGHTDLL.SoundEffectSetSyncFlag %d,%d:", p1, p2); } diff --git a/modules/SACT/sprite.c b/modules/SACT/sprite.c index 4e55ea5..ca4ee1f 100644 --- a/modules/SACT/sprite.c +++ b/modules/SACT/sprite.c @@ -340,7 +340,7 @@ int sp_set_show(int wNum, int wCount, int sShow) { sp = sact.sp[i]; oldstate = sp->show; - sp->show = (sShow == 1 ? TRUE : FALSE); + sp->show = sShow == 1; } return OK; } diff --git a/modules/SACT/sprite_keywait.c b/modules/SACT/sprite_keywait.c index aa138e1..73691ee 100644 --- a/modules/SACT/sprite_keywait.c +++ b/modules/SACT/sprite_keywait.c @@ -104,7 +104,7 @@ static boolean waitcond(int endtime) { } // その他キー入力があれば終了 - return sact.waitkey == -1 ? FALSE : TRUE; + return sact.waitkey != -1; } /* diff --git a/modules/SACT/sprite_sel.c b/modules/SACT/sprite_sel.c index d097bb0..d74af91 100644 --- a/modules/SACT/sprite_sel.c +++ b/modules/SACT/sprite_sel.c @@ -86,7 +86,7 @@ static void cb_select_move(agsevent_t *e) { newindex = (y - (sp->cur.y + sact.sel.frame_dot)) / (sact.sel.font_size + sact.sel.linespace); if (newstate == oldstate) { - if ((newstate == FALSE) || (newindex == oldindex)) { + if (!newstate || newindex == oldindex) { // 前と状態が同じでかつ、新しい状態がspriteの外か、 // indexが変わらない場合はなにもしない。 return; @@ -125,7 +125,7 @@ static void cb_select_release(agsevent_t *e) { iy = (y - (sp->cur.y + sact.sel.frame_dot)) / (sact.sel.font_size + sact.sel.linespace); // カーソルが sprite の外の場合は無視 - if (st == FALSE) { + if (!st) { return; } diff --git a/modules/lib/graph_expandcolor_blend.c b/modules/lib/graph_expandcolor_blend.c index f4cb9f4..c113c64 100644 --- a/modules/lib/graph_expandcolor_blend.c +++ b/modules/lib/graph_expandcolor_blend.c @@ -11,7 +11,7 @@ int gr_expandcolor_blend(surface_t *dst, int dx, int dy, surface_t *src, int sx, int x, y; int col; - if (FALSE == gr_clip(src, &sx, &sy, &sw, &sh, dst, &dx, &dy)) { + if (!gr_clip(src, &sx, &sy, &sw, &sh, dst, &dx, &dy)) { return NG; } diff --git a/modules/lib/graph_rect.c b/modules/lib/graph_rect.c index 5fd2fb7..f4f69e0 100644 --- a/modules/lib/graph_rect.c +++ b/modules/lib/graph_rect.c @@ -10,7 +10,7 @@ int gr_drawrect(surface_t *dst, int x, int y, int w, int h, int r, int g, int b) int i; int col = 0; - if (FALSE == gr_clip_xywh(dst, &x, &y, &w, &h)) { + if (!gr_clip_xywh(dst, &x, &y, &w, &h)) { return NG; } diff --git a/modules/lib/graph_saturadd_amap.c b/modules/lib/graph_saturadd_amap.c index 4542f7a..7584dd4 100644 --- a/modules/lib/graph_saturadd_amap.c +++ b/modules/lib/graph_saturadd_amap.c @@ -12,7 +12,7 @@ int gr_saturadd_alpha_map(surface_t *dst, int dx, int dy, surface_t *src, int sx uint8_t *sp, *dp; int x, y; - if (FALSE == gr_clip(src, &sx, &sy, &sw, &sh, dst, &dx, &dy)) { + if (!gr_clip(src, &sx, &sy, &sw, &sh, dst, &dx, &dy)) { return NG; } diff --git a/src/cmd2F.c b/src/cmd2F.c index e2ed936..2d2271f 100644 --- a/src/cmd2F.c +++ b/src/cmd2F.c @@ -1185,7 +1185,7 @@ void commands2F6B() { void commands2F6C() { int eFlag = getCaliValue(); - nact->is_msg_out = eFlag != 0 ? TRUE : FALSE; + nact->is_msg_out = eFlag != 0; TRACE("msgSetOutputFlag %d:", eFlag); } diff --git a/src/cmdb.c b/src/cmdb.c index 2c909a1..379bc04 100644 --- a/src/cmdb.c +++ b/src/cmdb.c @@ -108,7 +108,7 @@ void commandB3() { nact->msg.wininfo[num].y = Y1; nact->msg.wininfo[num].width = X2; nact->msg.wininfo[num].height = Y2; - nact->msg.wininfo[num].save = (V == 0) ? FALSE : TRUE; + nact->msg.wininfo[num].save = V != 0; TRACE("B3 %d,%d,%d,%d,%d,%d:", num, X1, Y1, X2, Y2, V); } diff --git a/src/cmdi.c b/src/cmdi.c index 586af44..194abfb 100644 --- a/src/cmdi.c +++ b/src/cmdi.c @@ -135,7 +135,7 @@ void commandIX() { /* 「次の選択肢まで進む」の状態取得 */ int *var = getCaliVariable(); - *var = msgskip_isSkipping() == TRUE ? 1 : 0; + *var = msgskip_isSkipping() ? 1 : 0; TRACE("IX %p:",var); } diff --git a/src/cmdm.c b/src/cmdm.c index 2bbb151..1b76052 100644 --- a/src/cmdm.c +++ b/src/cmdm.c @@ -265,7 +265,7 @@ void commandMG() { switch(no) { case 0: sw = getCaliValue(); - nact->msg.mg_getString = sw == 1 ? TRUE : FALSE; + nact->msg.mg_getString = sw == 1; break; case 1: sw = getCaliValue(); @@ -298,7 +298,7 @@ void commandMG() { break; case 100: sw = getCaliValue(); - nact->msg.mg_dspMsg = sw == 1 ? TRUE : FALSE; + nact->msg.mg_dspMsg = sw == 1; break; default: sw = getCaliValue(); diff --git a/src/cmdp.c b/src/cmdp.c index 0b55308..3276477 100644 --- a/src/cmdp.c +++ b/src/cmdp.c @@ -41,7 +41,7 @@ void commandPF() { boolean cancel_enabled; if (p1 == 2 || p1 == 3) { - cancel_enabled = getCaliValue() == 0 ? FALSE : TRUE; + cancel_enabled = getCaliValue() != 0; } else { cancel_enabled = FALSE; } @@ -69,7 +69,7 @@ void commandPW() { boolean cancel_enabled; if (p1 == 2 || p1 == 3) { - cancel_enabled = getCaliValue() == 0 ? FALSE : TRUE; + cancel_enabled = getCaliValue() != 0; } else { cancel_enabled = FALSE; } diff --git a/src/cmds.c b/src/cmds.c index 3916c34..2c44436 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -130,9 +130,9 @@ void commandSI() { int *var = getCaliVariable(); if (type == 0) { /* MIDI */ - *var = mus_midi_get_state() == TRUE ? 1 : 0; + *var = mus_midi_get_state() ? 1 : 0; } else if (type == 1) { /* PCM */ - *var = mus_pcm_get_state() == TRUE ? 1 : 0; + *var = mus_pcm_get_state() ? 1 : 0; } else if (type == 2) { /* CD */ *var = muscd_is_available() ? 1 : 0; } @@ -268,8 +268,8 @@ void commandSU() { *var1 = *var2 ? 1 : 0; /* XXX for panyon_new */ if (*var2 == 0){ - *var1 = dummy_pcm_in_play ? TRUE : FALSE; - dummy_pcm_in_play = dummy_pcm_in_play ? FALSE : TRUE; + *var1 = dummy_pcm_in_play; + dummy_pcm_in_play = !dummy_pcm_in_play; } } /* 闘神都市II 異常シナリオ対策 */ diff --git a/src/cmdv.c b/src/cmdv.c index 19c124f..f4caf36 100644 --- a/src/cmdv.c +++ b/src/cmdv.c @@ -416,12 +416,12 @@ void commandVF() { /* from Panyo */ for (i = 0; i < nPageNum; i++) { img = &srcimg[i]; - if (img->fEnable == FALSE) continue; + if (!img->fEnable) continue; for (y = 0; y < cyMap; y++) { for (x = 0; x < cxMap; x++) { unit = *UNITMAP_UNITNUMBER(i, x, y); - if (img->useTTP == TRUE && img->TTPunit == unit) continue; + if (img->useTTP && img->TTPunit == unit) continue; // printf("i = %d, x = %d, y = %d, unit no = %d\n", i, x, y,unit); unit_x = unit % img->nxUnit; unit_y = unit / img->nxUnit; @@ -452,7 +452,7 @@ void commandVV() { /* from T2 */ TRACE("VV %d,%d:",nPage, fEnable); - srcimg[nPage].fEnable = (fEnable == 1 ? TRUE : FALSE); + srcimg[nPage].fEnable = fEnable == 1; } void commandVR() { /* from Rance4 */ @@ -534,7 +534,7 @@ void commandVE() { /* from T2 */ for (i = 0; i < nPageNum; i++) { img = &srcimg[i]; /* VV による */ - if (img->fEnable == FALSE) continue; + if (!img->fEnable) continue; for (yy = y; yy < (y+height); yy++) { for (xx = x; xx < (x+width); xx++) { @@ -544,7 +544,7 @@ void commandVE() { /* from T2 */ unit = *UNITMAP_UNITNUMBER(i, xx, yy); } - if (img->useTTP == TRUE && img->TTPunit == unit) continue; + if (img->useTTP && img->TTPunit == unit) continue; //printf("i = %d, xx = %d, yy = %d, unit no = %d\n", i, xx, yy,unit); unit_x = unit % img->nxUnit; unit_y = unit / img->nxUnit; @@ -679,11 +679,11 @@ void commandVIC() { /* from Panyo */ for (i = 0; i < nPageNum; i++) { img = &srcimg[i]; - if (img->fEnable == FALSE) continue; + if (!img->fEnable) continue; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { unit = *UNITMAP_UNITNUMBER(i, sx + x, sy + y); - if (img->useTTP == TRUE && img->TTPunit == unit) continue; + if (img->useTTP && img->TTPunit == unit) continue; //printf("i = %d, xx = %d, yy = %d, unit no = %d\n", i, xx, yy, unit); unit_x = unit % img->nxUnit; unit_y = unit / img->nxUnit; diff --git a/src/cmdw.c b/src/cmdw.c index 61f4a9b..ffa058e 100644 --- a/src/cmdw.c +++ b/src/cmdw.c @@ -57,7 +57,7 @@ void commandWZ() { switch(p1) { case 0: - ags_setExposeSwitch(sw == 0 ? FALSE : TRUE); + ags_setExposeSwitch(sw != 0); if (sw == 1) { /* う〜ん こんな処理いれなあかんのかぁ〜 (T_T) */ if (nact->ags.world_depth == 8) nact->ags.pal_changed = TRUE; @@ -65,7 +65,7 @@ void commandWZ() { } break; case 1: - ags_setExposeSwitch(sw == 0 ? FALSE : TRUE); + ags_setExposeSwitch(sw != 0); break; default: break; diff --git a/src/cmdz.c b/src/cmdz.c index fca5390..98876cf 100644 --- a/src/cmdz.c +++ b/src/cmdz.c @@ -126,11 +126,11 @@ void commandZW() { int sw = getCaliValue(); if (sw < 256) { - nact->messagewait_enable = ((sw & 0xff) <= 1) ? FALSE : TRUE; + nact->messagewait_enable = ((sw & 0xff) > 1); nact->messagewait_cancelled = FALSE; } else { - nact->messagewait_time = sw & 0xff; - nact->messagewait_cancel = (sw & 0x200) ? TRUE : FALSE; + nact->messagewait_time = sw & 0xff; + nact->messagewait_cancel = !!(sw & 0x200); } TRACE("ZW %d:", sw); @@ -149,7 +149,7 @@ void commandZE() { /* 選択肢を選んだらメッセージ領域を初期化するかどうかを指定する */ int sw = getCaliValue(); - nact->sel.ClearMsgWindow = sw == 0 ? FALSE : TRUE; + nact->sel.ClearMsgWindow = sw != 0; TRACE("ZE %d:", sw); } @@ -524,7 +524,7 @@ void commandZA() { /* T2 */ msg_setStringDecorationColor(p2); break; case 2: case 3: - nact->msg.AutoPageChange = (p2 == 0 ? FALSE : TRUE); break; + nact->msg.AutoPageChange = p2 != 0; break; default: WARNING("Unknown ZA comannd %d, %d", p1, p2); } diff --git a/src/cursor.c b/src/cursor.c index 6be0dc6..ff7bb4e 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -263,7 +263,7 @@ static boolean cursor_load_mono(uint8_t *d, int no) { int pos = 6, p1; /* check header information */ - if (check_iconheader(d) == FALSE) { + if (!check_iconheader(d)) { WARNING("check_iconhdader fail"); return FALSE; } @@ -293,7 +293,7 @@ static boolean cursor_load_mono(uint8_t *d, int no) { pos += p1; /* read pixedl data */ - if (sdl_cursorNew(d + pos, no, &cursorImage, &cursordirentry) == FALSE) { + if (!sdl_cursorNew(d + pos, no, &cursorImage, &cursordirentry)) { WARNING("unable to read pixel data"); return FALSE; } diff --git a/src/gameresource.c b/src/gameresource.c index 52f4876..0f0c98a 100644 --- a/src/gameresource.c +++ b/src/gameresource.c @@ -152,7 +152,7 @@ boolean initGameResourceFromDir(GameResource *gr, DIR *dir, const char *savedir, } free(basename); - return (gr->cnt[DRIFILE_SCO] > 0) ? TRUE : FALSE; + return gr->cnt[DRIFILE_SCO] > 0; } static void trimRight(char *str) { diff --git a/src/menu_emscripten.c b/src/menu_emscripten.c index 1ce4c43..3fddcce 100644 --- a/src/menu_emscripten.c +++ b/src/menu_emscripten.c @@ -48,7 +48,7 @@ boolean menu_inputstring(INPUTSTRING_PARAM *p) { p->newstring = buf; else p->newstring = p->oldstring; - return ok ? TRUE : FALSE; + return ok; } boolean menu_inputstring2(INPUTSTRING_PARAM *p) { diff --git a/src/message.c b/src/message.c index e66c289..08f02d8 100644 --- a/src/message.c +++ b/src/message.c @@ -321,7 +321,7 @@ void msg_openWindow(int W, int C1, int C2, int N, int M) { default: break; } - if (M == 0) msg_nextPage(N == 0 ? TRUE : FALSE); + if (M == 0) msg_nextPage(N == 0); } void msg_setMessageLocation(int x, int y) {