summaryrefslogtreecommitdiff
path: root/games/tetris
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2018-04-25 17:41:24 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2018-04-25 17:41:24 +0000
commit745c3110a3ce3f757d8af6db04cadc078f8a5380 (patch)
tree7cc891063a86f621f9c619008cc3d8df0bf88d4d /games/tetris
parent54224f2dd914b7caf984ff0ad51f47201be81904 (diff)
Use a NUMKEYS macro instead of magic and use a more familiar idiom
in for loops. ok stsp, bcallah
Diffstat (limited to 'games/tetris')
-rw-r--r--games/tetris/tetris.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/games/tetris/tetris.c b/games/tetris/tetris.c
index b6d5a0c6eaa..9d8149710a4 100644
--- a/games/tetris/tetris.c
+++ b/games/tetris/tetris.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tetris.c,v 1.32 2017/08/13 02:12:16 tedu Exp $ */
+/* $OpenBSD: tetris.c,v 1.33 2018/04/25 17:41:23 tb Exp $ */
/* $NetBSD: tetris.c,v 1.2 1995/04/22 07:42:47 cgd Exp $ */
/*-
@@ -52,6 +52,8 @@
#include "screen.h"
#include "tetris.h"
+#define NUMKEYS 6
+
cell board[B_SIZE];
int Rows, Cols;
const struct shape *curshape;
@@ -142,7 +144,6 @@ randshape(void)
tmp = &shapes[classic? tmp->rotc : tmp->rot];
return (tmp);
}
-
int
main(int argc, char *argv[])
@@ -150,7 +151,7 @@ main(int argc, char *argv[])
int pos, c;
char *keys;
int level = 2;
- char key_write[6][10];
+ char key_write[NUMKEYS][10];
const char *errstr;
int ch, i, j;
@@ -171,7 +172,7 @@ main(int argc, char *argv[])
classic = 1;
break;
case 'k':
- if (strlen(keys = optarg) != 6)
+ if (strlen(keys = optarg) != NUMKEYS)
usage();
break;
case 'l':
@@ -199,8 +200,8 @@ main(int argc, char *argv[])
fallrate = 1000000000L / level;
- for (i = 0; i <= 5; i++) {
- for (j = i+1; j <= 5; j++) {
+ for (i = 0; i < NUMKEYS; i++) {
+ for (j = i+1; j < NUMKEYS; j++) {
if (keys[i] == keys[j])
errx(1, "duplicate command keys specified.");
}