diff --git a/server.c b/server.c index fcb586d..3ac5a3d 100644 --- a/server.c +++ b/server.c @@ -202,7 +202,7 @@ static void parse(int argc, char *argv[]) int countLength3 = 0; int countLength4 = 0; - for (int i = 0; i < sizeof(ships)/sizeof(struct Ship); i++) { + for (int i = 0; i < 6; i++) { if (ships[i]->shipsize == 2) { countLength2++; } else if (ships[i]->shipsize == 3) { @@ -216,9 +216,9 @@ static void parse(int argc, char *argv[]) } } - if (countLength2 != SHIP_CNT_LEN2 || - countLength3 != SHIP_CNT_LEN3 || - countLength4 != SHIP_CNT_LEN4) { + if ((countLength2 != SHIP_CNT_LEN2) || + (countLength3 != SHIP_CNT_LEN3) || + (countLength4 != SHIP_CNT_LEN4)) { fprintf(stderr, "[%s]: There must be exactly 2 ships of length 2, 3 ships of length 3 and 1 ship of length 4!\n", pname); cleanup(); usage();