From d6db1f0124bfbb74f81454d8edc5584cfecabe3a Mon Sep 17 00:00:00 2001 From: Pavel Date: Wed, 20 Oct 2021 22:34:51 +0200 Subject: [PATCH] remove unnecessary parentheses from alryslib.c --- alrys/alryslib.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/alrys/alryslib.c b/alrys/alryslib.c index 3082595..c905e4c 100644 --- a/alrys/alryslib.c +++ b/alrys/alryslib.c @@ -42,14 +42,14 @@ void segments(double x1, double y1, double x2, double y2, int *ls) { if(dx > 0) { - start = (int)(x2) + (ceil(x2) > x2) - 1; - stop = (int)(x1); + start = (int)x2 + (ceil(x2) > x2) - 1; + stop = (int)x1; step = -1; } else { - start = (int)(x2) + 1; - stop = (int)(x1) + (ceil(x1) > x1); + start = (int)x2 + 1; + stop = (int)x1 + (ceil(x1) > x1); step = 1; } for(i = start; i != stop; i += step) @@ -63,14 +63,14 @@ void segments(double x1, double y1, double x2, double y2, int *ls) { if(dy > 0) { - start = (int)(y2) + (ceil(y2) > y2) - 1; - stop = (int)(y1); + start = (int)y2 + (ceil(y2) > y2) - 1; + stop = (int)y1; step = -1; } else { - start = (int)(y2) + 1; - stop = (int)(y1) + (ceil(y1) > y1); + start = (int)y2 + 1; + stop = (int)y1 + (ceil(y1) > y1); step = 1; } for(i = start; i != stop; i += step) @@ -121,10 +121,10 @@ void forward(struct STATE *state, double l) for(k = 1; k < ls; ++k) { - xr = (int)(MIN(state->x, lx[k])); - yr = (int)(MIN(state->y, ly[k])); + xr = (int)MIN(state->x, lx[k]); + yr = (int)MIN(state->y, ly[k]); c1 = data[xr + yr * 146]; - c2 = data[(int)(lx[k]) + (int)(ly[k]) * 146]; + c2 = data[(int)lx[k] + (int)ly[k] * 146]; if(c1 == 1 || c2 == 1 || ((c1 == 3 || c2 == 3) && !state->boat)) break; d = hypot(lx[k] - state->x, ly[k] - state->y) * (0.2 + (c1 == 5) * 0.1 + (c1 == 4) * 0.2 + (c1 == 2) * 0.3); @@ -258,6 +258,6 @@ void output(double *steps, int size) printf("%1d %1d\n", (int)steps[0], (int)steps[1]); for(i = 2; i < size - 3; i += 4) { - printf("%7.3f %2d %6.3f %2d\n", steps[i + 0], (int)(steps[i + 1]), steps[i + 2], (int)(steps[i + 3])); + printf("%7.3f %2d %6.3f %2d\n", steps[i + 0], (int)steps[i + 1], steps[i + 2], (int)steps[i + 3]); } }