Simplify boolean expressions

This commit is contained in:
kichikuou
2025-02-02 09:36:20 +09:00
parent bc5d72b6fe
commit 29988d0d6c
20 changed files with 39 additions and 39 deletions
+2 -2
View File
@@ -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);
}
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -104,7 +104,7 @@ static boolean waitcond(int endtime) {
}
// その他キー入力があれば終了
return sact.waitkey == -1 ? FALSE : TRUE;
return sact.waitkey != -1;
}
/*
+2 -2
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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);
}
+1 -1
View File
@@ -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);
}
+1 -1
View File
@@ -135,7 +135,7 @@ void commandIX() {
/* 「次の選択肢まで進む」の状態取得 */
int *var = getCaliVariable();
*var = msgskip_isSkipping() == TRUE ? 1 : 0;
*var = msgskip_isSkipping() ? 1 : 0;
TRACE("IX %p:",var);
}
+2 -2
View File
@@ -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();
+2 -2
View File
@@ -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;
}
+4 -4
View File
@@ -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 異常シナリオ対策 */
+7 -7
View File
@@ -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;
+2 -2
View File
@@ -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;
+5 -5
View File
@@ -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);
}
+2 -2
View File
@@ -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;
}
+1 -1
View File
@@ -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) {
+1 -1
View File
@@ -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) {
+1 -1
View File
@@ -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) {