summaryrefslogtreecommitdiffstats
path: root/games
diff options
context:
space:
mode:
authortb <tb@openbsd.org>2018-04-25 17:41:23 +0000
committertb <tb@openbsd.org>2018-04-25 17:41:23 +0000
commitf26e040b81c32c8a3a5c934e954b96d7e782ca66 (patch)
tree2693b87e4a565fb1af5b048ebd98bbb95edc8ed7 /games
parentSimplify the handling of faults in iretq and xrstor by doing the (diff)
downloadwireguard-openbsd-f26e040b81c32c8a3a5c934e954b96d7e782ca66.tar.xz
wireguard-openbsd-f26e040b81c32c8a3a5c934e954b96d7e782ca66.zip
Use a NUMKEYS macro instead of magic and use a more familiar idiom
in for loops. ok stsp, bcallah
Diffstat (limited to 'games')
-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.");
}